gpt4 book ai didi

org.testng.reporters.XMLStringBuffer.addCDATA()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 20:56:40 27 4
gpt4 key购买 nike

本文整理了Java中org.testng.reporters.XMLStringBuffer.addCDATA()方法的一些代码示例,展示了XMLStringBuffer.addCDATA()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLStringBuffer.addCDATA()方法的具体详情如下:
包路径:org.testng.reporters.XMLStringBuffer
类名称:XMLStringBuffer
方法名:addCDATA

XMLStringBuffer.addCDATA介绍

[英]Add a CDATA tag.
[中]添加一个CDATA标签。

代码示例

代码示例来源:origin: org.testng/testng

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();
}

代码示例来源:origin: org.testng/testng

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
 }
}

代码示例来源:origin: cbeust/testng

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();
}

代码示例来源:origin: cbeust/testng

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
 }
}

代码示例来源:origin: org.testng/testng

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();
 }
}

代码示例来源:origin: org.testng/testng

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();
 }
}

代码示例来源:origin: org.testng/testng

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();
}

代码示例来源:origin: org.testng/testng

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();
}

代码示例来源:origin: cbeust/testng

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();
 }
}

代码示例来源:origin: org.testng/testng

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();
}

代码示例来源:origin: cbeust/testng

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();
  }
 }
}

代码示例来源:origin: cbeust/testng

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();
}

代码示例来源:origin: cbeust/testng

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();
}

代码示例来源:origin: cbeust/testng

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();
}

代码示例来源:origin: org.testng/testng

xsb.addCDATA(testTag.stackTrace);
xsb.pop(testTag.childTag);

代码示例来源:origin: cbeust/testng

xsb.addCDATA(testTag.stackTrace);
xsb.pop(testTag.childTag);

代码示例来源:origin: org.infinispan/infinispan-commons-test

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
 }
}

代码示例来源:origin: com.hotels/heat-core-utils

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();
}

代码示例来源:origin: HotelsDotCom/heat

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();
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com