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.github.woonsan.jdbc.jcr.impl.AbstractRepositoryEnabledTestCase.java

private void deleteTransientRepositoryFolderAndConfig() throws IOException {
    File repoDir = new File(TestConstants.TEST_REPOSITORY_HOME);

    if (repoDir.exists()) {
        FileUtils.forceDelete(repoDir);
    }//from w ww .  j a v  a  2  s.c  o m

    File repoConf = new File(TestConstants.TEST_REPOSITORY_CONF);

    if (repoConf.exists()) {
        FileUtils.forceDelete(repoConf);
    }
}

From source file:jenkins.plugins.asqatasun.AsqatasunRunner.java

public void callService() throws IOException, InterruptedException {
    File logFile = AsqatasunRunnerBuilder.createTempFile(contextDir, "log-" + new Random().nextInt() + ".log",
            "");/* w  w  w . j ava2  s .c o m*/
    File scenarioFile = AsqatasunRunnerBuilder.createTempFile(contextDir, scenarioName + "_#" + buildNumber,
            AsqatasunRunnerBuilder.forceVersion1ToScenario(scenario));

    ProcessBuilder pb = new ProcessBuilder(tgScriptName, "-f", firefoxPath, "-r", referential, "-l", level,
            "-d", displayPort, "-x", xmxValue, "-o", logFile.getAbsolutePath(), "-t", "Scenario",
            scenarioFile.getAbsolutePath());

    pb.directory(contextDir);
    pb.redirectErrorStream(true);
    listener.getLogger().print("Launching asqatasun runner with the following options : ");
    listener.getLogger().print(pb.command());
    Process p = pb.start();
    p.waitFor();

    extractDataAndPrintOut(logFile, listener.getLogger());

    if (!isDebug) {
        FileUtils.forceDelete(logFile);
    }

    FileUtils.forceDelete(scenarioFile);
}

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

@Test
public void testPrivateKeyEncryption02() throws Throwable {
    File file = new File("testPrivateKeyEncryption02.key");

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

    PrivateKey privateKey = KeyPairGenerator.getInstance(KeyFileUtilities.keyAlgorithm).generateKeyPair()
            .getPrivate();/*from   w  ww . j  av  a 2s  .c  om*/

    PrivateKey otherKey = KeyPairGenerator.getInstance(KeyFileUtilities.keyAlgorithm).generateKeyPair()
            .getPrivate();

    assertFalse("The keys should not be equal (1).", otherKey.equals(privateKey));

    KeyFileUtilities.writeEncryptedPrivateKey(privateKey, file, "yourTestPassword02".toCharArray());

    PrivateKey privateKey2 = KeyFileUtilities.readEncryptedPrivateKey(file, "yourTestPassword02".toCharArray());

    assertNotNull("The key should not be null.", privateKey2);
    assertFalse("The objects should not be the same.", privateKey == privateKey2);
    assertEquals("The keys should be the same.", privateKey, privateKey2);

    assertFalse("The keys should not be equal (2).", otherKey.equals(privateKey2));

    FileUtils.forceDelete(file);
}

From source file:de.tudarmstadt.ukp.clarin.webanno.automation.MiraAutomationServiceImpl.java

@Override
public void removeTemplate(Project aProject, String aFileName, String username) throws IOException {
    FileUtils.forceDelete(
            new File(dir.getAbsolutePath() + PROJECT + aProject.getId() + MIRA + MIRA_TEMPLATE + aFileName));
    createLog(aProject, username).info(//from   ww  w . jav a 2 s  . c om
            " Removed Template file from [" + aProject.getName() + "] with ID [" + aProject.getId() + "]");
    createLog(aProject, username).removeAllAppenders();
}

From source file:com.martinwunderlich.nlp.arg.aifdb.test.ArgMapTest.java

@org.junit.Test
public void testMapCountsS() {
    List<AIFdbArgumentMap> schemesList = AIFdbArgumentMapFactory
            .buildArgumentMapListFromNodesetJsonFiles(schemesPath);
    assertEquals("The number of argument maps in the schemes list is incorrect", schemesList.size(), 31);

    try {/* w w  w . j av  a 2  s .  c  o  m*/
        String filePath = "src/test/resources/schemes/outfile.txt";
        File outFile = new File(filePath);
        if (outFile.exists())
            FileUtils.forceDelete(outFile);
        AIFdbArgumentMapUtil.printNodesToFile(schemesList, NODE_TYPES.I,
                "src/test/resources/schemes/outfile.txt");
    } catch (IOException e) {
        fail("Error while trying to write map list to file: " + e.getLocalizedMessage());
    }
}

From source file:com.ebiznext.flume.source.TestMultiLineExecSource.java

