List of usage examples for org.apache.commons.io FileUtils deleteDirectory
public static void deleteDirectory(File directory) throws IOException
From source file:com.gs.obevo.db.impl.platforms.oracle.OracleRevengTest.java
@Test @Override//w ww. j a va 2 s . co m public void testReverseEngineeringFromFile() throws Exception { AquaRevengArgs args = new AquaRevengArgs(); args.setDbSchema("MYSCHEMA01"); args.setGenerateBaseline(false); args.setJdbcUrl("jdbc:oracle:thin:@myhost.me.com:1234:MYSERVER"); args.setUsername("myuser"); args.setPassword("mypass"); File outputDir = new File("./target/outputReveng"); FileUtils.deleteDirectory(outputDir); args.setOutputPath(outputDir); args.setInputPath(new File("./src/test/resources/reveng/oracle/input.sql")); new OracleDbPlatform().getDdlReveng().reveng(args); DirectoryAssert.assertDirectoriesEqual(new File("./src/test/resources/reveng/oracle/expected"), new File(outputDir, "final")); }
From source file:com.topekalabs.testutils.FileTestWatcher.java
@Override public void finished(Description description) { if (deleteDir) { try {//w ww . ja va 2 s.co m FileUtils.deleteDirectory(tempDir); } catch (IOException ex) { throw new RuntimeException(ex); } } }
From source file:com.netflix.imfutility.itunes.chapters.ChaptersXmlProviderTest.java
@AfterClass public static void teardownAll() throws IOException { FileUtils.deleteDirectory(TemplateParameterContextCreator.getWorkingDir()); System.setProperty("user.dir", userDir); }
From source file:com.blackberry.testutil.LocalKafkaServer.java
public LocalKafkaServer() throws IOException { while (new File(logDir).exists()) { FileUtils.deleteDirectory(new File(logDir)); }// w w w . j a va 2s. c o m Properties props = new Properties(); props.put("broker.id", nodeId); props.put("port", port); props.put("log.dir", logDir); props.put("zookeeper.connect", zkConnect); props.put("host.name", "127.0.0.1"); KafkaConfig conf = new KafkaConfig(props); zkUtils = ZkUtils.apply(props.getProperty("zookeeper.connect"), 30000, 30000, JaasUtils.isZkSecurityEnabled()); server = new KafkaServerStartable(conf); server.startup(); }
From source file:com.leverno.ysbos.item.domain.ItemTest.java
public void tearDown() throws Exception { FileUtils.deleteDirectory(new File(rootFolder)); super.tearDown(); }
From source file:com.compomics.pladipus.denovo.processsteps.DenovoGUISetupStep.java
@Override public boolean doAction() throws UnspecifiedPladipusException { System.out.println("Running " + this.getClass().getName()); try {/* w w w. j a va2 s.c om*/ if (tempResources.exists()) { for (File aFile : tempResources.listFiles()) { if (aFile.exists()) { if (aFile.isFile()) { aFile.delete(); } else { FileUtils.deleteDirectory(aFile); } } } } else { tempResources.mkdirs(); } initialiseInputFiles(); } catch (IOException e) { throw new UnspecifiedPladipusException(e); } return true; }
From source file:com.dp.bigdata.taurus.agent.utils.FileExtractUtilsTest.java
@Test public void TestUnzip() { String path = getAbsolutePath("extract/test.zip"); File file = new File(path); try {/*from www.j ava 2s . c o m*/ FileExtractUtils.unZip(file); File testFile1 = new File(file.getParent() + "/test/test1.txt"); assertTrue(testFile1.exists()); FileUtils.deleteDirectory(new File(file.getParent() + "/test")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.redhat.red.offliner.PlaintextArtifactListReaderTest.java
@BeforeClass public static void prepare() throws IOException { File tempDir = new File(TEMP_PLAINTEXT_DIR); if (tempDir.exists()) { FileUtils.deleteDirectory(tempDir); }/* w ww .ja v a 2 s. co m*/ tempDir.mkdirs(); List<String> resources = new ArrayList<String>(4); resources.add(RESOURCE0); resources.add(RESOURCE1); resources.add(RESOURCE2); resources.add(RESOURCE3); for (String resource : resources) { File target = new File(TEMP_PLAINTEXT_DIR, resource); OutputStream os = new FileOutputStream(target); if (resource.equals(RESOURCE0)) { IOUtils.closeQuietly(os); continue; } InputStream is = PlaintextArtifactListReaderTest.class.getClassLoader().getResourceAsStream(resource); try { IOUtils.copy(is, os); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); } } }
From source file:com.api6.zkclient.util.TestUtil.java
/** * ??ZooKeeper server/*from www. j a v a 2s . com*/ * @param serverName * @param port * @return * @return ZKServer * @author: zhaojie/zh_jie@163.com */ public static ZKServer startServer(String serverName, int port) { String dataPath = "./target/test-classes/" + serverName + "/data"; String logPath = "./target/test-classes/" + serverName + "/log"; try { FileUtils.deleteDirectory(new File(dataPath)); FileUtils.deleteDirectory(new File(logPath)); } catch (IOException e) { throw new ZKException("start server error!", e); } return startServer(dataPath, logPath, port); }
From source file:com.jhash.oimadmin.Utils.java
public static DiagnosticCollector<JavaFileObject> compileJava(String className, String code, String outputFileLocation) { logger.trace("Entering compileJava({},{},{})", new Object[] { className, code, outputFileLocation }); File outputFileDirectory = new File(outputFileLocation); logger.trace("Validating if the output location {} exists and is a directory", outputFileLocation); if (outputFileDirectory.exists()) { if (outputFileDirectory.isDirectory()) { try { logger.trace("Deleting the directory and its content"); FileUtils.deleteDirectory(outputFileDirectory); } catch (IOException exception) { throw new OIMAdminException( "Failed to delete directory " + outputFileLocation + " and its content", exception); }//from ww w.j a va 2 s . c o m } else { throw new InvalidParameterException( "The location " + outputFileLocation + " was expected to be a directory but it is a file."); } } logger.trace("Creating destination directory for compiled class file"); outputFileDirectory.mkdirs(); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); if (compiler == null) { throw new NullPointerException( "Failed to locate a java compiler. Please ensure that application is being run using JDK (Java Development Kit) and NOT JRE (Java Runtime Environment) "); } StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); Iterable<File> files = Arrays.asList(new File(outputFileLocation)); boolean success = false; DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); try { JavaFileObject javaFileObject = new InMemoryJavaFileObject(className, code); fileManager.setLocation(StandardLocation.CLASS_OUTPUT, files); JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, Arrays.asList("-source", "1.6", "-target", "1.6"), null, Arrays.asList(javaFileObject)); success = task.call(); fileManager.close(); } catch (Exception exception) { throw new OIMAdminException("Failed to compile " + className, exception); } if (!success) { logger.trace("Exiting compileJava(): Return Value {}", diagnostics); return diagnostics; } else { logger.trace("Exiting compileJava(): Return Value null"); return null; } }