/** * Saves the content of the string buffer to the specified file. * * @param file the file to write to. * @param content the content to write to the file. */ protected void saveSuiteContent(final File file, final XMLStringBuffer content) { try (OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8"))) { fw.write(content.getStringBuffer().toString()); } catch (IOException ioe) { // TODO CQ is this normal to swallow exception here LOGGER.error("IO Exception", ioe); } } }
/** * Saves the content of the string buffer to the specified file. * * @param file the file to write to. * @param content the content to write to the file. */ protected void saveSuiteContent(final File file, final XMLStringBuffer content) { try (OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8"))) { fw.write(content.getStringBuffer().toString()); } catch (IOException ioe) { // TODO CQ is this normal to swallow exception here LOGGER.error("IO Exception", ioe); } } }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); if (hasElements(m_methodSelectors)) { xsb.push("method-selectors"); for (XmlMethodSelector selector : m_methodSelectors) { xsb.getStringBuffer().append(selector.toXml(indent + " ")); } xsb.pop("method-selectors"); } return xsb.toXML(); } }
xsb.getStringBuffer().append(m.toXml(indent + " "));
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); if (hasElements(m_methodSelectors)) { xsb.push("method-selectors"); for (XmlMethodSelector selector : m_methodSelectors) { xsb.getStringBuffer().append(selector.toXml(indent + " ")); } xsb.pop("method-selectors"); } return xsb.toXML(); } }
xsb.getStringBuffer().append(d.toXml(indent2)); xsb.getStringBuffer().append(m_run.toXml(indent2)); xsb.getStringBuffer().append(d.toXml(indent2));
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); Properties prop = new Properties(); prop.setProperty("name", getName()); boolean hasMethods = !m_includedMethods.isEmpty() || !m_excludedMethods.isEmpty(); boolean hasParameters = !m_parameters.isEmpty(); if (hasParameters || hasMethods) { xsb.push("class", prop); XmlUtils.dumpParameters(xsb, m_parameters); if (hasMethods) { xsb.push("methods"); for (XmlInclude m : getIncludedMethods()) { xsb.getStringBuffer().append(m.toXml(indent + " ")); } for (String m : getExcludedMethods()) { Properties p = new Properties(); p.setProperty("name", m); xsb.addEmptyElement("exclude", p); } xsb.pop("methods"); } xsb.pop("class"); } else { xsb.addEmptyElement("class", prop); } return xsb.toXML(); }
xsb.getStringBuffer().append(d.toXml(indent2)); xsb.getStringBuffer().append(m_run.toXml(indent2)); xsb.getStringBuffer().append(d.toXml(indent2));
xsb.push("method-selectors"); for (XmlMethodSelector selector: xmlTest.getMethodSelectors()) { xsb.getStringBuffer().append(selector.toXml(indent + " ")); xsb.getStringBuffer().append(pack.toXml(" ")); xsb.push("classes"); for (XmlClass cls : xmlTest.getXmlClasses()) { xsb.getStringBuffer().append(cls.toXml(indent + " "));
xsb.getStringBuffer().append(pack.toXml(" ")); xsb.getStringBuffer().append(xmlSuite.getXmlMethodSelectors().toXml(" ")); } else { xsb.push("method-selectors"); for (XmlMethodSelector selector : xmlSuite.getMethodSelectors()) { xsb.getStringBuffer().append(selector.toXml(" ")); xsb.getStringBuffer().append(xmlSuite.getGroups().toXml(" ")); xsb.getStringBuffer().append(test.toXml(" "));
xsb.push("method-selectors"); for (XmlMethodSelector selector : xmlTest.getMethodSelectors()) { xsb.getStringBuffer().append(selector.toXml(indent + " ")); xsb.getStringBuffer().append(pack.toXml(" ")); xsb.push("classes"); for (XmlClass cls : xmlTest.getXmlClasses()) { xsb.getStringBuffer().append(cls.toXml(indent + " "));
xsb.getStringBuffer().append(pack.toXml(" ")); xsb.getStringBuffer().append(xmlSuite.getXmlMethodSelectors().toXml(" ")); } else { xsb.push("method-selectors"); for (XmlMethodSelector selector : xmlSuite.getMethodSelectors()) { xsb.getStringBuffer().append(selector.toXml(" ")); xsb.getStringBuffer().append(xmlSuite.getGroups().toXml(" ")); xsb.getStringBuffer().append(test.toXml(" "));
fw = new FileWriter(file); bw = new BufferedWriter(fw); bw.write(xmlBuffer.getStringBuffer().toString()); bw.flush();
protected void saveSuiteContent(final File file, final XMLStringBuffer content) { FileOutputStream fileOutputStream = null; BufferedOutputStream bufferedOutputStream = null; OutputStreamWriter osw = null; try { fileOutputStream = new FileOutputStream(file); bufferedOutputStream = new BufferedOutputStream(fileOutputStream); // use utf8 to solve special character problem osw = new OutputStreamWriter(bufferedOutputStream, Charset.forName("UTF-8")); osw.write(content.getStringBuffer().toString()); } catch (IOException ioException) { TestNGPlugin.log(ioException); } finally { try { if (osw != null) osw.close(); if (bufferedOutputStream != null) bufferedOutputStream.close(); if (fileOutputStream != null) fileOutputStream.close(); } catch (Exception e) { TestNGPlugin.log(e); } } }