List of usage examples for org.apache.commons.io FileUtils forceDeleteOnExit
public static void forceDeleteOnExit(File file) throws IOException
From source file:com.redhat.victims.mock.MockEnvironment.java
public static void deleteCache() { if (TEMP_CACHE.exists()) { try {//from ww w .j av a 2s. c o m FileUtils.forceDeleteOnExit(TEMP_CACHE); } catch (IOException e) { e.printStackTrace(); } } }
From source file:fr.inria.atlanmod.neoemf.extension.Workspace.java
@Override public void after() { if (nonNull(temporaryFolder) && temporaryFolder.exists() && !FileUtils.deleteQuietly(temporaryFolder)) { try {/*w w w . j a va 2s .c om*/ FileUtils.forceDeleteOnExit(temporaryFolder); } catch (IOException ignore) { } } }
From source file:com.opengamma.transport.TaxonomyGatheringFudgeMessageSenderTest.java
public void noTaxonomyFileAvailableYet() throws IOException { File tmpFile = File.createTempFile("TaxonomyGatheringFudgeMessageSenderTest_noTaxonomyFileAvailableYet", ".properties"); FileUtils.forceDelete(tmpFile);//from ww w .j a va 2 s . c o m FileUtils.forceDeleteOnExit(tmpFile); FudgeContext context = new FudgeContext(); CollectingFudgeMessageReceiver collectingReceiver = new CollectingFudgeMessageReceiver(); ByteArrayFudgeMessageReceiver fudgeReceiver = new ByteArrayFudgeMessageReceiver(collectingReceiver); DirectInvocationByteArrayMessageSender byteArraySender = new DirectInvocationByteArrayMessageSender( fudgeReceiver); ByteArrayFudgeMessageSender fudgeSender = new ByteArrayFudgeMessageSender(byteArraySender, context); TaxonomyGatheringFudgeMessageSender gatheringSender = new TaxonomyGatheringFudgeMessageSender(fudgeSender, tmpFile.getAbsolutePath()); assertTrue(gatheringSender.getCurrentTaxonomy().isEmpty()); }
From source file:com.splunk.shuttl.testutil.TUtilsFile.java
/** * @return a temporary, existing, empty file that will be deleted when the VM * terminates.//from w w w. j av a 2 s .c om * * @see TUtilsFile#createFilePath() */ public static File createFile() { File uniquelyNamedFile = getUniquelyNamedFileWithPrefix("test-file"); try { if (!uniquelyNamedFile.createNewFile()) throw new IOException("Could not create file: " + uniquelyNamedFile); FileUtils.forceDeleteOnExit(uniquelyNamedFile); } catch (IOException e) { TUtilsTestNG.failForException("Couldn't create a test file.", e); } return uniquelyNamedFile; }
From source file:edu.cornell.med.icb.goby.counts.TestCountsReader.java
@AfterClass public static void cleanupTestDirectory() throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Deleting base test directory: " + BASE_TEST_DIR); FileUtils.forceDeleteOnExit(new File(BASE_TEST_DIR)); }/* ww w. j a v a 2 s. c o m*/ }
From source file:com.stratio.connector.cassandra.CCMHandler.java
/** * Start a test Cassandra cluster to execute the unit tests. The method creates a * temporal file with the contents of {@code /com/stratio/meta/test/test.sh} and proceeds * with its execution.//from www.j av a 2 s.c o m */ public static void startCCM() { BufferedReader in = null; try { File tempFile = File.createTempFile("stratio-start-ccm", ".sh"); InputStream resourceStream = CCMHandler.class .getResourceAsStream("/com/stratio/connector/cassandra/test.sh"); FileUtils.copyInputStreamToFile(resourceStream, tempFile); tempFile.setExecutable(true); Process p = Runtime.getRuntime().exec(tempFile.getAbsolutePath()); in = new BufferedReader(new InputStreamReader(p.getInputStream(), Charset.forName("UTF-8"))); String line; while ((line = in.readLine()) != null) { LOG.debug(line); } FileUtils.forceDeleteOnExit(tempFile); } catch (IOException e) { LOG.error("Error starting CCM", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { LOG.error("IO exception closing ccm output.", e); } } } }
From source file:com.joyent.manta.config.ConfigContextTest.java
public void canValidateContextWithClientEncryptionDisabled() throws IOException { File mantaAuthPrivateKey = File.createTempFile("manta-key", ""); FileUtils.forceDeleteOnExit(mantaAuthPrivateKey); FileUtils.write(mantaAuthPrivateKey, UnitTestConstants.PRIVATE_KEY, StandardCharsets.US_ASCII); StandardConfigContext config = new StandardConfigContext(); config.setMantaURL(DefaultsConfigContext.DEFAULT_MANTA_URL); config.setMantaUser("username"); config.setMantaKeyId(UnitTestConstants.FINGERPRINT); config.setMantaKeyPath(mantaAuthPrivateKey.getAbsolutePath()); config.setClientEncryptionEnabled(false); ConfigContext.validate(config);/*w ww .ja va2s .co m*/ }
From source file:com.netflix.nicobar.core.persistence.JarArchiveRepositoryTest.java
@Override @BeforeClass/*from w ww . j a v a 2 s .c o m*/ public void setup() throws Exception { rootArchiveDirectory = Files.createTempDirectory(JarArchiveRepositoryTest.class.getSimpleName() + "_"); FileUtils.forceDeleteOnExit(rootArchiveDirectory.toFile()); super.setup(); }
From source file:com.netflix.nicobar.core.persistence.PathArchiveRepositoryTest.java
@Override @BeforeClass//w w w . ja va 2 s . c om public void setup() throws Exception { rootArchiveDirectory = Files.createTempDirectory(PathRepositoryPollerTest.class.getSimpleName() + "_"); FileUtils.forceDeleteOnExit(rootArchiveDirectory.toFile()); super.setup(); }
From source file:com.willwinder.universalgcodesender.BufferedCommunicatorTest.java
@AfterClass static public void teardown() throws IOException { FileUtils.forceDeleteOnExit(tempDir); }