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

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

Introduction

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

Prototype

public static boolean deleteQuietly(File file) 

Source Link

Document

Deletes a file, never throwing an exception.

Usage

From source file:de.uzk.hki.da.at.ATUseCaseRetrieval.java

@After
public void tearDown() {
    distributedConversionAdapter.remove("aip/TEST/ID-ATUseCaseRetrieval"); // TODO does it work?
    new File("/tmp/ID-ATUseCaseRetrieval.tar").delete();
    FileUtils.deleteQuietly(new File("/tmp/ID-ATUseCaseRetrieval"));
}

From source file:com.strandls.alchemy.rest.client.stubgenerator.GuiceModuleGeneratorTest.java

/**
 * Test method for/*  ww w .  j  a  v  a  2  s .  c  o  m*/
 * {@link com.strandls.alchemy.rest.client.stubgenerator.GuiceModuleGenerator#generateGuiceModule(java.lang.String, java.io.File, java.util.Map)}
 * .
 *
 * @throws Exception
 */
@Test
public void testGenerateModuleWithPackage() throws Exception {
    final GuiceModuleGenerator generator = new GuiceModuleGenerator();
    final File tempDir = File.createTempFile("test", "test");
    FileUtils.deleteQuietly(tempDir);

    if (!tempDir.mkdirs()) {
        throw new IOException("Cannot create temporary directory.");
    }
    try {
        final Map<String, String> map = new LinkedHashMap<String, String>();
        map.put("testStub1", "testStub1Proxy");
        map.put("testStub2", "testStub2Proxy");
        generator.generateGuiceModule("com.strandls.alchemy", tempDir, map);

        String actualGuiceStub = FileUtils
                .readFileToString(new File(tempDir, GuiceModuleGenerator.CLIENT_GUICE_MODULE_NAME + ".java"))
                .trim();
        assertEquals(
                FileUtils
                        .readFileToString(
                                new File("src/test/resources/com/strandls/alchemy/rest/client/stubgenerator/"
                                        + GuiceModuleGenerator.CLIENT_GUICE_MODULE_NAME + "WithPackage.txt"))
                        .trim(),
                actualGuiceStub);
    } finally {
        FileUtils.deleteQuietly(tempDir);
    }
}

From source file:hoot.services.controllers.info.ErrorLogTest.java

@AfterClass
public static void afterClass() throws Exception {
    FileUtils.deleteQuietly(testFolder);
    HootCustomPropertiesSetter.setProperty("ERROR_LOG_PATH", original_ERROR_LOG_PATH);
    HootCustomPropertiesSetter.setProperty("TEMP_OUTPUT_PATH", original_TEMP_OUTPUT_PATH);
}

From source file:com.cloudant.sync.util.TestUtils.java

public static void deleteTempTestingDir(String path) {
    FileUtils.deleteQuietly(new File(path));
}

From source file:de.uzk.hki.da.at.ATUseCaseIngestMigrationAllowed.java

@After
public void tearDown() {

    FileUtils.deleteQuietly(UNPACKED_DIP);
}

From source file:com.adaptris.core.lms.FilePurge.java

public void purge() {
    try {// w  ww. j a  v a  2s .  c  o  m
        File dir = new File(System.getProperty("java.io.tmpdir"));
        File[] files = dir.listFiles(fileFilter);
        for (File file : files) {
            FileUtils.deleteQuietly(file);
        }
    } catch (Exception ignoredIntentionally) {
        ;
    }
}

From source file:com.splunk.shuttl.archiver.LocalFileSystemPathsWithRealConfTest.java

@BeforeMethod
@Parameters(value = { "shuttl.conf.dir" })
public void setUp(String shuttlConfsDirPath) {
    File confsDir = new File(shuttlConfsDirPath);
    TUtilsMBean.runWithRegisteredMBeans(confsDir, new Runnable() {
        @Override/*from w ww . j a  v a 2s  .co  m*/
        public void run() {
            archiverDirWithMBeanConf = LocalFileSystemPaths.create().getArchiverDirectory();
            FileUtils.deleteQuietly(archiverDirWithMBeanConf);
        }
    });
}

From source file:com.meltmedia.cadmium.core.git.DelayedGitServiceInitializerTest.java

/**
 * Initializes the {@link GitService} reference to set into the {@link DelayedDelayedGitServiceInitializer}.
 * /*from   w w w.  j a  va2  s  . co  m*/
 * @throws Exception
 */
@Before
public void initGitService() throws Exception {
    File testDir = new File("target/delayed-git-init-test");
    FileUtils.deleteQuietly(testDir);
    FileUtils.forceMkdir(testDir);
    gitInit = new DelayedGitServiceInitializer();
    GitService tmpGit = GitService.cloneRepo("git://github.com/meltmedia/cadmium.git",
            new File(testDir, "git-checkout").getAbsolutePath());
    tmpGit.switchBranch("cd-manual");
    tmpGit.resetToRev("3ddc7c498c940f49a1cc53aa3d98104a4d24eaa4");
    assertNotNull("GitService should not be null.", tmpGit);
    gitInit.setGitService(tmpGit);
}

From source file:com.splunk.shuttl.FileSystemCleaner.java

public void cleanShuttlTestDirectory() {
    File shuttlTestDirectory = TUtilsFile.getShuttlTestDirectory();
    File[] files = shuttlTestDirectory.listFiles();
    if (files != null)
        for (File file : files)
            FileUtils.deleteQuietly(file);
}

From source file:com.datatorrent.demos.dimensions.generic.EnrichmentOperatorTest.java

@Test
public void testEnrichmentOperator() throws IOException, InterruptedException {
    URL origUrl = getClass().getResource("/productmapping.txt");

    URL fileUrl = new URL(getClass().getResource("/").toString() + "productmapping1.txt");
    FileUtils.deleteQuietly(new File(fileUrl.getPath()));
    FileUtils.copyFile(new File(origUrl.getPath()), new File(fileUrl.getPath()));

    EnrichmentOperator oper = new EnrichmentOperator();
    oper.setFilePath(fileUrl.toString());
    oper.setLookupKey("productId");
    oper.setScanInterval(10);//  w w  w. j  a v  a2 s .  c o m

    oper.setup(null);
    /* File contains 6 entries, but operator one entry is duplicate,
     * so cache should contains only 5 entries after scanning input file.
     */
    Assert.assertEquals("Number of mappings ", 7, oper.cache.size());

    CollectorTestSink<Map<String, Object>> sink = new CollectorTestSink<Map<String, Object>>();
    @SuppressWarnings({ "unchecked", "rawtypes" })
    CollectorTestSink<Object> tmp = (CollectorTestSink) sink;
    oper.outputPort.setSink(tmp);

    oper.beginWindow(0);
    Map<String, Object> tuple = Maps.newHashMap();
    tuple.put("productId", 3);
    tuple.put("channelId", 4);
    tuple.put("amount", 10.0);

    Kryo kryo = new Kryo();
    oper.inputPort.process(kryo.copy(tuple));

    oper.endWindow();

    /* Number of tuple, emitted */
    Assert.assertEquals("Number of tuple emitted ", 1, sink.collectedTuples.size());
    Map<String, Object> emitted = sink.collectedTuples.iterator().next();

    /* The fields present in original event is kept as it is */
    Assert.assertEquals("Number of fields in emitted tuple", 4, emitted.size());
    Assert.assertEquals("value of productId is 3", tuple.get("productId"), emitted.get("productId"));
    Assert.assertEquals("value of channelId is 4", tuple.get("channelId"), emitted.get("channelId"));
    Assert.assertEquals("value of amount is 10.0", tuple.get("amount"), emitted.get("amount"));

    /* Check if productCategory is added to the event */
    Assert.assertEquals("productCategory is part of tuple", true, emitted.containsKey("productCategory"));
    Assert.assertEquals("value of product category is 1", 6, emitted.get("productCategory"));

    /* Check if modified file is reloaded in beginWindow */
    FileUtils.write(new File(fileUrl.getPath()), "{ \"productId\": 10, \"productCategory\": 5 }");
    Thread.sleep(100);
    oper.beginWindow(2);
    oper.endWindow();
    Assert.assertEquals("Number of mappings ", 1, oper.cache.size());
}