Example usage for org.apache.commons.io FileUtils deleteDirectory

List of usage examples for org.apache.commons.io FileUtils deleteDirectory

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils deleteDirectory.

Prototype

public static void deleteDirectory(File directory) throws IOException 

Source Link

Document

Deletes a directory recursively.

Usage

From source file:com.palantir.atlasdb.cli.runner.RocksDbTestRunner.java

@Override
protected void cleanup(KeyValueServiceConfig kvsConfig) {
    Preconditions.checkArgument(kvsConfig instanceof RocksDbKeyValueServiceConfig,
            "RocksDbAtlasDbFactory expects a configuration of type RocksDbKeyValueServiceConfig, found %s",
            kvsConfig.getClass());// w w  w. j a va2s . c om
    RocksDbKeyValueServiceConfig rocksDbConfig = (RocksDbKeyValueServiceConfig) kvsConfig;
    try {
        FileUtils.deleteDirectory(rocksDbConfig.dataDir());
    } catch (IOException e) {
        Throwables.rewrapAndThrowUncheckedException("Could not cleanup after cli test", e);
    }
}

From source file:ml.shifu.shifu.pig.PigExecutorTest.java

public void test() throws IOException {
    PigExecutor exec = PigExecutor.getExecutor();
    ModelConfig modelConfig = CommonUtils.loadModelConfig(
            "src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/ModelConfig.json",
            SourceType.LOCAL);//w w  w  .  ja v a  2s. c o m

    Environment.setProperty(Environment.SHIFU_HOME, ".");
    modelConfig.getDataSet().setSource(SourceType.LOCAL);
    exec.submitJob(modelConfig, "src/test/java/ml/shifu/shifu/pig/pigTest.pig");

    FileUtils.deleteQuietly(new File("ModelConfig.json"));
    FileUtils.deleteDirectory(new File("ModelSets"));
}

From source file:com.metamx.druid.loading.ConvertingBaseQueryableFactory.java

@Override
public StorageAdapter factorize(File parentDir) throws StorageAdapterLoadingException {
    File indexFile = new File(parentDir, "index.drd");
    if (!indexFile.exists()) {
        throw new StorageAdapterLoadingException("indexFile[%s] does not exist.", indexFile);
    }//from w  w  w.  ja v a 2s. c  o  m

    try {
        if (!IndexIO.canBeMapped(parentDir)) {
            File canBeMappedDir = new File(parentDir, "forTheMapping");
            if (canBeMappedDir.exists()) {
                FileUtils.deleteDirectory(canBeMappedDir);
            }
            canBeMappedDir.mkdirs();

            IndexIO.storeLatest(IndexIO.readIndex(parentDir), canBeMappedDir);
            if (!IndexIO.canBeMapped(canBeMappedDir)) {
                throw new StorageAdapterLoadingException("WTF!? newly written file[%s] cannot be mapped!?",
                        canBeMappedDir);
            }
            for (File file : canBeMappedDir.listFiles()) {
                if (!file.renameTo(new File(parentDir, file.getName()))) {
                    throw new StorageAdapterLoadingException("Couldn't rename[%s] to [%s]", canBeMappedDir,
                            indexFile);
                }
            }
            FileUtils.deleteDirectory(canBeMappedDir);
        }

        return factorizeConverted(parentDir);
    } catch (IOException e) {
        log.warn(e, "Got exception, deleting index[%s]", indexFile);
        try {
            FileUtils.deleteDirectory(parentDir);
        } catch (IOException e2) {
            log.error(e, "Problem deleting parentDir[%s]", parentDir);
        }
        throw new StorageAdapterLoadingException(e, e.getMessage());
    }
}

From source file:com.streamsets.datacollector.execution.runner.common.TestRulesConfigLoader.java

@BeforeClass
public static void beforeClass() throws IOException {
    System.setProperty(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.DATA_DIR, "target/var");
    File f = new File(System.getProperty(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.DATA_DIR));
    FileUtils.deleteDirectory(f);
    TestUtil.captureStagesForProductionRun();
    ObjectGraph g = ObjectGraph.create(TestUtil.TestPipelineStoreModuleNew.class);
    pipelineStoreTask = g.get(PipelineStoreTask.class);
    configuration = g.get(Configuration.class);
}

From source file:grakn.core.distribution.GraknGraqlCommands_WithARunningGraknE2E.java

@AfterClass
public static void cleanup_cleanupDistribution() throws IOException, InterruptedException, TimeoutException {
    commandExecutor.command("./grakn", "server", "stop").execute();
    assertGraknIsNotRunning();/*from  ww w .j a  va 2  s  .c o  m*/
    FileUtils.deleteDirectory(GRAKN_UNZIPPED_DIRECTORY.toFile());
}

From source file:com.googlecode.t7mp.CommonsSetupUtilTest.java

@After
public void tearDown() throws IOException {
    FileUtils.deleteDirectory(catalinaBaseDir);
    if (catalinaBaseDir.exists()) {
        System.err.println("Could not delete directory " + catalinaBaseDir.getAbsolutePath());
    }/*from ww  w  .  j  av  a2  s .  c  o  m*/
    FileUtils.deleteQuietly(source);
    FileUtils.deleteQuietly(target);
}

From source file:net.sf.infrared.tool.mojo.TestWarIntegration.java

@After
public void cleanUp() {
    try {/*from w ww .  ja v a2s .co m*/
        FileUtils.deleteDirectory(new File(getBaseDir(), "target"));
    } catch (Exception ex) {
        ;// Only a problem on windows. we really do not care.. if we cant
         // delete the file
         // It is probably not there
    }
}

From source file:com.srotya.tau.api.dao.TestRuleGroupManager.java

@BeforeClass
public static void beforeClass() throws Exception {
    Properties config = new Properties(System.getProperties());
    File db = new File(TARGET_RULES_DB);
    if (db.exists()) {
        FileUtils.deleteDirectory(db);
    }/*from   w  w  w .  java  2  s  . c  om*/
    config.setProperty("javax.persistence.jdbc.url", CONNECTION_STRING);
    try {
        emf = Persistence.createEntityManagerFactory("tau", config);
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}

From source file:com.thoughtworks.go.util.validators.JettyWorkDirValidator.java

public Validation validate(Validation val) {
    if (StringUtils.isBlank(systemEnvironment.getPropertyImpl("jetty.home"))) {
        systemEnvironment.setProperty("jetty.home", systemEnvironment.getPropertyImpl("user.dir"));
    }//from   w w  w . j  a v  a 2s .  c o  m
    systemEnvironment.setProperty("jetty.base", systemEnvironment.getPropertyImpl("jetty.home"));

    File home = new File(systemEnvironment.getPropertyImpl("jetty.home"));
    File work = new File(systemEnvironment.getPropertyImpl("jetty.home"), "work");
    if (home.exists()) {
        if (work.exists()) {
            try {
                FileUtils.deleteDirectory(work);
            } catch (IOException e) {
                String message = format("Error trying to remove Jetty working directory {0}: {1}",
                        work.getAbsolutePath(), e);
                return val.addError(new RuntimeException(message));
            }
        }
        work.mkdir();
    }
    return Validation.SUCCESS;
}

From source file:com.datatorrent.demos.dimensions.ads.HDHTApplicationTest.java

@Before
public void beforeTest() throws Exception {
    kafkaLauncher.baseDir = "target/" + this.getClass().getName();
    FileUtils.deleteDirectory(new File(kafkaLauncher.baseDir));
    kafkaLauncher.startZookeeper();/*from w w w . j av  a2s. c  om*/
    kafkaLauncher.startKafkaServer();
    kafkaLauncher.createTopic(kafkaQueryTopic);
    kafkaLauncher.createTopic(kafkaQueryResultTopic);
}