List of usage examples for org.apache.lucene.util IOUtils rm
private static LinkedHashMap<Path, Throwable> rm(final LinkedHashMap<Path, Throwable> unremoved, Path... locations)
From source file:org.elasticsearch.plugins.PluginManagerTests.java
License:Apache License
@Test public void testLocalPluginInstallWithBinAndConfig() throws Exception { String pluginName = "plugin-test"; Tuple<Settings, Environment> initialSettings = buildInitialSettings(); Environment env = initialSettings.v2(); Path binDir = env.homeFile().resolve("bin"); if (!Files.exists(binDir)) { Files.createDirectories(binDir); }// w ww . jav a 2s . c o m Path pluginBinDir = binDir.resolve(pluginName); Path configDir = env.configFile(); if (!Files.exists(configDir)) { Files.createDirectories(configDir); } Path pluginConfigDir = configDir.resolve(pluginName); try { PluginManager pluginManager = pluginManager(getPluginUrlForResource("plugin_with_bin_and_config.zip"), initialSettings); pluginManager.downloadAndExtract(pluginName); Path[] plugins = pluginManager.getListInstalledPlugins(); assertThat(plugins, arrayWithSize(1)); assertDirectoryExists(pluginBinDir); assertDirectoryExists(pluginConfigDir); Path toolFile = pluginBinDir.resolve("tool"); assertFileExists(toolFile); // check that the file is marked executable, without actually checking that we can execute it. PosixFileAttributeView view = Files.getFileAttributeView(toolFile, PosixFileAttributeView.class); // the view might be null, on e.g. windows, there is nothing to check there! if (view != null) { PosixFileAttributes attributes = view.readAttributes(); assertTrue("unexpected permissions: " + attributes.permissions(), attributes.permissions().contains(PosixFilePermission.OWNER_EXECUTE)); } } finally { // we need to clean up the copied dirs IOUtils.rm(pluginBinDir, pluginConfigDir); } }