List of usage examples for org.apache.commons.io FileUtils deleteQuietly
public static boolean deleteQuietly(File file)
From source file:io.github.swagger2markup.extensions.SpringRestDocsExtensionsTest.java
@Test public void testSwagger2AsciiDocConversionWithSpringRestDocsExtension() throws IOException, URISyntaxException { //Given/* w w w . j ava 2s . co m*/ Path file = Paths .get(SpringRestDocsExtensionsTest.class.getResource("/yaml/swagger_petstore.yaml").toURI()); Path outputDirectory = Paths.get("build/test/asciidoc/spring_rest_docs"); FileUtils.deleteQuietly(outputDirectory.toFile()); //When Swagger2MarkupExtensionRegistry registry = new Swagger2MarkupExtensionRegistryBuilder() //.withPathsDocumentExtension(new SpringRestDocsExtension(Paths.get("src/test/resources/docs/asciidoc/paths").toUri()).withDefaultSnippets()) .build(); Properties properties = new Properties(); properties.load(SpringRestDocsExtensionsTest.class.getResourceAsStream("/config/config.properties")); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder(properties).build(); Swagger2MarkupConverter.from(file).withConfig(config).withExtensionRegistry(registry).build() .toFolder(outputDirectory); //Then String[] files = outputDirectory.toFile().list(); assertThat(files).hasSize(4).containsAll(expectedFiles); Path expectedFilesDirectory = Paths.get(SpringRestDocsExtensionsTest.class .getResource("/expected_results/asciidoc/spring_rest_docs").toURI()); DiffUtils.assertThatAllFilesAreEqual(outputDirectory, expectedFilesDirectory, "testSwagger2AsciiDocConversionWithSpringRestDocsExtension.html"); }
From source file:com.spotify.helios.system.AgentStateDirConflictTest.java
@After public void teardown() throws Exception { FileUtils.deleteQuietly(stateDir.toFile()); stopQuietly(first);//from w w w .j a v a2 s. com stopQuietly(second); Thread.setDefaultUncaughtExceptionHandler(dueh); zk.stop(); }
From source file:com.thoughtworks.go.plugin.infra.service.DefaultPluginLoggingServiceIntegrationTest.java
@After public void tearDown() throws Exception { for (Integer pluginIndex : plugins.keySet()) { FileUtils.deleteQuietly(pluginLog(pluginIndex)); }/* w ww . j a v a 2 s . c om*/ }
From source file:com.adaptris.util.stream.StreamUtilTest.java
@Test public void testCreateFileInDirectory() throws Exception { int bytes = TEXT.length(); ByteArrayInputStream in = new ByteArrayInputStream(TEXT.getBytes()); File f = StreamUtil.createFile(in, bytes, System.getProperty("java.io.tmpdir")); assertNotNull(f);/*from ww w.ja v a 2 s.c o m*/ assertEquals(TEXT, new String(read(f))); FileUtils.deleteQuietly(f); }
From source file:com.creactiviti.piper.plugin.ffmpeg.Ffmpeg.java
@Override public Object handle(Task aTask) throws Exception { List<String> options = aTask.getList("options", String.class); CommandLine cmd = new CommandLine("ffmpeg"); options.forEach(o -> cmd.addArgument(o)); log.debug("{}", cmd); DefaultExecutor exec = new DefaultExecutor(); File tempFile = File.createTempFile("log", null); try (PrintStream stream = new PrintStream(tempFile);) { exec.setStreamHandler(new PumpStreamHandler(stream)); int exitValue = exec.execute(cmd); return exitValue != 0 ? FileUtils.readFileToString(tempFile) : cmd.toString(); } catch (ExecuteException e) { throw new ExecuteException(e.getMessage(), e.getExitValue(), new RuntimeException(FileUtils.readFileToString(tempFile))); } finally {/* w w w. j av a 2s. com*/ FileUtils.deleteQuietly(tempFile); } }
From source file:com.thoughtworks.go.server.view.artifacts.ArtifactDirectoryChooserTest.java
@After public void removeTestDirectories() { if (root1.exists()) { FileUtils.deleteQuietly(root1); }//from w ww . j a va 2 s . c o m if (root2.exists()) { FileUtils.deleteQuietly(root2); } }
From source file:com.thoughtworks.go.buildsession.GenerateTestReportCommandExecutor.java
@Override public boolean execute(BuildCommand command, BuildSession buildSession) { File workingDirectory = buildSession.resolveRelativeDir(command.getWorkingDirectory()); String uploadPath = command.getStringArg("uploadPath"); String[] sources = command.getArrayArg("srcs"); ArrayList<File> allFiles = findMatchedSourceFiles(buildSession, workingDirectory, sources); if (allFiles.size() > 0) { File tempFolder = null;// w w w. ja v a 2 s .com try { tempFolder = FileUtil.createTempFolder(); File testResultSource = new File(tempFolder, "result"); testResultSource.mkdirs(); UnitTestReportGenerator generator = new UnitTestReportGenerator(buildSession.getPublisher(), testResultSource); generator.generate(allFiles.toArray(new File[allFiles.size()]), uploadPath); } finally { if (tempFolder != null) { FileUtils.deleteQuietly(tempFolder); } } } else { String message = "No files were found in the Test Results folders"; buildSession.printlnWithPrefix(message); LOG.warn(message); } return true; }
From source file:com.thoughtworks.go.server.service.RailsAssetsServiceTest.java
@After public void teardown() { FileUtils.deleteQuietly(assetsDir); }
From source file:com.linkedin.pinot.server.integration.HelixStarterTest.java
@BeforeClass public void setup() { FileUtils.deleteQuietly(INDEX_DIR); Assert.assertTrue(INDEX_DIR.mkdirs()); }
From source file:de.mpg.imeji.logic.storage.util.MediaUtils.java
/** * User imagemagick to convert any image into a jpeg * /* www.java 2 s .co m*/ * @param bytes * @param extension * @throws IOException * @throws URISyntaxException * @throws InterruptedException * @throws IM4JavaException */ public static byte[] convertToJPEG(File tmp, String extension) throws IOException, URISyntaxException, InterruptedException, IM4JavaException { // In case the file is made of many frames, (for instance videos), generate only the frames from 0 to 48 to // avoid high memory consumption String path = tmp.getAbsolutePath() + "[0-48]"; ConvertCmd cmd = getConvert(); // create the operation, add images and operators/options IMOperation op = new IMOperation(); if (isImage(extension)) op.colorspace(findColorSpace(tmp)); op.strip(); op.flatten(); op.addImage(path); // op.colorspace("RGB"); File jpeg = File.createTempFile("uploadMagick", ".jpg"); try { op.addImage(jpeg.getAbsolutePath()); cmd.run(op); int frame = getNonBlankFrame(jpeg.getAbsolutePath()); if (frame >= 0) { File f = new File(FilenameUtils.getFullPath(jpeg.getAbsolutePath()) + FilenameUtils.getBaseName(jpeg.getAbsolutePath()) + "-" + frame + ".jpg"); return FileUtils.readFileToByteArray(f); } return FileUtils.readFileToByteArray(jpeg); } finally { removeFilesCreatedByImageMagick(jpeg.getAbsolutePath()); FileUtils.deleteQuietly(jpeg); } }