List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:com.googlecode.jgenhtml.JGenXmlTest.java
private void runJgenhtml() { try {/*from ww w .ja va 2s.c o m*/ File outputDir = JGenHtmlTestUtils.getTestDir(); FileUtils.cleanDirectory(outputDir);//START WITH A CLEAN DIRECTORY! String outputDirPath = outputDir.getAbsolutePath(); String traceFile = JGenHtmlTestUtils.getJstdTraceFiles(false, false)[0]; String[] argv = new String[] { "-o", outputDirPath, traceFile }; traceFileName = new File(traceFile).getName(); JGenHtml.main(argv); } catch (IOException ex) { fail(ex.getLocalizedMessage()); } }
From source file:ch.ivyteam.ivy.maven.TestCompileProjectMojo.java
@Test public void buildWithExistingProject() throws Exception { CompileProjectMojo mojo = compile.getMojo(); File dataClassDir = new File(mojo.project.getBasedir(), "src_dataClasses"); File wsProcDir = new File(mojo.project.getBasedir(), "src_wsproc"); File classDir = new File(mojo.project.getBasedir(), "classes"); FileUtils.cleanDirectory(wsProcDir); FileUtils.cleanDirectory(dataClassDir); mojo.buildApplicationDirectory = Files.createTempDirectory("MyBuildApplication").toFile(); mojo.execute();/*from w w w . j a v a 2 s.c o m*/ assertThat(findFiles(dataClassDir, "java")).hasSize(2); assertThat(findFiles(wsProcDir, "java")).hasSize(1); assertThat(findFiles(classDir, "txt")) .as("classes directory must be cleand by the builder before compilation").isEmpty(); assertThat(findFiles(classDir, "class")).as("compiled classes must exist. but not contain any test class.") .hasSize(4); assertThat(findFiles(classDir, "xml")) .as("resources from the src folder must be copied to the classes folder").hasSize(1); testMojo.execute(); assertThat(findFiles(classDir, "class")).as("compiled classes must contain test resources as well") .hasSize(5); }
From source file:com.googlecode.t7mp.steps.DeleteDefaultWebappsSequence.java
@Override public void execute(Context context) { this.logger = context.getLog(); this.configuration = context.getConfiguration(); if (configuration.isDeleteDefaultTomcatWebapps()) { logger.info("Delete all default tomcat webapps"); try {// w w w . j av a 2 s. co m FileUtils.cleanDirectory(new File(configuration.getCatalinaBase(), "/webapps")); } catch (IOException e) { e.printStackTrace(); } } else { for (Step step : this.sequence) { step.execute(context); } } }
From source file:de.tobiasbruns.content.storage.ContentControllerITCase.java
@AfterClass public static void cleanup() throws IOException { File rootDir = new File("testroot"); if (rootDir.exists()) { FileUtils.cleanDirectory(rootDir); }/*w w w. j av a 2 s . c o m*/ }
From source file:com.buddycloud.mediaserver.delete.DeleteAvatarTest.java
@Override protected void testSetUp() throws Exception { File destDir = new File(configuration.getProperty(MediaServerConfiguration.MEDIA_STORAGE_ROOT_PROPERTY) + File.separator + BASE_CHANNEL); if (!destDir.mkdir()) { FileUtils.cleanDirectory(destDir); }//from w w w . j av a 2 s . c o m fileToDelete = new File(destDir + File.separator + MEDIA_ID); FileUtils.copyFile(new File(TEST_FILE_PATH + TEST_AVATAR_NAME), fileToDelete); Media media = buildMedia(MEDIA_ID, TEST_FILE_PATH + TEST_AVATAR_NAME); dataSource.storeMedia(media); dataSource.storeAvatar(media); // mocks AuthVerifier authClient = xmppTest.getAuthVerifier(); EasyMock.expect(authClient.verifyRequest(EasyMock.matches(BASE_USER), EasyMock.matches(BASE_TOKEN), EasyMock.startsWith(URL))).andReturn(true); PubSubClient pubSubClient = xmppTest.getPubSubClient(); EasyMock.expect(pubSubClient.matchUserCapability(EasyMock.matches(BASE_USER), EasyMock.matches(BASE_CHANNEL), (CapabilitiesDecorator) EasyMock.notNull())).andReturn(true); EasyMock.replay(authClient); EasyMock.replay(pubSubClient); }
From source file:com.buddycloud.mediaserver.delete.DeleteMediaTest.java
@Override protected void testSetUp() throws Exception { File destDir = new File(configuration.getProperty(MediaServerConfiguration.MEDIA_STORAGE_ROOT_PROPERTY) + File.separator + BASE_CHANNEL); if (!destDir.mkdir()) { FileUtils.cleanDirectory(destDir); }/*from w w w . java 2s .c o m*/ fileToDelete = new File(destDir + File.separator + MEDIA_ID); FileUtils.copyFile(new File(TEST_FILE_PATH + TEST_IMAGE_NAME), fileToDelete); Media media = buildMedia(MEDIA_ID, TEST_FILE_PATH + TEST_IMAGE_NAME); dataSource.storeMedia(media); // mocks AuthVerifier authClient = xmppTest.getAuthVerifier(); EasyMock.expect(authClient.verifyRequest(EasyMock.matches(BASE_USER), EasyMock.matches(BASE_TOKEN), EasyMock.startsWith(URL))).andReturn(true); PubSubClient pubSubClient = xmppTest.getPubSubClient(); EasyMock.expect(pubSubClient.matchUserCapability(EasyMock.matches(BASE_USER), EasyMock.matches(BASE_CHANNEL), (CapabilitiesDecorator) EasyMock.notNull())).andReturn(true); EasyMock.replay(authClient); EasyMock.replay(pubSubClient); }
From source file:au.org.ands.vocabs.toolkit.utils.ToolkitFileUtils.java
/** Require the existence of a directory, but clean it out if * it already exists. Create it, if it does not already exist. * @param dir The full pathname of the required directory. * @throws IOException If the directory already exists but can * not be cleaned.//from w w w. j a va 2s. c om */ public static void requireEmptyDirectory(final String dir) throws IOException { File oDir = new File(dir); if (!oDir.exists()) { oDir.mkdirs(); } else { try { FileUtils.cleanDirectory(new File(dir)); } catch (IOException e) { logger.error("requireEmptyDirectory failed: ", e); throw e; } } }
From source file:com.igormaznitsa.jcp.usecases.AbstractUseCaseTest.java
@After public void after() throws Exception { if (deleteResult()) { try {//from w ww.j av a2s . c o m FileUtils.cleanDirectory(tmpResultFolder.getRoot()); } finally { tmpResultFolder.delete(); } } }
From source file:by.logscanner.LogScanner.java
public void init() throws IOException { ResourceBundle resBundle = ResourceBundle.getBundle("config"); resPath = resBundle.getString("resPath"); destPath = resBundle.getString("destPath"); FileUtils.cleanDirectory(new File(destPath)); if (!isGateway()) { walk(resPath);//from w ww .j a v a2 s . c o m fileData.add(new FileData(getDestFileName(), toBytes())); } else { walkGateway(resPath); } write(); }
From source file:com.tc.l2.logging.TCLoggingTest.java
public void testRollover() throws Exception { String logDir = "/tmp/terracotta/test/com/tc/logging"; File logDirFolder = new File(logDir); logDirFolder.mkdirs();//from w w w . j a va 2s . c o m try { FileUtils.cleanDirectory(logDirFolder); } catch (IOException e) { Assert.fail("Unable to clean the temp log directory !! Exiting..."); } final int LOG_ITERATIONS = 5; for (int i = 0; i < LOG_ITERATIONS; i++) { createLogs(logDir); } File[] listFiles = logDirFolder.listFiles(); int logFileCount = 0; for (File file : listFiles) { String ext = file.getName().substring(file.getName().lastIndexOf('.') + 1); if (!file.isHidden() && ext.equals("log")) { logFileCount++; } } // Always one extra file is created by log4j Assert.assertEquals(LOG_ITERATIONS + 1, logFileCount); }