/** * Add an empty element tag (e.g. <foo/>) * * @param tagName The name of the tag * */ public void addEmptyElement(String tagName) { addEmptyElement(tagName, (Properties) null); }
private void createSkipElement(XMLStringBuffer doc) { doc.addEmptyElement(XMLConstants.SKIPPED); }
public static void dumpParameters(XMLStringBuffer xsb, Map<String, String> parameters) { // parameters if (!parameters.isEmpty()) { for(Map.Entry<String, String> para: parameters.entrySet()) { Properties paramProps= new Properties(); paramProps.setProperty("name", para.getKey()); paramProps.setProperty("value", para.getValue()); xsb.addEmptyElement("parameter", paramProps); // BUGFIX: TESTNG-27 } } }
/** 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 addEmptyElement(String tagName, String... attributes) { addEmptyElement(tagName, createProperties(attributes)); }
private File referenceSuite(XMLStringBuffer xmlBuffer, ISuite suite) { String relativePath = suite.getName() + File.separatorChar + FILE_NAME; File suiteFile = new File(config.getOutputDirectory(), relativePath); Properties attrs = new Properties(); attrs.setProperty(XMLReporterConfig.ATTR_URL, relativePath); xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_SUITE, attrs); return suiteFile; }
/** 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; }
private File referenceSuiteResult(XMLStringBuffer xmlBuffer, String parentDir, ISuiteResult suiteResult) { Properties attrs = new Properties(); String suiteResultName = suiteResult.getTestContext().getName() + ".xml"; attrs.setProperty(XMLReporterConfig.ATTR_URL, suiteResultName); xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_TEST, attrs); return new File(parentDir + File.separatorChar + suiteResultName); }
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 File referenceSuite(XMLStringBuffer xmlBuffer, ISuite suite) { String relativePath = suite.getName() + File.separatorChar + fileName(); File suiteFile = new File(config.getOutputDirectory(), relativePath); Properties attrs = new Properties(); attrs.setProperty(XMLReporterConfig.ATTR_URL, relativePath); xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_SUITE, attrs); return suiteFile; }
private void writeSuiteGroups(XMLStringBuffer xmlBuffer, ISuite suite) { xmlBuffer.push(XMLReporterConfig.TAG_GROUPS); Map<String, Collection<ITestNGMethod>> methodsByGroups = suite.getMethodsByGroups(); for (Map.Entry<String, Collection<ITestNGMethod>> entry : methodsByGroups.entrySet()) { Properties groupAttrs = new Properties(); groupAttrs.setProperty(XMLReporterConfig.ATTR_NAME, entry.getKey()); xmlBuffer.push(XMLReporterConfig.TAG_GROUP, groupAttrs); Set<ITestNGMethod> groupMethods = getUniqueMethodSet(entry.getValue()); for (ITestNGMethod groupMethod : groupMethods) { Properties methodAttrs = new Properties(); methodAttrs.setProperty(XMLReporterConfig.ATTR_NAME, groupMethod.getMethodName()); methodAttrs.setProperty(XMLReporterConfig.ATTR_METHOD_SIG, groupMethod.toString()); methodAttrs.setProperty(XMLReporterConfig.ATTR_CLASS, groupMethod.getRealClass().getName()); xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_METHOD, methodAttrs); } xmlBuffer.pop(); } xmlBuffer.pop(); }
private void createFailureElement(XMLStringBuffer doc, ITestResult tr) { Properties attrs= new Properties(); Throwable t= tr.getThrowable(); if(t != null) { attrs.setProperty(XMLConstants.ATTR_TYPE, t.getClass().getName()); String message= t.getMessage(); if((message != null) && (message.length() > 0)) { attrs.setProperty(XMLConstants.ATTR_MESSAGE, encodeAttr(message)); // ENCODE } doc.push(XMLConstants.FAILURE, attrs); doc.addCDATA(Utils.shortStackTrace(t, false)); doc.pop(); } else { doc.addEmptyElement(XMLConstants.FAILURE); // THIS IS AN ERROR } }
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 String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); Properties p = new Properties(); p.setProperty("name", getName()); List<Integer> invocationNumbers = getInvocationNumbers(); if (invocationNumbers != null && invocationNumbers.size() > 0) { p.setProperty("invocation-numbers", XmlClass.listToString(invocationNumbers).toString()); } if (!m_parameters.isEmpty()){ xsb.push("include", p); XmlUtils.dumpParameters(xsb, m_parameters); xsb.pop("include"); } else { xsb.addEmptyElement("include", p); } return xsb.toXML(); }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); boolean hasElements = hasElements(m_excludes) || hasElements(m_includes); if (hasElements) { xsb.push("run"); } for (String s : m_includes) { xsb.addEmptyElement("include", "name", s); } for (String s : m_excludes) { xsb.addEmptyElement("exclude", "name", s); } if (hasElements) { xsb.pop("run"); } return xsb.toXML(); }
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(); } }
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 generateClassPanel(Class c, List<ITestResult> results, XMLStringBuffer xsb, String status, ISuite suite) { xsb.push(D, C, "suite-" + suiteToTag(suite) + "-class-" + status); xsb.push(D, C, "main-panel-header rounded-window-top"); // Passed/failed icon xsb.addEmptyElement("img", "src", Model.getImage(status)); xsb.addOptional(S, c.getName(), C, "class-name"); xsb.pop(D); xsb.push(D, C, "main-panel-content rounded-window-bottom"); for (ITestResult tr : results) { generateMethod(tr, xsb); } xsb.pop(D); xsb.pop(D); }
@Override public String getContent(ISuite suite, XMLStringBuffer main) { XMLStringBuffer xsb = new XMLStringBuffer(main.getCurrentIndent()); SetMultiMap<Class<?>, ITestNGMethod> map = Maps.newSetMultiMap(); for (ITestNGMethod method : suite.getExcludedMethods()) { map.put(method.getTestClass().getRealClass(), method); } for (Class<?> c : map.keySet()) { xsb.push(D, C, "ignored-class-div"); xsb.addRequired(S, c.getName(), C, "ignored-class-name"); xsb.push(D, C, "ignored-methods-div"); for (ITestNGMethod m : map.get(c)) { xsb.addRequired(S, m.getMethodName(), C, "ignored-method-name"); xsb.addEmptyElement("br"); } xsb.pop(D); xsb.pop(D); } return xsb.toXML(); }