public static String readFile(File f) throws IOException { try (InputStream is = new FileInputStream(f)) { return readFile(is); } }
InputStream inputStream = jf.getInputStream(je); File copyFile = new File(file, jeName); Files.copyFile(inputStream, copyFile); if (matchesXmlPathInJar(je)) { suitePath = copyFile.toString();
private static String createTemporarySuiteAndGetItsPath() throws IOException { Path file = Files.createTempFile("testng", ".xml"); org.testng.reporters.Files.writeFile( buildSuiteContentThatRefersToInvalidTestClass(), file.toFile()); return file.toFile().getAbsolutePath(); }
InputStream inputStream = jf.getInputStream(je); File copyFile = new File(file, jeName); Files.copyFile(inputStream, copyFile); if (matchesXmlPathInJar(je)) { suitePath = copyFile.toString();
@Test(description = "GITHUB-1787") public void testParameterInclusion() throws IOException { SuiteXmlParser parser = new SuiteXmlParser(); String file = "src/test/resources/yaml/1787.xml"; XmlSuite xmlSuite = parser.parse(file, new FileInputStream(file), false); StringBuilder yaml = org.testng.internal.Yaml.toYaml(xmlSuite); Matcher m = Pattern.compile("parameters:").matcher(yaml.toString()); int count = 0; while (m.find()) { count++; } assertThat(count).isEqualTo(5); File newSuite = File.createTempFile("suite", ".xml"); newSuite.deleteOnExit(); Files.writeFile(yaml.toString(), newSuite); assertThat(parser.parse(newSuite.getAbsolutePath(), new FileInputStream(file), false)) .isEqualTo(xmlSuite); }
public static String readFile(File f) throws IOException { try (InputStream is = new FileInputStream(f)) { return readFile(is); } }
@Test(description = "GITHUB-1834") public void ensureDependenciesDefinedInSuiteAreHonored() throws IOException { File file = File.createTempFile("1834", ".xml"); Files.writeFile(asSuite(), file); TestNG testng = create(); testng.setTestSuites(Collections.singletonList(file.getAbsolutePath())); OutputGatheringListener listener = new OutputGatheringListener(); testng.addListener(listener); testng.run(); assertThat(listener.getConsoleLogs()).containsExactly("Uncached", "Cached"); }
@Override public String toString() { String result = null; if (m_file != null) { flushToFile(); try { result = Files.readFile(m_file); } catch (IOException e) { e.printStackTrace(); } } else { result = m_sb.toString(); } return result; }
@Override public String toString() { String result = null; if (m_file != null) { flushToFile(); try { result = Files.readFile(m_file); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } } else { result = m_sb.toString(); } return result; } }
@Override public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) { m_outputDirectory = outputDirectory; XMLStringBuffer xsb = new XMLStringBuffer(" "); xsb.push(D, "id", "suites"); generateSuites(xmlSuites, suites, xsb); xsb.pop(D); String all; try { all = Files.readFile(new File(m_outputDirectory + "/head")); Utils.writeFile(m_outputDirectory, "index2.html", all + xsb.toXML()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }