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

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

Introduction

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

Prototype

public static void forceDelete(File file) throws IOException 

Source Link

Document

Deletes a file.

Usage

From source file:com.meltmedia.cadmium.blackbox.test.GitBareRepoInitializer.java

public void init(String repoPath, String sourceDir, String sourceConfigDir) throws Exception {
    File repoDir = new File(repoPath);
    if (repoDir.exists()) {
        FileUtils.forceDelete(repoDir);
    }// w w w  . j  ava2  s. c o m

    File checkoutDir = new File(repoDir.getAbsoluteFile().getParent(), repoDir.getName() + ".checkout");
    if (checkoutDir.exists()) {
        FileUtils.forceDelete(checkoutDir);
    }
    checkoutPath = checkoutDir.getAbsolutePath();

    InitCommand init = Git.init();
    init.setBare(true);
    init.setDirectory(repoDir);
    bareRepo = init.call();

    clonedGit = GitService.cloneRepo(repoPath, checkoutPath);
    clonedGit.checkinNewContent(sourceConfigDir, "Initial commit");
    clonedGit.push(false);
    clonedGit.newEmtpyRemoteBranch("cd-master");
    clonedGit.switchBranch("cd-master");
    clonedGit.checkinNewContent(sourceDir, "Initial commit");
    clonedGit.push(false);
    clonedGit.newEmtpyRemoteBranch("cfg-master");
    clonedGit.switchBranch("cfg-master");
    clonedGit.checkinNewContent(sourceConfigDir, "Initial commit");
    clonedGit.push(false);
}

From source file:com.docd.purefm.test.JavaFileTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    try {/*  ww  w .ja  v a 2  s. co m*/
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignored
    }

    final String state = Environment.getExternalStorageState();
    if (!state.equals(Environment.MEDIA_MOUNTED)) {
        throw new RuntimeException(
                "Make sure the external storage is mounted read-write before running this test");
    }
    try {
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignored
    }
    assertTrue(testDir.mkdirs());

    // prepare a test file
    try {
        FileUtils.write(test1, "test");
    } catch (IOException e) {
        throw new RuntimeException("Failed to create test file: " + e);
    }
}

From source file:net.formicary.remoterun.common.test.FileStreamerTest.java

@AfterClass
public void tearDown() throws IOException {
    FileUtils.forceDelete(tempDirectory.toFile());
}

From source file:com.docd.purefm.test.FileFactoryTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    try {//from w  w w  .  j av  a 2s .  c  o  m
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignored
    }

    final String state = Environment.getExternalStorageState();
    if (!state.equals(Environment.MEDIA_MOUNTED)) {
        throw new RuntimeException(
                "Make sure the external storage is mounted read-write before running this test");
    }
    try {
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignore
    }
    assertTrue(testDir.mkdirs());
}

From source file:com.datis.irc.kryo.KryoSerializerTest.java

@Override
protected void setUp() throws Exception {
    try {//from  w w w .java2 s .  co m
        System.out.println("DELETE and Create Folder");
        File f = new File(addressFolder);
        File fKryo = new File(addressFolder + "/kryo");
        File fpojo = new File(addressFolder + "/pojo");
        FileUtils.cleanDirectory(f); //clean out directory (this is optional -- but good know)
        FileUtils.forceDelete(f); //delete directory
        FileUtils.forceMkdir(f); //create directory
        FileUtils.forceMkdir(fKryo); //create directory
        FileUtils.forceMkdir(fpojo); //create directory
    } catch (IOException e) {
        System.out.println("ERROR in Create And Delete DirectoryS");
        e.printStackTrace();
    }
}

From source file:azkaban.app.AzkabanApplicationTest.java

private File mktempdir(String name) throws IOException {
    File dir = File.createTempFile(name, ".d");
    FileUtils.forceDelete(dir);
    FileUtils.forceMkdir(dir);//from www. j  a v a 2  s. co m
    return dir;
}

From source file:dremel.common.DremelParserTest.java

@Test
public void basic() throws RecognitionException, IOException {
    //tests parsing all SQL that are encountered in the documentation
    for (int i = 1; i <= 15; i++) {

        File tempFile = Drec.getFile("q" + i + "_temp.bql.ast");
        File expectedFile = Drec.getFile("q" + i + ".bql.ast");
        File queryFile = Drec.getFile("q" + i + ".bql");

        FileUtils.writeStringToFile(tempFile,
                DremelParser.parseBql(FileUtils.readFileToString(queryFile)).toStringTree());

        assertTrue("ast files differs", FileUtils.contentEquals(expectedFile, tempFile));

        FileUtils.forceDelete(tempFile);
    }//from ww w.  ja v  a2s. c om
}

From source file:net.hillsdon.reviki.configuration.TestDataDirImpl.java

@Override
protected void tearDown() throws Exception {
    FileUtils.forceDelete(new File(_baseDir));
}

From source file:net.nicholaswilliams.java.licensing.encryption.TestFilePublicKeyDataProvider.java

@Test
public void testKeyFile01() throws IOException {
    final String fileName = "testKeyFile01.key";
    File file = new File(fileName);

    if (file.exists())
        FileUtils.forceDelete(file);

    FilePublicKeyDataProvider provider = new FilePublicKeyDataProvider(fileName);

    assertNotNull("The key file should not be null.", provider.getPublicKeyFile());
    assertEquals("The key file is not correct.", file.getAbsoluteFile(), provider.getPublicKeyFile());
    assertFalse("The paths should not be the same.", fileName.equals(provider.getPublicKeyFile().getPath()));
    assertTrue("The paths should end the same.", provider.getPublicKeyFile().getPath().endsWith(fileName));
}

From source file:net.nicholaswilliams.java.licensing.encryption.TestFilePrivateKeyDataProvider.java

@Test
public void testKeyFile01() throws IOException {
    final String fileName = "testKeyFile01.key";
    File file = new File(fileName);

    if (file.exists())
        FileUtils.forceDelete(file);

    FilePrivateKeyDataProvider provider = new FilePrivateKeyDataProvider(fileName);

    assertNotNull("The key file should not be null.", provider.getPrivateKeyFile());
    assertEquals("The key file is not correct.", file.getAbsoluteFile(), provider.getPrivateKeyFile());
    assertFalse("The paths should not be the same.", fileName.equals(provider.getPrivateKeyFile().getPath()));
    assertTrue("The paths should end the same.", provider.getPrivateKeyFile().getPath().endsWith(fileName));
}