Beispiel #1
0
 private static String getPath(URI surl) {
   String path = surl.getPath();
   String query = surl.getQuery();
   if (query != null) {
     int i = query.indexOf(SFN_STRING);
     if (i != -1) {
       path = query.substring(i + SFN_STRING.length());
     }
   }
   /* REVISIT
    *
    * This is not correct in the presence of symlinked directories. The
    * simplified path may refer to a different directory than the one
    * we will delete.
    *
    * For now we ignore this problem - fixing it requires resolving the
    * paths to an absolute path, which requires additional name space
    * lookups.
    */
   path = Files.simplifyPath(path);
   if (!path.endsWith("/")) {
     path = path + "/";
   }
   return path;
 }
  @Test
  public void testThatConfigDirectoryCanBeOutsideOfElasticsearchHomeDirectory() throws IOException {
    String pluginName = randomAsciiOfLength(10);
    Path homeFolder = createTempDir();
    Path genericConfigFolder = createTempDir();

    Settings settings =
        settingsBuilder()
            .put("path.conf", genericConfigFolder)
            .put("path.home", homeFolder)
            .build();
    Environment environment = new Environment(settings);

    PluginManager.PluginHandle pluginHandle =
        new PluginManager.PluginHandle(pluginName, "version", "user", "repo");
    String configDirPath =
        Files.simplifyPath(pluginHandle.configDir(environment).normalize().toString());
    String expectedDirPath =
        Files.simplifyPath(genericConfigFolder.resolve(pluginName).normalize().toString());

    assertThat(configDirPath, is(expectedDirPath));
  }