private OutputStream target(String targetFile) throws FileNotFoundException { return new FileOutputStream(testFolder.getAbsolutePath() + FileUtil.fileseparator() + targetFile); }
private OutputStream target(String targetFile) throws FileNotFoundException { return new FileOutputStream(testFolder.getAbsolutePath() + FileUtil.fileseparator() + targetFile); }
private InputStream source(String filename) throws IOException { return new ClassPathResource(FileUtil.fileseparator() + "data" + FileUtil.fileseparator() + filename).getInputStream(); }
private InputStream source(String filename) throws IOException { return new ClassPathResource(FileUtil.fileseparator() + "data" + FileUtil.fileseparator() + filename).getInputStream(); }
public Properties generate(File[] allTestFiles, String uploadDestPath) { FileOutputStream transformedHtml = null; File mergedResults = new File(folderToUpload.getAbsolutePath() + FileUtil.fileseparator() + TEST_RESULTS_FILE); File mergedResource = null; FileInputStream mergedFileStream = null; try { mergedResource = mergeAllTestResultToSingleFile(allTestFiles); transformedHtml = new FileOutputStream(mergedResults); try { mergedFileStream = new FileInputStream(mergedResource); Source xmlSource = new StreamSource(mergedFileStream); StreamResult result = new StreamResult(transformedHtml); templates.newTransformer().transform(xmlSource, result); } catch (Exception e) { publisher.reportErrorMessage("Unable to publish test properties. Error was " + e.getMessage(), e); } extractProperties(mergedResults); publisher.upload(mergedResults, uploadDestPath); return null; } catch (Exception e) { publisher.reportErrorMessage("Unable to publish test properties. Error was " + e.getMessage(), e); } finally { IOUtils.closeQuietly(mergedFileStream); IOUtils.closeQuietly(transformedHtml); if (mergedResource != null) { mergedResource.delete(); } } return new Properties(); }
@Test public void shouldConvertFileCorrectly() throws Exception { final Foo object = new Foo(); final GoConfigFieldWriter field = new GoConfigFieldWriter(Foo.class.getDeclaredField("directory"), object, configCache, null); final Element element = new Element("foo"); element.setAttribute("directory", "foo" + FileUtil.fileseparator() + "dir"); field.setValueIfNotNull(element, object); assertThat(object.directory.getPath(), is("foo" + FileUtil.fileseparator() + "dir")); }