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 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 } }
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 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 } }
private void addTestResultException(XMLStringBuffer xmlBuffer, ITestResult testResult) { Throwable exception = testResult.getThrowable(); if (exception != null) { Properties exceptionAttrs = new Properties(); exceptionAttrs.setProperty(XMLReporterConfig.ATTR_CLASS, exception.getClass().getName()); xmlBuffer.push(XMLReporterConfig.TAG_EXCEPTION, exceptionAttrs); if (!Utils.isStringEmpty(exception.getMessage())) { xmlBuffer.push(XMLReporterConfig.TAG_MESSAGE); xmlBuffer.addCDATA(exception.getMessage()); xmlBuffer.pop(); } XMLReporterConfig.StackTraceLevels level = calculateStackTraceLevels(testResult); switch (level) { case SHORT: xmlBuffer.push(XMLReporterConfig.TAG_SHORT_STACKTRACE); xmlBuffer.addCDATA(Utils.shortStackTrace(exception, false)); xmlBuffer.pop(); break; case FULL: xmlBuffer.push(XMLReporterConfig.TAG_FULL_STACKTRACE); xmlBuffer.addCDATA(Utils.longStackTrace(exception, false)); xmlBuffer.pop(); break; default: //everything else is ignored for now. } xmlBuffer.pop(); } }
private void addTestResultAttributes(XMLStringBuffer xmlBuffer, ITestResult testResult) { if (testResult.getAttributeNames() != null && testResult.getAttributeNames().size() > 0) { xmlBuffer.push(XMLReporterConfig.TAG_ATTRIBUTES); for (String attrName: testResult.getAttributeNames()) { if (attrName == null) { continue; } Object attrValue = testResult.getAttribute(attrName); Properties attributeAttrs = new Properties(); attributeAttrs.setProperty(XMLReporterConfig.ATTR_NAME, attrName); if (attrValue == null) { attributeAttrs.setProperty(XMLReporterConfig.ATTR_IS_NULL, "true"); xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_ATTRIBUTE, attributeAttrs); } else { xmlBuffer.push(XMLReporterConfig.TAG_ATTRIBUTE, attributeAttrs); xmlBuffer.addCDATA(attrValue.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(); }
private void addTestResultException(XMLStringBuffer xmlBuffer, ITestResult testResult) { Throwable exception = testResult.getThrowable(); if (exception != null) { Properties exceptionAttrs = new Properties(); exceptionAttrs.setProperty(XMLReporterConfig.ATTR_CLASS, exception.getClass().getName()); xmlBuffer.push(XMLReporterConfig.TAG_EXCEPTION, exceptionAttrs); if (!Utils.isStringEmpty(exception.getMessage())) { xmlBuffer.push(XMLReporterConfig.TAG_MESSAGE); xmlBuffer.addCDATA(exception.getMessage()); xmlBuffer.pop(); } XMLReporterConfig.StackTraceLevels level = calculateStackTraceLevels(testResult); switch (level) { case SHORT: xmlBuffer.push(XMLReporterConfig.TAG_SHORT_STACKTRACE); xmlBuffer.addCDATA(Utils.shortStackTrace(exception, false)); xmlBuffer.pop(); break; case FULL: xmlBuffer.push(XMLReporterConfig.TAG_FULL_STACKTRACE); xmlBuffer.addCDATA(Utils.longStackTrace(exception, false)); xmlBuffer.pop(); break; default: // everything else is ignored for now. } xmlBuffer.pop(); } }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); xsb.push("method-selector"); if (null != m_className) { Properties clsProp = new Properties(); clsProp.setProperty("name", getClassName()); if(getPriority() != -1) { clsProp.setProperty("priority", String.valueOf(getPriority())); } xsb.addEmptyElement("selector-class", clsProp); } else if (getLanguage() != null) { Properties scriptProp = new Properties(); scriptProp.setProperty("language", getLanguage()); xsb.push("script", scriptProp); xsb.addCDATA(getExpression()); xsb.pop("script"); } else { throw new TestNGException("Invalid Method Selector: found neither class name nor language"); } xsb.pop("method-selector"); return xsb.toXML(); }
private void addTestResultAttributes(XMLStringBuffer xmlBuffer, ITestResult testResult) { if (testResult.getAttributeNames() != null && testResult.getAttributeNames().size() > 0) { xmlBuffer.push(XMLReporterConfig.TAG_ATTRIBUTES); for (String attrName : testResult.getAttributeNames()) { if (attrName == null) { continue; } Object attrValue = testResult.getAttribute(attrName); Properties attributeAttrs = new Properties(); attributeAttrs.setProperty(XMLReporterConfig.ATTR_NAME, attrName); if (attrValue == null) { attributeAttrs.setProperty(XMLReporterConfig.ATTR_IS_NULL, "true"); xmlBuffer.addEmptyElement(XMLReporterConfig.TAG_ATTRIBUTE, attributeAttrs); } else { xmlBuffer.push(XMLReporterConfig.TAG_ATTRIBUTE, attributeAttrs); xmlBuffer.addCDATA(attrValue.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); xsb.push("method-selector"); if (null != m_className) { Properties clsProp = new Properties(); clsProp.setProperty("name", getClassName()); if (getPriority() != -1) { clsProp.setProperty("priority", String.valueOf(getPriority())); } xsb.addEmptyElement("selector-class", clsProp); } else if (getScript() != null && getScript().getLanguage() != null) { Properties scriptProp = new Properties(); scriptProp.setProperty("language", getScript().getLanguage()); xsb.push("script", scriptProp); xsb.addCDATA(getScript().getExpression()); xsb.pop("script"); } else { throw new TestNGException("Invalid Method Selector: found neither class name nor language"); } xsb.pop("method-selector"); return xsb.toXML(); }
xsb.addCDATA(testTag.stackTrace); xsb.pop(testTag.childTag);
xsb.addCDATA(testTag.stackTrace); xsb.pop(testTag.childTag);
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.stackTrace(t, false)[0]); doc.pop(); } else { doc.addEmptyElement(XMLConstants.FAILURE); // THIS IS AN ERROR } }
private void setFailedTcAttribute(XMLStringBuffer doc, ITestResult failedTestCase) { Properties attributesFailedTestSuites = new Properties(); String tcName = ((HashMap<String, String>) failedTestCase.getParameters()[0]).get(PROP_TEST_ID); attributesFailedTestSuites.setProperty(XMLConstants.ATTR_NAME, tcName); long elapsedTimeMillis = failedTestCase.getEndMillis() - failedTestCase.getStartMillis(); testRunningTotalTime += elapsedTimeMillis; Throwable t = failedTestCase.getThrowable(); doc.push(XMLConstants.TESTCASE, attributesFailedTestSuites); if (t != null) { attributesFailedTestSuites.setProperty(XMLConstants.ATTR_TYPE, t.getClass().getName()); String message = t.getMessage(); if ((message != null) && (message.length() > 0)) { attributesFailedTestSuites.setProperty(XMLConstants.ATTR_MESSAGE, encodeAttr(message)); // ENCODE } doc.push(XMLConstants.FAILURE, attributesFailedTestSuites); doc.addCDATA(Utils.stackTrace(t, false)[0]); doc.pop(); } else { doc.addEmptyElement(XMLConstants.FAILURE); // THIS IS AN ERROR } doc.pop(); }
private void setFailedTcAttribute(XMLStringBuffer doc, ITestResult failedTestCase) { Properties attributesFailedTestSuites = new Properties(); String tcName = ((HashMap<String, String>) failedTestCase.getParameters()[0]).get(PROP_TEST_ID); attributesFailedTestSuites.setProperty(XMLConstants.ATTR_NAME, tcName); long elapsedTimeMillis = failedTestCase.getEndMillis() - failedTestCase.getStartMillis(); testRunningTotalTime += elapsedTimeMillis; Throwable t = failedTestCase.getThrowable(); doc.push(XMLConstants.TESTCASE, attributesFailedTestSuites); if (t != null) { attributesFailedTestSuites.setProperty(XMLConstants.ATTR_TYPE, t.getClass().getName()); String message = t.getMessage(); if ((message != null) && (message.length() > 0)) { attributesFailedTestSuites.setProperty(XMLConstants.ATTR_MESSAGE, encodeAttr(message)); // ENCODE } doc.push(XMLConstants.FAILURE, attributesFailedTestSuites); doc.addCDATA(Utils.stackTrace(t, false)[0]); doc.pop(); } else { doc.addEmptyElement(XMLConstants.FAILURE); // THIS IS AN ERROR } doc.pop(); }