@Test
public void testProcess() throws InterruptedException, LifecycleException, EventDeliveryException, IOException {
    Channel channel = new MemoryChannel();
    Context context = new Context();

    URL resource = Thread.currentThread().getContextClassLoader().getResource("server.log");
    assertNotNull(resource);//w  w  w  .ja va  2  s.  com

    context.put("command", format("cat %s", resource.getFile()));
    //      context.put("regex", ".*(\\s*.*(Exception|Error): .+)|.*(\\s+at .+)|.*(\\s*Caused by:.+)|.*(\\s+... (\\d+) more)");
    context.put("keep-alive", "1");
    context.put("capacity", "100000");
    context.put("transactionCapacity", "100000");
    Configurables.configure(source, context);
    Configurables.configure(channel, context);

    ChannelSelector rcs = new ReplicatingChannelSelector();
    rcs.setChannels(Lists.newArrayList(channel));

    source.setChannelProcessor(new ChannelProcessor(rcs));

    source.start();
    Transaction transaction = channel.getTransaction();

    transaction.begin();
    Event event;

    File actualFile = new File("/tmp/flume-execsource." + Thread.currentThread().getId());
    FileOutputStream outputStream = new FileOutputStream(actualFile);

    while ((event = channel.take()) != null) {
        byte[] bytes = event.getBody();
        outputStream.write(bytes);
        outputStream.write('\n');
    }

    outputStream.close();
    transaction.commit();
    transaction.close();

    source.stop();

    File expectedFile = new File(resource.getFile());

    assertEquals(FileUtils.checksumCRC32(expectedFile), FileUtils.checksumCRC32(actualFile));

    FileUtils.forceDelete(actualFile);
}

From source file:com.smartbear.readyapi.plugin.git.ReadyApiGitIntegrationTest.java

@Test(expected = IllegalStateException.class)
public void throwsIllegalStateExceptionForInvalidRepo() throws IOException {
    File gitConfig = new File(localPath + "/.git");
    FileUtils.forceDelete(gitConfig);
    gitIntegration.getAvailableTags(dummyProject);
}

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

@Test
public void testSaveKeyPairToFiles01() throws IOException {
    KeyPair keyPair = this.generator.generateKeyPair();

    File file1 = new File("testSaveKeyPairToFiles01.private");
    File file2 = new File("testSaveKeyPairToFiles01.public");

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

    if (file2.exists())
        FileUtils.forceDelete(file2);/*w w  w. jav a  2  s  .  c om*/

    assertFalse("File 1 should not exist.", file1.exists());
    assertFalse("File 2 should not exist.", file2.exists());

    this.generator.saveKeyPairToFiles(keyPair, "testSaveKeyPairToFiles01.private",
            "testSaveKeyPairToFiles01.public", "testMyPassword01".toCharArray());

    assertTrue("File 1 should exist.", file1.exists());
    assertTrue("File 2 should exist.", file2.exists());

    PrivateKey privateKey = KeyFileUtilities.readEncryptedPrivateKey(file1, "testMyPassword01".toCharArray());
    PublicKey publicKey = KeyFileUtilities.readEncryptedPublicKey(file2, "testMyPassword01".toCharArray());

    assertNotNull("The private key should not be null.", privateKey);
    assertEquals("The private key is not correct.", keyPair.getPrivate(), privateKey);

    assertNotNull("The public key should not be null.", publicKey);
    assertEquals("The public key is not correct.", keyPair.getPublic(), publicKey);

    FileUtils.forceDelete(file1);
    FileUtils.forceDelete(file2);
}

From source file:hoot.services.controllers.ingest.BasemapResourceTest.java

@Test
@Category(UnitTest.class)
public void TestToggleBasemap() throws Exception {
    BasemapResource mapRes = new BasemapResource();
    File f = new File(mapRes._ingestStagingPath + "/BASEMAP/controltest.enabled");
    FileUtils.touch(f);//w ww  . j a  v  a 2 s  .c o m
    mapRes._toggleBaseMap("controltest", false);
    f = new File(mapRes._ingestStagingPath + "/BASEMAP/controltest.disabled");
    org.junit.Assert.assertTrue(f.exists());

    mapRes._toggleBaseMap("controltest", true);

    f = new File(mapRes._ingestStagingPath + "/BASEMAP/controltest.enabled");
    org.junit.Assert.assertTrue(f.exists());

    FileUtils.forceDelete(f);
}

From source file:edu.ur.file.db.service.DefaultFileServerServiceTest.java

/**
 * Setup for testing//from  ww w  .  j a v  a2s. com
 * 
 * this deletes exiting test directories if they exist
 */
@BeforeMethod
public void cleanDirectory() {
    System.out.println("TRYING to CLEAN");
    try {
        System.out.println("property = " + properties.getProperty("fileServerService.server_path"));
        File f = new File(properties.getProperty("fileServerService.server_path"));
        if (f.exists()) {
            FileUtils.forceDelete(f);
        }
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}