Tabnine Logo
XMLStringBuffer.addCDATA
Code IndexAdd Tabnine to your IDE (free)

How to use
addCDATA
method
in
org.testng.reporters.XMLStringBuffer

Best Java code snippets using org.testng.reporters.XMLStringBuffer.addCDATA (Showing top 19 results out of 315)

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();
}
org.testng.reportersXMLStringBufferaddCDATA

Javadoc

Add a CDATA tag.

Popular methods of XMLStringBuffer

  • <init>
  • pop
    Pop the last pushed element and throws an AssertionError if it doesn't match the corresponding tag t
  • push
  • addEmptyElement
  • toXML
  • addComment
  • addOptional
  • addRequired
  • getStringBuffer
  • setDocType
    Set the doctype for this document.
  • addString
  • createProperties
  • addString,
  • createProperties,
  • getCurrentIndent,
  • init,
  • setDefaultComment,
  • setXmlDetails,
  • toWriter

Popular in Java

  • Finding current android device location
  • requestLocationUpdates (LocationManager)
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • JCheckBox (javax.swing)
  • JFrame (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now