List of usage examples for org.apache.commons.io FileUtils deleteQuietly
public static boolean deleteQuietly(File file)
From source file:io.github.robwin.swagger2markup.Swagger2MarkupConverterTest.java
@Test public void testSwagger2AsciiDocConversion() throws IOException { //Given//from w w w .jav a 2 s .c o m File file = new File(Swagger2MarkupConverterTest.class.getResource("/json/swagger.json").getFile()); File outputDirectory = new File("build/docs/asciidoc/generated"); FileUtils.deleteQuietly(outputDirectory); //When Swagger2MarkupConverter.from(file.getAbsolutePath()).build().intoFolder(outputDirectory.getAbsolutePath()); //Then String[] directories = outputDirectory.list(); assertThat(directories).hasSize(3).containsAll(asList("definitions.adoc", "overview.adoc", "paths.adoc")); }
From source file:com.thoughtworks.go.domain.JobInstancesTest.java
@After public void tearDown() { FileUtils.deleteQuietly(artifactsRoot); }
From source file:com.cloud.utils.ProcessUtilTest.java
@After public void cleanup() { FileUtils.deleteQuietly(pidFile); }
From source file:com.xeiam.datasets.common.business.DatasetsDAO.java
public static void init(String poolName, String dbName, String dataFilesDir, String dataFileURL, String propsFileURL, String scriptFileURL, String lobsFileURL, boolean requiresManualDownload) { // 1. create data dir // 1b. Clean up any stragglers FileUtils.deleteQuietly(new File(dataFilesDir + "/" + dbName + ".tmp")); FileUtils.deleteQuietly(new File(dataFilesDir + "/" + dbName + ".lck")); FileUtils.deleteQuietly(new File(dataFilesDir + "/" + dbName + ".log")); // 2. check if files are already available File dataFile = new File(dataFilesDir + "/" + dbName + ".data"); File propsFile = new File(dataFilesDir + "/" + dbName + ".properties"); File scriptFile = new File(dataFilesDir + "/" + dbName + ".script"); File lobsFile = new File(dataFilesDir + "/" + dbName + ".lobs"); // if the files don't yet exist, then download them if (!dataFile.exists() || !propsFile.exists() || !scriptFile.exists()) { logger.info("Saving DB files in: " + dataFilesDir); URL url;/*from w w w. j a v a 2s . co m*/ try { // props logger.info("Downloading props file..."); url = new URL(GoogleDriveURLPart1 + propsFileURL); org.apache.commons.io.FileUtils.copyURLToFile(url, propsFile, 5000, 10000); } catch (Exception e) { throw new RuntimeException( "Something went wrong while downloading the database files. Perhaps try again and if all else fails, download the files manually (https://drive.google.com/folderview?id=0ByP7_A9vXm17VXhuZzBrcnNubEE&usp=sharing) and place in the directory you specified.", e); } try { // script logger.info("Downloading script file..."); url = new URL(GoogleDriveURLPart1 + scriptFileURL); org.apache.commons.io.FileUtils.copyURLToFile(url, scriptFile, 5000, 10000); } catch (Exception e) { throw new RuntimeException( "Something went wrong while downloading the database files. Perhaps try again and if all else fails, download the files manually (https://drive.google.com/folderview?id=0ByP7_A9vXm17VXhuZzBrcnNubEE&usp=sharing) and place in the directory you specified.", e); } // data if (!requiresManualDownload) { try { logger.info("Downloading data file... (this could take a while so be patient!)"); url = new URL(GoogleDriveURLPart1 + dataFileURL); org.apache.commons.io.FileUtils.copyURLToFile(url, dataFile, 5000, 10000); } catch (Exception e) { throw new RuntimeException( "Something went wrong while downloading the database files. Perhaps try again and if all else fails, download the files manually (https://drive.google.com/folderview?id=0ByP7_A9vXm17VXhuZzBrcnNubEE&usp=sharing) and place in the directory you specified.", e); } } else { throw new RuntimeException( "The data file is too big to download automatically! Please manually download it from: " + (GoogleDriveURLPart1 + dataFileURL) + " and place it in: " + dataFilesDir); } } else { logger.info("Database files already exist in local directory. Skipping download."); } if (lobsFileURL != null && !lobsFile.exists()) { throw new RuntimeException( "The data file is too big to download automatically! Please manually download it from: " + (GoogleDriveURLPart1 + lobsFileURL) + " and place it in: " + dataFilesDir); } // 3. setup HSQLDB Properties dbProps = new Properties(); dbProps.setProperty("driverclassname", "org.hsqldb.jdbcDriver"); dbProps.setProperty(poolName + ".url", "jdbc:hsqldb:file:" + dataFilesDir + File.separatorChar + dbName + ";shutdown=true;readonly=true"); dbProps.setProperty(poolName + ".user", "sa"); dbProps.setProperty(poolName + ".password", ""); dbProps.setProperty(poolName + ".maxconn", "10"); DBConnectionManager.INSTANCE.init(dbProps); }
From source file:com.github.rwhogg.git_vcr.review.php.PhpmdReviewTool.java
@Override public List<String> getResults(File file) throws ReviewFailedException { // delete the cache first Path pathToCache = FileSystems.getDefault().getPath(System.getProperty("user.home"), ".pdepend"); try {//from w w w .j ava 2s . co m FileUtils.deleteQuietly(pathToCache.toFile()); } catch (Exception e) { } List<Object> rules = configuration.getList("rules"); String commandTemplate = "\"%s\" text \"%s\""; List<String> results; try { StringBuffer ruleStringBuffer = new StringBuffer(); for (Object rule : rules) { ruleStringBuffer.append((String) rule + ","); } String ruleString = ruleStringBuffer.toString(); results = runProcess(String.format(commandTemplate, file.getAbsolutePath(), ruleString.substring(0, ruleString.length() - 1))); } catch (IOException e) { throw new ReviewFailedException(e.getLocalizedMessage(), this, file.getAbsolutePath()); } // first result is always an empty line if ((results != null) && (results.size() > 0)) { List<String> copy = new LinkedList<>(); copy.addAll(results); copy.remove(0); results = copy; } return results; }
From source file:com.linkedin.pinot.filesystem.LocalPinotFSTest.java
@BeforeClass public void setUp() { _absoluteTmpDirPath = new File(System.getProperty("java.io.tmpdir"), LocalPinotFSTest.class.getSimpleName() + "first"); FileUtils.deleteQuietly(_absoluteTmpDirPath); Assert.assertTrue(_absoluteTmpDirPath.mkdir(), "Could not make directory " + _absoluteTmpDirPath.getPath()); try {/*from w ww.j a v a2 s . c o m*/ testFile = new File(_absoluteTmpDirPath, "testFile"); Assert.assertTrue(testFile.createNewFile(), "Could not create file " + testFile.getPath()); } catch (IOException e) { throw new RuntimeException(e); } _newTmpDir = new File(System.getProperty("java.io.tmpdir"), LocalPinotFSTest.class.getSimpleName() + "second"); FileUtils.deleteQuietly(_newTmpDir); Assert.assertTrue(_newTmpDir.mkdir(), "Could not make directory " + _newTmpDir.getPath()); _absoluteTmpDirPath.deleteOnExit(); _newTmpDir.deleteOnExit(); }
From source file:de.uzk.hki.da.at.ATUseCaseIngestSpecialCases.java
@After public void tearDown() { FileUtils.deleteQuietly( Path.make(localNode.getWorkAreaRootPath(), "/work/TEST/" + object.getIdentifier()).toFile()); Path.make(localNode.getIngestAreaRootPath(), "/TEST/AT_CON1.tar").toFile().delete(); Path.make(localNode.getIngestAreaRootPath(), "/TEST/AT_CON2.tgz").toFile().delete(); Path.make(localNode.getIngestAreaRootPath(), "/TEST/AT_CON3.zip").toFile().delete(); }
From source file:com.thoughtworks.go.domain.builder.CommandBuilderTest.java
@After public void tearDown() { FileUtils.deleteQuietly(tempWorkDir); }
From source file:gov.nih.nci.caarray.plugins.agilent.AgilentTextParserTest.java
@Test public void emptyInputTest() throws Exception { File file = createFile(new String[] {}); AgilentTextParser parser = new AgilentTextParser(file); assertFalse(parser.hasNext());//from w ww . j av a2 s . c o m FileUtils.deleteQuietly(file); }
From source file:com.gs.obevo.mithra.MithraSchemaConverterTest.java
@Test public void testConvertMithraDdlsToDaFormat() throws Exception { final File outputFolder = new File("./target/mithraRevengTest"); FileUtils.deleteQuietly(outputFolder); final MithraSchemaConverter mithraSchemaConverter = new MithraSchemaConverter(); final ChangeType tableChangeType = mock(ChangeType.class); when(tableChangeType.getDirectoryName()).thenReturn("table"); Platform platform = mock(Platform.class); when(platform.getName()).thenReturn("mockPlatform"); when(platform.getChangeType(ChangeType.TABLE_STR)).thenReturn(tableChangeType); when(platform.getObjectExclusionPredicateBuilder()).thenReturn( new ObjectTypeAndNamePredicateBuilder(ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE)); when(platform.convertDbObjectName()).thenReturn(Functions.getStringPassThru()); mithraSchemaConverter.convertMithraDdlsToDaFormat(platform, new File("./src/test/resources/reveng/input"), outputFolder, "yourSchema", true); DirectoryAssert.assertDirectoriesEqual(new File("./src/test/resources/reveng/expected"), outputFolder); }