List of usage examples for org.apache.commons.io FileUtils deleteDirectory
public static void deleteDirectory(File directory) throws IOException
From source file:de.uzk.hki.da.format.PublishVideoConversionStrategyTests.java
/** * Tear down.//from w w w. j a va 2 s .c om * * @throws IOException Signals that an I/O exception has occurred. */ @After public void tearDown() throws IOException { if (new File(basePath + "dip").exists()) FileUtils.deleteDirectory(new File(basePath + "dip")); FileUtils.deleteDirectory(new File(basePath + "/TEST")); }
From source file:edu.stanford.slac.archiverappliance.PlainPB.PlainPBFileNameUtilityTest.java
@Before public void setUp() throws Exception { configService = new ConfigServiceForTests(new File("./bin")); File rootFolder = new File(rootFolderStr); if (rootFolder.exists()) { FileUtils.deleteDirectory(rootFolder); }/*w ww. j a va 2s .co m*/ rootFolder.mkdirs(); }
From source file:azkaban.reportal.util.StreamProviderLocal.java
public void deleteFile(String pathString) throws Exception { FileUtils.deleteDirectory(new File(pathString)); }
From source file:com.pivotal.hawq.mapreduce.TPCHClusterTester.java
@Override protected void testTPCHTable(HAWQTPCHSpec tpchSpec, String tableName) throws Exception { String caseName = tpchSpec.toString(); System.out.println("Executing test case: " + caseName); final File caseFolder = new File(FT_TEST_FOLDER, caseName); final File answerFile = new File(caseFolder, tableName + ".ans"); final File outputFile = new File(caseFolder, tableName + ".out"); if (caseFolder.exists()) { FileUtils.deleteDirectory(caseFolder); }/* www . ja va 2s .c o m*/ caseFolder.mkdir(); Connection conn = null; List<String> answers; try { conn = MRFormatTestUtils.getTestDBConnection(); // 1. load TPCH data Map<String, String> rs = HAWQJdbcUtils.executeSafeQueryForSingleRow(conn, "SHOW default_segment_num;"); int segnum = Integer.parseInt(rs.get("default_segment_num")); MRFormatTestUtils.runShellCommand(tpchSpec.getLoadCmd(segnum)); // 2. generate answer answers = MRFormatTestUtils.dumpTable(conn, tableName); Collections.sort(answers); Files.write(Joiner.on('\n').join(answers).getBytes(), answerFile); } finally { HAWQJdbcUtils.closeConnection(conn); } // 3. run input format driver final Path hdfsOutput = new Path("/temp/hawqinputformat/part-r-00000"); int exitCode = MRFormatTestUtils.runMapReduceOnCluster(tableName, hdfsOutput.getParent(), null); Assert.assertEquals(0, exitCode); // 4. copy hdfs output to local MRFormatTestUtils.runShellCommand( String.format("hadoop fs -copyToLocal %s %s", hdfsOutput.toString(), outputFile.getPath())); // 5. compare result List<String> outputs = Files.readLines(outputFile, Charsets.UTF_8); if (!answers.equals(outputs)) Assert.fail(String.format("HAWQInputFormat output for table %s differs with DB output:\n%s\n%s", tableName, answerFile, outputFile)); System.out.println("Successfully finish test case: " + caseName); }
From source file:com.splout.db.common.TestCompressorUtil.java
@Test public void test() throws IOException { File foo = new File("foo"); foo.mkdir();//ww w .java2s .com new File(foo, "foo1").mkdir(); new File(foo, "foo2.tmp").createNewFile(); new File("foo/foo1/foo3.tmp").createNewFile(); File compressed = new File("foo.zip"); CompressorUtil.createZip(foo, compressed, FileFilterUtils.trueFileFilter(), FileFilterUtils.trueFileFilter()); assertTrue(compressed.exists() && compressed.length() > 0); File uncompFoo = new File("uncomp-foo"); CompressorUtil.uncompress(compressed, uncompFoo); assertTrue(compressed.exists()); assertTrue(uncompFoo.exists()); assertTrue(uncompFoo.isDirectory()); assertTrue(new File(uncompFoo, "foo1").exists()); assertTrue(new File(uncompFoo, "foo1").isDirectory()); assertTrue(new File(uncompFoo, "foo2.tmp").exists()); assertTrue(new File(uncompFoo, "foo1/foo3.tmp").exists()); FileUtils.deleteQuietly(compressed); FileUtils.deleteDirectory(foo); FileUtils.deleteDirectory(uncompFoo); }
From source file:com.tasktop.c2c.server.hudson.configuration.service.HudsonWarDeprovisioner.java
/** * @param file/*w ww .j av a2 s . com*/ */ private void tryDelete(File file) { if (!file.exists()) { LOG.info(String.format("Could not delete [%s], does not exist", file.getPath())); return; } if (file.isDirectory()) { try { FileUtils.deleteDirectory(file); } catch (IOException e) { LOG.info(String.format("Could not delete [%s]", file.getPath()), e); } } else { boolean succeeded = file.delete(); if (!succeeded) { LOG.info(String.format("Could not delete [%s]", file.getPath())); } } }
From source file:hu.bme.mit.trainbenchmark.benchmark.orientdb.driver.OrientDbDriver.java
public OrientDbDriver(final String dbPath, final String benchmarkDir) throws IOException { // delete old directory if (new File(dbPath).exists()) { FileUtils.deleteDirectory(new File(dbPath)); }// ww w . ja va2 s .c om // start the database this.dbPath = dbPath; this.benchmarkDir = benchmarkDir; }
From source file:com.streamsets.datacollector.execution.snapshot.TestFileSnapshotStore.java
@Before public void setUp() throws IOException { File f = new File(System.getProperty(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.DATA_DIR)); FileUtils.deleteDirectory(f); ObjectGraph objectGraph = ObjectGraph.create(FileSnapshotStoreModule.class); snapshotStore = objectGraph.get(FileSnapshotStore.class); }
From source file:de.uzk.hki.da.cb.DeleteObjectActionTests.java
@After public void tearDown() throws IOException { FileUtils.deleteDirectory(new File(workAreaRootPath + "work/TEST/123/data")); new File(workAreaRootPath + "work/TEST/abc.txt").delete(); new File(ingestAreaRootPath + "TEST/abc.txt").delete(); }
From source file:com.googlecode.fascinator.sequences.SequenceServiceTest.java
@After public void shutdown() throws IOException, SQLException { sequenceService.shutdown();//from www.j ava 2 s .co m File derbyDir = new File("derby"); FileUtils.deleteDirectory(derbyDir); }