List of usage examples for org.apache.commons.io FileUtils deleteDirectory
public static void deleteDirectory(File directory) throws IOException
From source file:com.jdom.util.TestUtil.java
public static File getTestClassDir(Class<?> testClass) { File testDir = new File(JAVA_IO_TMPDIR, testClass.getSimpleName()); if (testDir.exists()) { try {/*www . jav a2 s . c om*/ FileUtils.deleteDirectory(testDir); } catch (IOException e) { throw new IllegalStateException(e); } } return testDir; }
From source file:dao.PersonalGoalTxtDaoTest.java
@AfterClass public static void tearDownClass() { File file = new File(System.getProperty("user.dir") + fSeparator + "MyDiaryBook"); try {/*from w ww . ja v a 2 s . com*/ FileUtils.deleteDirectory(file); } catch (IOException ex) { Logger.getLogger(PersonalGoalTxtDaoTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:net.sf.jdbcwrappers.spring.SpringTest.java
@BeforeClass public static void createDataSource() throws Exception { FileUtils.deleteDirectory(new File("target/testDB")); dataSource = new EmbeddedDataSource(); dataSource.setDatabaseName("target/testDB"); dataSource.setUser("test"); dataSource.setCreateDatabase("create"); // Need to request at least one connection for the database to be created dataSource.getConnection().close();/*w w w . ja v a 2 s. c o m*/ }
From source file:de.oppermann.pomutils.TestUtils.java
public static void prepareTestFolder(String subFolder) throws IOException { String targetFolder = resourceBaseTestFolder + "/" + subFolder; File targetFolderFile = new File(targetFolder); FileUtils.deleteDirectory(targetFolderFile); FileUtils.copyDirectory(new File("src/test/resources/" + subFolder), targetFolderFile); }
From source file:com.jdom.junit.utils.TestUtil.java
/** * Setup the directory the test class should use. * /*from www .j a v a 2 s. c o m*/ * @param testClass * The test class to create a directory for * @return The directory created for the test class */ public static File setupTestClassDir(Class<?> testClass) { File dir = new File(System.getProperty("java.io.tmpdir"), testClass.getSimpleName()); // Delete any preexisting version try { FileUtils.deleteDirectory(dir); } catch (IOException e) { throw new IllegalStateException(e); } // Make the directory dir.mkdirs(); return dir; }
From source file:net.sf.jdbcwrappers.nulltype.NullTypeTest.java
@BeforeClass public static void createDataSource() throws Exception { FileUtils.deleteDirectory(new File("target/testDB")); rawDataSource = new EmbeddedDataSource(); rawDataSource.setDatabaseName("target/testDB"); rawDataSource.setUser("test"); rawDataSource.setCreateDatabase("create"); Connection connection = rawDataSource.getConnection(); try {//from w w w.java 2 s . co m if (ij.runScript(connection, NullTypeTest.class.getResourceAsStream("schema.sql"), "UTF-8", System.out, "UTF-8") > 0) { fail("Failed to initialize database"); } } finally { connection.close(); } dataSource = new NullTypeWrapperFactory().wrapDataSource(rawDataSource); }
From source file:com.ms.commons.test.common.FileUtil.java
public static void clearAndMakeDirs(String dir) { File f = new File(dir); if (f.exists()) { try {// ww w . jav a2 s . c o m FileUtils.deleteDirectory(f); } catch (IOException e) { e.printStackTrace(); } } f.mkdirs(); }
From source file:dev.meng.wikipedia.profiler.Cleaner.java
public static void cleanData(List<String> values) { for (String value : values) { try {//from w w w . java 2s. c o m Path filepath = Paths.get(value); File file = filepath.toFile(); if (file.exists()) { if (file.isFile()) { Files.delete(filepath); } else if (file.isDirectory()) { FileUtils.deleteDirectory(file); } } } catch (IOException ex) { LogHandler.console(Cleaner.class, ex); } } }
From source file:controller.NewEntryVideoControllerTest.java
@AfterClass public static void tearDownClass() { String fSeparator = File.separator; File file = new File("." + fSeparator + "MyDiaryBook" + fSeparator); try {/*w ww . java 2 s. com*/ FileUtils.deleteDirectory(file); } catch (IOException ex) { Logger.getLogger(NewEntryVideoControllerTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.netflix.imfutility.ImfUtilityTest.java
@BeforeClass public static void setupAll() throws IOException { // create both working directory and logs folder. FileUtils.deleteDirectory(TemplateParameterContextCreator.getWorkingDir()); File workingDir = TemplateParameterContextCreator.getWorkingDir(); if (!workingDir.mkdir()) { throw new RuntimeException("Could not create a working dir within tmp folder"); }//from www . j a v a2s . c om File logs = new File(TemplateParameterContextCreator.getWorkingDir(), CoreConstants.LOGS_DIR); if (!logs.mkdir()) { throw new RuntimeException("Could not create a log dir within working dir"); } }