List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:co.cask.cdap.filetailer.tailer.TailerLogUtils.java
public static void clearTestDir() throws IOException { PipeConfiguration flowConf = loadConfig(); File dir = flowConf.getSourceConfiguration().getWorkDir(); FileUtils.cleanDirectory(dir); }
From source file:com.xiaomi.linden.core.TestMultiLindenCore.java
@BeforeClass public static void beforeClass() throws Exception { if (new File(INDEX_DIR).exists()) { FileUtils.cleanDirectory(new File(INDEX_DIR)); }/* www. j a v a2 s .co m*/ }
From source file:com.buddycloud.mediaserver.download.DownloadImageTest.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 a va 2 s . co m FileUtils.copyFile(new File(TEST_FILE_PATH + TEST_IMAGE_NAME), new File(destDir + File.separator + MEDIA_ID)); Media media = buildMedia(MEDIA_ID, TEST_FILE_PATH + TEST_IMAGE_NAME); dataSource.storeMedia(media); // mocks AuthVerifier authClient = xmppTest.getAuthVerifier(); EasyMock.expect(authClient.verifyRequest(BASE_USER, BASE_TOKEN, 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.download.DownloadVideoTest.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 . jav a2 s .c om*/ FileUtils.copyFile(new File(TEST_FILE_PATH + TEST_VIDEO_NAME), new File(destDir + File.separator + MEDIA_ID)); Media media = buildMedia(MEDIA_ID, TEST_FILE_PATH + TEST_VIDEO_NAME); dataSource.storeMedia(media); // mocks AuthVerifier authClient = xmppTest.getAuthVerifier(); EasyMock.expect(authClient.verifyRequest(BASE_USER, BASE_TOKEN, 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:jp.co.tis.gsp.tools.dba.mojo.GenerateDdlMojo.java
/** * Generate DDL.//ww w. j av a2 s.co m * * @throws MojoExecutionException * @throws MojoFailureException */ @Override protected void executeMojoSpec() throws MojoExecutionException, MojoFailureException { if (outputDirectory.exists()) { try { FileUtils.cleanDirectory(outputDirectory); } catch (IOException e) { throw new MojoExecutionException("Can't clean outputDirectory:" + outputDirectory); } } else { try { FileUtils.forceMkdir(outputDirectory); } catch (IOException e) { throw new MojoExecutionException("Can't create outputDirectory:" + outputDirectory); } } ObjectBrowserErParser parser = new ObjectBrowserErParser(); parser.setOutputDirectory(outputDirectory); parser.setSchema(schema); parser.setUrl(url); parser.setUser(user); parser.setDdlTemplateFileDir(ddlTemplateFileDir); Dialect dialect = DialectFactory.getDialect(url, driver); parser.setTypeMapper(dialect.getTypeMapper()); parser.setPrintTable(dialect.canPrintTable()); parser.setPrintIndex(dialect.canPrintIndex()); parser.setPrintForeignKey(dialect.canPrintForeignKey()); parser.setPrintView(dialect.canPrintView()); parser.setLengthSemantics(lengthSemantics); parser.setAllocationSize(allocationSize); ; try { parser.parse(erdFile); } catch (Exception e) { throw new MojoExecutionException("DDL generate", e); } }
From source file:com.buddycloud.mediaserver.update.UpdateAvatarTest.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 ww w. j a v a2s . com FileUtils.copyFile(new File(TEST_FILE_PATH + TEST_AVATAR_NAME), new File(destDir + File.separator + MEDIA_ID)); 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:dmh.kuebiko.model.filesystem.FileSystemNoteDaoTest.java
@AfterMethod public void methodCleanup() throws IOException { // Clean the temp directory for the next test. FileUtils.cleanDirectory(tempDir); }
From source file:com.tascape.qa.th.db.H2Handler.java
@Override public void init() throws Exception { File dir = new File(this.dbPath); if (dir.exists()) { FileUtils.cleanDirectory(dir); }// w ww.j a v a 2s . com this.connPool = JdbcConnectionPool.create("jdbc:h2:" + this.dbPath + SYS_CONFIG.getExecId(), "sa", "sa"); connPool.setMaxConnections(10); try (Connection conn = this.getConnection()) { try { conn.prepareStatement("SELECT * FROM test_result WHERE 0;").executeQuery(); } catch (SQLException ex) { LOG.warn("{}", ex.getMessage()); this.initSchema(); } } }
From source file:com.buddycloud.mediaserver.download.DownloadAvatarTest.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 a v a 2 s.c o m FileUtils.copyFile(new File(TEST_FILE_PATH + TEST_AVATAR_NAME), new File(destDir + File.separator + MEDIA_ID)); 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(BASE_USER, BASE_TOKEN, URL)).andReturn(true); PubSubClient pubSubClient = xmppTest.getPubSubClient(); EasyMock.expect(pubSubClient.isChannelPublic(EasyMock.matches(BASE_CHANNEL))).andReturn(true); 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.groupcdg.maven.tidesdk.GenerateMojoTest.java
@Test public void testDefaultGeneration() throws Exception { File target = new File(DEFAULT_PROJECT, "target"); if (target.exists()) FileUtils.cleanDirectory(target); rule.configureMojo(new GenerateMojo(), PLUGIN_NAME, pom(DEFAULT_PROJECT)); rule.executeMojo(DEFAULT_PROJECT, GENERATE_GOAL); assertIncluded(config(DEFAULT_PROJECT, "manifest"), "appname: Default_Project"); assertIncluded(config(DEFAULT_PROJECT, "tiapp.xml"), "<name>Default Project</name>"); assertIncluded(asset(DEFAULT_PROJECT, "index.html"), DEFAULT_ASSET_CONTENT); assertIncluded(asset(DEFAULT_PROJECT, "css/style.css"), DEFAULT_ASSET_CONTENT); }