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.github.davidcarboni.encryptedfileupload.EncryptedFileItemSerializeTest.java

@Before
public void setUp() throws Exception {
    if (REPO.exists()) {
        FileUtils.deleteDirectory(REPO);
    }/*from ww w .ja  v a  2s .  c  om*/
    assertFalse("Must not exist", REPO.exists());
    REPO.mkdir();
}

From source file:de.nrw.hbz.regal.sync.TestDippDownloader.java

@Before
public void setUp() {
    try {/*from w w w  .  jav  a2s .co m*/

        FileUtils.deleteDirectory(new File(piddownloaderDownloadLocation));

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:fr.duminy.jbackup.core.filter.JexlFileFilterTest.java

/**
 * Method copied from {@link org.apache.commons.io.filefilter.RegexFileFilterTestCase#tearDown()}.
 * TODO check potential license issue.// ww w .j  a v a 2 s  .  c  o  m
 *
 * @throws Exception
 */
@Override
public void tearDown() throws Exception {
    FileUtils.deleteDirectory(getTestDirectory());
}

From source file:com.cip.crane.agent.utils.FileExtractUtilsTest.java

public void TestunTarunGzip() {
    String path = getAbsolutePath("extract/test.tar.gz");
    File file = new File(path);
    try {/*from  w w w .  jav a 2s  .co m*/
        FileExtractUtils.unTar(FileExtractUtils.unGzip(file));
        File testFile1 = new File(file.getParent() + "/test/test1.txt");
        assertTrue(testFile1.exists());
        FileUtils.deleteDirectory(new File(file.getParent() + "/test"));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ArchiveException e) {
        e.printStackTrace();
    }
}

From source file:controller.DeletePersonalGoalControllerTest.java

@After
public void tearDown() {
    try {/*from w ww .  j  a va2 s  . com*/
        FileUtils.deleteDirectory(homeFile);
    } catch (IOException ex) {
        Logger.getLogger(DeletePersonalGoalControllerTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ch.ivyteam.ivy.maven.ProjectMojoRule.java

@Override
protected void after() {
    try {/*  ww  w  .java 2 s . c om*/
        FileUtils.deleteDirectory(projectDir);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:com.garethahealy.camel.file.loadbalancer.example1.routes.Read99FilesWithThreeReadersTest.java

@Override
protected void doPreSetup() throws Exception {
    File directory = FileUtils.toFile(new URL("file:" + rootDirectory));
    FileUtils.deleteDirectory(directory);

    directory.mkdir();//from  w ww.ja va2  s  .c o  m

    for (int i = 0; i < 99; i++) {
        FileUtils.writeStringToFile(
                FileUtils.toFile(new URL("file:" + rootDirectory + "/file" + Integer.toString(i) + ".log")),
                "file" + Integer.toString(i));
    }

    LOG.info("Wrote files to: " + directory.getAbsolutePath());
}

From source file:azkaban.test.jobtype.JobTypeManagerTest.java

@After
public void tearDown() throws IOException {
    FileUtils.deleteDirectory(new File(TEST_PLUGIN_DIR));
}

From source file:com.blackberry.bdp.test.utils.LocalZkServer.java

public LocalZkServer()
        throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException,
        IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException {
    String dataDirectory = System.getProperty("java.io.tmpdir");

    dir = new File(dataDirectory, "zookeeper").getAbsoluteFile();

    while (dir.exists()) {
        LOG.info("deleting {}", dir);
        FileUtils.deleteDirectory(dir);
    }/*from   w w  w  .  j av a  2 s. com*/

    server = new ZooKeeperServer(dir, dir, tickTime);

    // The class that we need changed name between CDH3 and CDH4, so let's check
    // for the right version here.
    try {
        factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxnFactory");

        standaloneServerFactory = factoryClass.newInstance();
        Method configure = factoryClass.getMethod("configure", InetSocketAddress.class, Integer.TYPE);
        configure.invoke(standaloneServerFactory, new InetSocketAddress(clientPort), numConnections);
        Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class);
        startup.invoke(standaloneServerFactory, server);

    } catch (ClassNotFoundException e) {
        LOG.info("Did not find NIOServerCnxnFactory");
        try {
            factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxn$Factory");

            Constructor<?> constructor = factoryClass.getConstructor(InetSocketAddress.class, Integer.TYPE);
            standaloneServerFactory = constructor.newInstance(new InetSocketAddress(clientPort),
                    numConnections);
            Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class);
            startup.invoke(standaloneServerFactory, server);

        } catch (ClassNotFoundException e1) {
            LOG.info("Did not find NIOServerCnxn.Factory");
            throw new ClassNotFoundException("Can't find NIOServerCnxnFactory or NIOServerCnxn.Factory");
        }
    }
}

From source file:com.garethahealy.camel.file.loadbalancer.example1.routes.ReadThreeFilesWithThreeReadersTest.java

@Override
protected void doPreSetup() throws Exception {
    File directory = FileUtils.toFile(new URL("file:" + rootDirectory));
    FileUtils.deleteDirectory(directory);

    directory.mkdir();/* w w w .j  ava 2 s  . c o m*/

    URL file1 = ReadThreeFilesWithThreeReadersTest.class.getClassLoader()
            .getResource("example-files/afile1.log");
    URL file2 = ReadThreeFilesWithThreeReadersTest.class.getClassLoader()
            .getResource("example-files/bfile2.log");
    URL file3 = ReadThreeFilesWithThreeReadersTest.class.getClassLoader()
            .getResource("example-files/cfile3.log");

    Assert.assertNotNull(file1);
    Assert.assertNotNull(file2);
    Assert.assertNotNull(file3);

    FileUtils.copyFileToDirectory(FileUtils.toFile(file1), directory);
    FileUtils.copyFileToDirectory(FileUtils.toFile(file2), directory);
    FileUtils.copyFileToDirectory(FileUtils.toFile(file3), directory);

    LOG.info("Moved files to: " + directory.getAbsolutePath());
}