/** * Push a new tag. Its value is stored and will be compared against the parameter * passed to pop(). * * @param tagName The name of the tag. */ public void push(String tagName) { push(tagName, ""); }
/** * Push a new tag. Its value is stored and will be compared against the parameter * passed to pop(). * * @param tagName The name of the tag. * @param schema The schema to use (can be null or an empty string). */ public void push(String tagName, @Nullable String schema) { push(tagName, schema, null); }
/** * Push a new tag. Its value is stored and will be compared against the parameter * passed to pop(). * * @param tagName The name of the tag. * @param attributes A Properties file representing the attributes (or null) */ public void push(String tagName, @Nullable Properties attributes) { push(tagName, "", attributes); }
/** Put a XML start or empty tag to the XMLStringBuffer depending on hasChildElements parameter */ private boolean putElement(XMLStringBuffer xsb, String tagName, Properties attributes, boolean hasChildElements) { if (hasChildElements) { xsb.push(tagName, attributes); } else { xsb.addEmptyElement(tagName, attributes); } return hasChildElements; }
public void push(String tagName, String... attributes) { push(tagName, createProperties(attributes)); }
private void addParameter(XMLStringBuffer xmlBuffer, Object parameter, int i) { Properties attrs = new Properties(); attrs.setProperty(XMLReporterConfig.ATTR_INDEX, String.valueOf(i)); xmlBuffer.push(XMLReporterConfig.TAG_PARAM, attrs); if (parameter == null) { Properties valueAttrs = new Properties(); valueAttrs.setProperty(XMLReporterConfig.ATTR_IS_NULL, "true"); xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_PARAM_VALUE, valueAttrs); } else { xmlBuffer.push(XMLReporterConfig.TAG_PARAM_VALUE); xmlBuffer.addCDATA(parameter.toString()); xmlBuffer.pop(); } xmlBuffer.pop(); }
private void writeReporterOutput(XMLStringBuffer xmlBuffer) { // TODO: Cosmin - maybe a <line> element isn't indicated for each line xmlBuffer.push(XMLReporterConfig.TAG_REPORTER_OUTPUT); List<String> output = Reporter.getOutput(); for (String line : output) { if (line != null) { xmlBuffer.push(XMLReporterConfig.TAG_LINE); xmlBuffer.addCDATA(line); xmlBuffer.pop(); } } xmlBuffer.pop(); }
private void addTestResultOutput(XMLStringBuffer xmlBuffer, ITestResult testResult) { // TODO: Cosmin - maybe a <line> element isn't indicated for each line xmlBuffer.push(XMLReporterConfig.TAG_REPORTER_OUTPUT); List<String> output = Reporter.getOutput(testResult); for (String line : output) { if (line != null) { xmlBuffer.push(XMLReporterConfig.TAG_LINE); xmlBuffer.addCDATA(line); xmlBuffer.pop(); } } xmlBuffer.pop(); }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); boolean hasElements = hasElements(m_xmlDependencyGroups); if (hasElements) { xsb.push("dependencies"); } for (Map.Entry<String, String> entry : m_xmlDependencyGroups.entrySet()) { xsb.addEmptyElement("include", "name", entry.getKey(), "depends-on", entry.getValue()); } if (hasElements) { xsb.pop("dependencies"); } return xsb.toXML(); }
public void addTestMethodParams(XMLStringBuffer xmlBuffer, ITestResult testResult) { Object[] parameters = testResult.getParameters(); if ((parameters != null) && (parameters.length > 0)) { xmlBuffer.push(XMLReporterConfig.TAG_PARAMS); for (int i = 0; i < parameters.length; i++) { addParameter(xmlBuffer, parameters[i], i); } xmlBuffer.pop(); } }
@Override public void generate(XMLStringBuffer xsb) { for (ISuite s : getSuites()) { xsb.push(D, C, "panel", "panel-name", getPanelName(s)); xsb.push(D, C, "main-panel-header rounded-window-top"); xsb.addOptional(S, getHeader(s), C, "header-content"); xsb.pop(D); xsb.push(D, C, "main-panel-content rounded-window-bottom"); xsb.addString(getContent(s, xsb)); xsb.pop(D); xsb.pop(D); } }
private void writeSuiteToBuffer(XMLStringBuffer xmlBuffer, ISuite suite) { xmlBuffer.push(XMLReporterConfig.TAG_SUITE, getSuiteAttributes(suite)); writeSuiteGroups(xmlBuffer, suite); Map<String, ISuiteResult> results = suite.getResults(); XMLSuiteResultWriter suiteResultWriter = new XMLSuiteResultWriter(config); for (Map.Entry<String, ISuiteResult> result : results.entrySet()) { suiteResultWriter.writeSuiteResult(xmlBuffer, result.getValue()); } xmlBuffer.pop(); }
private synchronized void createElementFromIgnoredTests(XMLStringBuffer doc, ITestContext context) { Collection<ITestNGMethod> methods = context.getExcludedMethods(); for (ITestNGMethod method : methods) { Properties properties = getPropertiesFor(method, 0); doc.push(XMLConstants.TESTCASE,properties); doc.addEmptyElement(XMLConstants.ATTR_IGNORED); doc.pop(); } }
private void addLinkTo(XMLStringBuffer header, INavigatorPanel panel, ISuite suite) { String text = panel.getNavigatorLink(suite); header.push("li"); header.push("a", "href", "#", "panel-name", panel.getPanelName(suite), C, "navigator-link "); String className = panel.getClassName(); if (className != null) { header.addOptional(S, text, C, className); } else { header.addOptional(S, text); } header.pop("a"); header.pop("li"); }
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(); } }
@Override public String getContent(ISuite suite, XMLStringBuffer main) { XMLStringBuffer xsb = new XMLStringBuffer(main.getCurrentIndent()); xsb.push("ul"); for (XmlTest test : suite.getXmlSuite().getTests()) { xsb.push("li"); int count = test.getXmlClasses().size(); String name = test.getName() + " (" + pluralize(count, "class") + ")"; xsb.addRequired(S, name, C, "test-name"); xsb.pop("li"); } xsb.pop("ul"); return xsb.toXML(); }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); boolean hasElements = hasElements(m_includes); if (hasElements) { xsb.push("define", "name", m_name); } for (String s : m_includes) { xsb.addEmptyElement("include", "name", s); } if (hasElements) { xsb.pop("define"); } return xsb.toXML(); }
@Override public void generate(XMLStringBuffer xsb) { xsb.push(D, C, "top-banner-root"); xsb.addRequired(S, "Test results", C, "top-banner-title-font"); xsb.addEmptyElement("br"); int failedCount = getModel().getAllFailedResults().size(); String testResult = failedCount > 0 ? ", " + pluralize(failedCount, "failed test") : ""; String subTitle = pluralize(getModel().getSuites().size(), "suite") + testResult; xsb.addRequired(S, subTitle, C, "top-banner-font-1"); xsb.pop(D); }
private void addTestResult(XMLStringBuffer xmlBuffer, ITestResult testResult) { Properties attribs = getTestResultAttributes(testResult); attribs.setProperty(XMLReporterConfig.ATTR_STATUS, getStatusString(testResult.getStatus())); xmlBuffer.push(XMLReporterConfig.TAG_TEST_METHOD, attribs); addTestMethodParams(xmlBuffer, testResult); addTestResultException(xmlBuffer, testResult); addTestResultOutput(xmlBuffer, testResult); if (config.isGenerateTestResultAttributes()) { addTestResultAttributes(xmlBuffer, testResult); } xmlBuffer.pop(); }
@Override public String getContent(ISuite suite, XMLStringBuffer main) { XMLStringBuffer xsb = new XMLStringBuffer(main.getCurrentIndent()); xsb.push("pre"); xsb.addString(Utils.escapeHtml(suite.getXmlSuite().toXml())); xsb.pop("pre"); return xsb.toXML(); }