List of usage examples for java.io File deleteOnExit
public void deleteOnExit()
From source file:gov.nih.nci.caintegrator.application.analysis.SegmentDatasetFileWriterTest.java
@Test public void testWriteAsSegFile() throws IOException { List<SegmentData> result = createTestResult(); String testFilePath = System.getProperty("java.io.tmpdir") + File.separator + "segTest.seg"; File segFile = SegmentDatasetFileWriter.writeAsSegFile(result, testFilePath, false); segFile.deleteOnExit(); checkFile(segFile, result);/* w w w . j a va2s . co m*/ }
From source file:info.magnolia.ui.form.field.upload.DefaultFileFactory.java
@Override public File createFile(String fileName, String mimeType) { try {// ww w.j a v a 2s. c o m File tmpFile = File.createTempFile(StringUtils.rightPad(fileName, 5, "x"), null, directory); tmpFile.deleteOnExit(); return tmpFile; } catch (IOException e) { throw new RuntimeException(e); } }
From source file:me.kafeitu.activiti.extra.test.repository.ProcessDefinitionHelperTest.java
@Test @Deployment(resources = "me/kafeitu/activiti/extra/test/runtime/AutoAssignee.bpmn") public void testExportDiagramToFile() throws Exception { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().latestVersion() .singleResult();//from w w w.j a va 2s .c o m String dir = "/tmp"; if (OSValidator.isWindows()) { dir = "c:\\"; } String exportDiagramToFile = processDefinitionHelper.exportDiagramToFile(processDefinition, dir); assertNotNull(exportDiagramToFile); File file = new File(exportDiagramToFile); assertTrue(file.exists()); file.deleteOnExit(); }
From source file:put.semantic.fcanew.script.HandcraftedScript.java
private File copy(String resource) throws IOException { File f = File.createTempFile("fca", null); f.deleteOnExit(); try (InputStream input = HandcraftedScript.class.getClassLoader().getResourceAsStream(resource); FileOutputStream output = new FileOutputStream(f)) { IOUtils.copy(input, output);//from w w w.j a va2s .c om } return f; }
From source file:com.sap.prd.mobile.ios.mios.PListAccessorTest.java
private File createTempFile() throws IOException { File temp = File.createTempFile("Info", ".plist"); temp.deleteOnExit(); return temp;/*from w ww .ja va 2s . com*/ }
From source file:com.logsniffer.model.file.FileLogTest.java
@Test public void testReadInt() throws IOException { File openFile = File.createTempFile("test", "txt"); openFile.deleteOnExit(); FileOutputStream out = new FileOutputStream(openFile); FileLog flog = new FileLog(openFile); IOUtils.write("line1\n", out); out.flush();//from w ww . j av a 2s . c o m ByteLogInputStream lis = new DirectFileLogAccess(flog).getInputStream(null); // Log instanatiated before data is written assertEquals(-1, lis.read()); flog = new FileLog(openFile); lis = new DirectFileLogAccess(flog).getInputStream(null); assertEquals('l', lis.read()); assertEquals('i', lis.read()); assertEquals('n', lis.read()); assertEquals('e', lis.read()); assertEquals('1', lis.read()); assertEquals('\n', lis.read()); assertEquals(-1, lis.read()); // Write more, but lis doesn't see the new data due to size limitation IOUtils.write("l2\n", out); out.flush(); assertEquals(-1, lis.read()); lis.close(); }
From source file:com.thoughtworks.go.config.MagicalCruiseConfigXmlPerformanceTest.java
private File tempCruiseConfig() throws IOException { File tempFile = File.createTempFile("cruise-config", "xml"); tempFile.deleteOnExit(); return tempFile; }
From source file:com.tascape.qa.th.webui.test.SeleniumIdeTests.java
protected boolean runSeleniumIdeFirefox(File html, String browserURL) throws Exception { File tempDir = new File(html.getParentFile() + "/temp/"); tempDir.mkdir();/*from w w w . j ava 2 s .co m*/ File suite = File.createTempFile("selenium-ide-temp-suite-", ".html", tempDir); suite.deleteOnExit(); String content = TEST_SUITE_TEMPLATE.replaceAll("XXXXXXXXXXXXXXXXXXXX", html.getName()); FileUtils.write(suite, content); LOG.debug("Temp test suite file {}", suite.getAbsolutePath()); File result = this.saveIntoFile("ide-result", "html", ""); this.captureScreens(2000); HTMLLauncher launcher = new HTMLLauncher(this.seleniumServer); String ff = "*firefox"; String bin = sysConfig.getProperty(Firefox.SYSPROP_FF_BINARY); if (bin != null) { ff += " " + bin; } String pf = launcher.runHTMLSuite(ff, browserURL, suite.toURI().toURL().toString(), result, 36000, true); suite.delete(); return "PASSED".equals(pf); }
From source file:com.googlecode.fannj.FannTrainerTest.java
@Test public void testCascadeTraining() throws IOException { File temp = File.createTempFile("fannj_", ".tmp"); temp.deleteOnExit(); IOUtils.copy(this.getClass().getResourceAsStream("parity8.train"), new FileOutputStream(temp)); Fann fann = new FannShortcut(8, 1); Trainer trainer = new Trainer(fann); float desiredError = .00f; float mse = trainer.cascadeTrain(temp.getPath(), 30, 1, desiredError); assertTrue("" + mse, mse <= desiredError); }
From source file:de.tudarmstadt.ukp.dkpro.core.mallet.topicmodel.io.MalletTopicProportionsWriterTest.java
@Test public void test() throws UIMAException, IOException { File targetFile = new File("target/topics.txt"); targetFile.deleteOnExit(); int expectedLines = 2; String expectedLine0Regex = "dummy1.txt\t(0\\.[0-9]{4},){9}0\\.[0-9]{4}"; String expectedLine1Regex = "dummy2.txt\t(0\\.[0-9]{4},){9}0\\.[0-9]{4}"; CollectionReaderDescription reader = createReaderDescription(TextReader.class, TextReader.PARAM_SOURCE_LOCATION, CAS_DIR, TextReader.PARAM_PATTERNS, CAS_FILE_PATTERN, TextReader.PARAM_LANGUAGE, LANGUAGE); AnalysisEngineDescription segmenter = createEngineDescription(BreakIteratorSegmenter.class); AnalysisEngineDescription inferencer = createEngineDescription(MalletTopicModelInferencer.class, MalletTopicModelInferencer.PARAM_MODEL_LOCATION, MODEL_FILE, MalletTopicModelInferencer.PARAM_USE_LEMMA, USE_LEMMAS); AnalysisEngineDescription writer = createEngineDescription(MalletTopicProportionsWriter.class, MalletTopicProportionsWriter.PARAM_TARGET_LOCATION, targetFile); SimplePipeline.runPipeline(reader, segmenter, inferencer, writer); List<String> lines = FileUtils.readLines(targetFile); assertTrue(lines.get(0).matches(expectedLine0Regex)); assertTrue(lines.get(1).matches(expectedLine1Regex)); assertEquals(expectedLines, lines.size()); }