List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:co.runrightfast.vertx.orientdb.hooks.RunRightFastOrientDBLifeCycleListenerTest.java
@BeforeClass public static void setUpClass() throws Exception { orientdbHome.mkdirs();/* w w w. ja va2s . com*/ FileUtils.cleanDirectory(orientdbHome); FileUtils.deleteDirectory(orientdbHome); log.logp(INFO, CLASS_NAME, "setUpClass", String.format("orientdbHome.exists() = %s", orientdbHome.exists())); final File configDirSrc = new File("src/test/resources/orientdb/config"); final File configDirTarget = new File(orientdbHome, "config"); FileUtils.copyFileToDirectory(new File(configDirSrc, "default-distributed-db-config.json"), configDirTarget); FileUtils.copyFileToDirectory(new File(configDirSrc, "hazelcast.xml"), configDirTarget); server = createOServer(); server.activate(); final File dbDir = new File(orientdbHome, String.format("databases/%s", RunRightFastOrientDBLifeCycleListenerTest.class.getSimpleName())); final String dbUrl = "plocal:" + dbDir.getAbsolutePath(); try (final ODatabase db = new ODatabaseFactory().createDatabase("document", dbUrl).create()) { log.logp(INFO, CLASS_NAME, "setUpClass", String.format("created db = %s", db.getName())); final OClass timestampedClass = db.getMetadata().getSchema() .createAbstractClass(Timestamped.class.getSimpleName()); timestampedClass.createProperty(Timestamped.Field.created_on.name(), OType.DATETIME); timestampedClass.createProperty(Timestamped.Field.updated_on.name(), OType.DATETIME); final OClass logRecordClass = db.getMetadata().getSchema() .createClass(EventLogRecord.class.getSimpleName()) .setSuperClasses(ImmutableList.of(timestampedClass)); logRecordClass.createProperty(EventLogRecord.Field.event.name(), OType.STRING); } }
From source file:io.github.bonigarcia.wdm.test.CacheTest.java
@Before public void deleteDownloadedFiles() throws IOException { FileUtils.cleanDirectory(new File(new Downloader(null).getTargetPath())); }
From source file:at.uni_salzburg.cs.ros.viewer.services.BigraphArchiveImpl.java
/** * @param imageRenderer the BigraphImageRenderer instance. * @throws IOException/* w w w . j a v a2 s. c o m*/ */ public BigraphArchiveImpl(BigraphImageRenderer imageRenderer) throws IOException { this.imageRenderer = imageRenderer; String bgmArchiveDirName = System.getProperty(BGM_ARCHIVE_PROP, BGM_ARCHIVE_DEFAULT_DIR); bgmArchive = new File(bgmArchiveDirName); FileUtils.forceMkdir(bgmArchive); LOG.info("Using archive directory {}", bgmArchive.getAbsolutePath()); String cleanUp = System.getProperty(BGM_ARCHIVE_CLEANUP_PROP, "true"); if ("true".equalsIgnoreCase(cleanUp)) { LOG.info("Cleaning up bigraph image archive folder '{}'", bgmArchive.getAbsolutePath()); FileUtils.cleanDirectory(bgmArchive); } else { LOG.info("Cleaning up bigraph image archive folder '{}' declined.", bgmArchive.getAbsolutePath()); } }
From source file:com.googlecode.jgenhtml.JGenHtmlTest.java
private void runJgenhtml() { try {/*www . j a v a 2 s . c o m*/ File outputDir = JGenHtmlTestUtils.getTestDir(); FileUtils.cleanDirectory(outputDir);//START WITH A CLEAN DIRECTORY! jstdTestDir = new File(outputDir, "jstd"); cCodeTestDir = new File(outputDir, "code"); baselinedTestDir = new File(outputDir, "baselined"); noSourceTestDir = new File(outputDir, "nosource"); String[] argv = new String[] { "-o", jstdTestDir.getAbsolutePath(), JGenHtmlTestUtils.getJstdTraceFiles(false, false)[0] }; JGenHtml.main(argv); argv = new String[] { "-o", cCodeTestDir.getAbsolutePath(), JGenHtmlTestUtils.getTraceFilesWithBranchAndFuncData()[0] }; JGenHtml.main(argv); argv = new String[] { "-o", baselinedTestDir.getAbsolutePath(), "-b", JGenHtmlTestUtils.getBaselineFile(), JGenHtmlTestUtils.getTraceFilesWithBranchAndFuncData()[0] }; JGenHtml.main(argv); argv = new String[] { "-o", noSourceTestDir.getAbsolutePath(), "--no-source", JGenHtmlTestUtils.getTraceFilesWithBranchAndFuncData()[0] }; JGenHtml.main(argv); } catch (IOException ex) { fail(ex.getLocalizedMessage()); } }
From source file:hudson.maven.AbstractMaven3xBuildTest.java
public void testSimpleMaven3BuildRedeployPublisher() throws Exception { MavenModuleSet m = createMavenProject(); MavenInstallation mavenInstallation = configureMaven3x(); m.setMaven(mavenInstallation.getName()); File repo = createTmpDir();//from ww w .j a v a2s . c o m FileUtils.cleanDirectory(repo); m.getReporters().add(new TestReporter()); m.getPublishersList().add(new RedeployPublisher("", repo.toURI().toString(), true, false)); m.setScm(new ExtractResourceSCM(getClass().getResource("maven3-project.zip"))); m.setGoals("clean install"); MavenModuleSetBuild b = buildAndAssertSuccess(m); assertTrue(MavenUtil.maven3orLater(b.getMavenVersionUsed())); File artifactDir = new File(repo, "com/mycompany/app/my-app/1.7-SNAPSHOT/"); String[] files = artifactDir.list(new FilenameFilter() { public boolean accept(File dir, String name) { System.out.println("file name : " + name); return name.endsWith(".jar"); } }); assertTrue("SNAPSHOT exist", !files[0].contains("SNAPSHOT")); assertTrue("file not ended with -1.jar", files[0].endsWith("-1.jar")); }
From source file:com.thoughtworks.go.server.initializers.PluginsInitializer.java
@Override public void initialize() { cleanupOldPluginDirectories();/* ww w. j a v a 2s.c o m*/ try { File bundledPluginsDirectory = new File(systemEnvironment.get(PLUGIN_GO_PROVIDED_PATH)); if (shouldReplaceBundledPlugins(bundledPluginsDirectory)) { FileUtils.cleanDirectory(bundledPluginsDirectory); zipUtil.unzip(getPluginsZipStream(), bundledPluginsDirectory); } pluginManager.startInfrastructure(true); } catch (Exception e) { LOG.error("Could not extract bundled plugins to default bundled directory", e); } }
From source file:Helpers.FileHelper.java
public void deleteDirectory(File path) { if (path.exists()) { try {// ww w . ja v a2s. co m File f = path; FileUtils.cleanDirectory(f); //clean out directory (this is optional -- but good know) FileUtils.forceDelete(f); //delete directory FileUtils.forceMkdir(f); //create directory } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.streamsets.datacollector.execution.runner.TestSlaveStandaloneRunner.java
@After public void tearDown() throws Exception { TestUtil.EMPTY_OFFSET = false;/*from www . j a va2 s .c om*/ File dataDir = new File(System.getProperty(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.DATA_DIR)); try { FileUtils.cleanDirectory(dataDir); } catch (IOException e) { // ignore } Assert.assertTrue(dataDir.isDirectory()); }
From source file:co.runrightfast.vertx.orientdb.impl.embedded.EmbeddedOrientDBServiceTest.java
@BeforeClass public static void setUpClass() throws Exception { orientdbHome.mkdirs();//from w w w . j av a 2 s . c o m FileUtils.cleanDirectory(orientdbHome); FileUtils.deleteDirectory(orientdbHome); log.logp(INFO, CLASS_NAME, "setUpClass", String.format("orientdbHome.exists() = %s", orientdbHome.exists())); final File configDirSrc = new File("src/test/resources/orientdb/config"); final File configDirTarget = new File(orientdbHome, "config"); FileUtils.copyFileToDirectory(new File(configDirSrc, "default-distributed-db-config.json"), configDirTarget); FileUtils.copyFileToDirectory(new File(configDirSrc, "hazelcast.xml"), configDirTarget); final ApplicationId appId = ApplicationId.builder().group("co.runrightfast") .name("runrightfast-vertx-orientdb").version("1.0.0").build(); final AppEventLogger appEventLogger = new AppEventJDKLogger(appId); final EmbeddedOrientDBServiceConfig config = EmbeddedOrientDBServiceConfig.builder() .orientDBRootDir(orientdbHome.toPath()).handler(new OGraphServerHandlerConfig()) .handler(EmbeddedOrientDBServiceTest::oHazelcastPlugin) .handler(EmbeddedOrientDBServiceTest::oServerSideScriptInterpreter) .networkConfig(oServerNetworkConfiguration()) .user(new OServerUserConfiguration(ROOT_USER, "root", "*")) .property(OGlobalConfiguration.DB_POOL_MIN, "1").property(OGlobalConfiguration.DB_POOL_MAX, "50") .databasePoolConfig(new OrientDBPoolConfig(CLASS_NAME, "remote:localhost/" + CLASS_NAME, "admin", "admin", 10, ImmutableSet.of(() -> new SetCreatedOnAndUpdatedOn()))) .lifecycleListener(() -> new RunRightFastOrientDBLifeCycleListener(appEventLogger)).build(); service = new EmbeddedOrientDBService(config); ServiceUtils.start(service); initDatabase(); }
From source file:ddf.test.itests.platform.TestConfigStatusCommand.java
@After public void cleanup() throws Exception { FileUtils.cleanDirectory(getPathToProcessedDirectory().toFile()); FileUtils.cleanDirectory(getPathToFailedDirectory().toFile()); }