Package org.glassfish.pfl.test
Class XMLJUnitReportWriter
- java.lang.Object
-
- org.glassfish.pfl.test.XMLJUnitReportWriter
-
- All Implemented Interfaces:
JUnitReportWriter,XMLConstants
public class XMLJUnitReportWriter extends java.lang.Object implements JUnitReportWriter, XMLConstants
Prints XML output of the test to a specified Writer.- See Also:
- "FormatterElement"
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.pfl.test.JUnitReportWriter
JUnitReportWriter.TestCounts, JUnitReportWriter.TestDescription
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]DEFAULT_TRACE_FILTERSprivate org.w3c.dom.DocumentdocThe XML document.private interrorCountprivate java.util.Set<JUnitReportWriter.TestDescription>failedTeststests that failed.private intfailureCountprivate booleanfilterTraceprivate java.io.OutputStreamoutWhere to write the log to.private org.w3c.dom.ElementrootElementThe wrapper for the whole testsuite.private intrunCountprivate longstartTimeprivate java.util.Map<JUnitReportWriter.TestDescription,org.w3c.dom.Element>testElementsElement for the current test.private java.util.Map<JUnitReportWriter.TestDescription,java.lang.Long>testStartsTiming helper.private static java.lang.StringUNKNOWNconstant for unnnamed testsuites/cases-
Fields inherited from interface org.glassfish.pfl.test.XMLConstants
ATTR_CLASSNAME, ATTR_ERRORS, ATTR_FAILURES, ATTR_ID, ATTR_MESSAGE, ATTR_NAME, ATTR_PACKAGE, ATTR_TESTS, ATTR_TIME, ATTR_TYPE, ATTR_VALUE, ERROR, FAILURE, HOSTNAME, PROPERTIES, PROPERTY, SYSTEM_ERR, SYSTEM_OUT, TESTCASE, TESTSUITE, TESTSUITES, TIMESTAMP
-
-
Constructor Summary
Constructors Constructor Description XMLJUnitReportWriter()No arg constructor.XMLJUnitReportWriter(boolean filter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddError(JUnitReportWriter.TestDescription test, java.lang.Throwable t)An error occurred.voidaddFailure(JUnitReportWriter.TestDescription test, java.lang.Throwable t)A failure occurred.voidendTest(JUnitReportWriter.TestDescription test)A test ended.voidendTest(JUnitReportWriter.TestDescription test, long duration)A test ended.org.w3c.dom.ElementendTestHelper(JUnitReportWriter.TestDescription test)JUnitReportWriter.TestCountsendTestSuite()The whole testsuite ended.private booleanfilterLine(java.lang.String line)private java.lang.StringfilterStack(java.lang.String stack)private voidformatError(java.lang.String type, JUnitReportWriter.TestDescription test, java.lang.Throwable t)private voidformatOutput(java.lang.String type, java.lang.String output)private static javax.xml.parsers.DocumentBuildergetDocumentBuilder()private java.lang.StringgetFilteredTrace(java.lang.Throwable t)private java.lang.StringgetHostname()private java.lang.StringgetStackTrace(java.lang.Throwable t)voidsetOutput(java.io.OutputStream out)Sets the stream the formatter is supposed to write its results to.voidsetSystemError(java.lang.String out)This is what the test has written to System.errvoidsetSystemOutput(java.lang.String out)This is what the test has written to System.outvoidstartTest(JUnitReportWriter.TestDescription t)A test started.voidstartTestSuite(java.lang.String name, java.util.Properties props)The whole testsuite started.
-
-
-
Field Detail
-
UNKNOWN
private static final java.lang.String UNKNOWN
constant for unnnamed testsuites/cases- See Also:
- Constant Field Values
-
doc
private org.w3c.dom.Document doc
The XML document.
-
rootElement
private org.w3c.dom.Element rootElement
The wrapper for the whole testsuite.
-
testElements
private java.util.Map<JUnitReportWriter.TestDescription,org.w3c.dom.Element> testElements
Element for the current test.
-
failedTests
private java.util.Set<JUnitReportWriter.TestDescription> failedTests
tests that failed.
-
testStarts
private java.util.Map<JUnitReportWriter.TestDescription,java.lang.Long> testStarts
Timing helper.
-
out
private java.io.OutputStream out
Where to write the log to.
-
filterTrace
private boolean filterTrace
-
runCount
private int runCount
-
failureCount
private int failureCount
-
errorCount
private int errorCount
-
startTime
private long startTime
-
DEFAULT_TRACE_FILTERS
private static final java.lang.String[] DEFAULT_TRACE_FILTERS
-
-
Method Detail
-
getDocumentBuilder
private static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
-
setOutput
public void setOutput(java.io.OutputStream out)
Description copied from interface:JUnitReportWriterSets the stream the formatter is supposed to write its results to.- Specified by:
setOutputin interfaceJUnitReportWriter- Parameters:
out- the output stream to use.
-
setSystemOutput
public void setSystemOutput(java.lang.String out)
Description copied from interface:JUnitReportWriterThis is what the test has written to System.out- Specified by:
setSystemOutputin interfaceJUnitReportWriter- Parameters:
out- the string to write.
-
setSystemError
public void setSystemError(java.lang.String out)
Description copied from interface:JUnitReportWriterThis is what the test has written to System.err- Specified by:
setSystemErrorin interfaceJUnitReportWriter- Parameters:
out- the string to write.
-
startTestSuite
public void startTestSuite(java.lang.String name, java.util.Properties props)Description copied from interface:JUnitReportWriterThe whole testsuite started.- Specified by:
startTestSuitein interfaceJUnitReportWriter- Parameters:
name- the suite.
-
getHostname
private java.lang.String getHostname()
-
endTestSuite
public JUnitReportWriter.TestCounts endTestSuite()
Description copied from interface:JUnitReportWriterThe whole testsuite ended.- Specified by:
endTestSuitein interfaceJUnitReportWriter
-
startTest
public void startTest(JUnitReportWriter.TestDescription t)
Description copied from interface:JUnitReportWriterA test started.- Specified by:
startTestin interfaceJUnitReportWriter
-
endTest
public void endTest(JUnitReportWriter.TestDescription test, long duration)
Description copied from interface:JUnitReportWriterA test ended. Here we supply the duration, in case the duration is not determined by the [ startTest, endTest ] interval.- Specified by:
endTestin interfaceJUnitReportWriter
-
endTest
public void endTest(JUnitReportWriter.TestDescription test)
Description copied from interface:JUnitReportWriterA test ended.- Specified by:
endTestin interfaceJUnitReportWriter
-
endTestHelper
public org.w3c.dom.Element endTestHelper(JUnitReportWriter.TestDescription test)
-
addFailure
public void addFailure(JUnitReportWriter.TestDescription test, java.lang.Throwable t)
Description copied from interface:JUnitReportWriterA failure occurred.- Specified by:
addFailurein interfaceJUnitReportWriter
-
addError
public void addError(JUnitReportWriter.TestDescription test, java.lang.Throwable t)
Description copied from interface:JUnitReportWriterAn error occurred.- Specified by:
addErrorin interfaceJUnitReportWriter
-
formatError
private void formatError(java.lang.String type, JUnitReportWriter.TestDescription test, java.lang.Throwable t)
-
formatOutput
private void formatOutput(java.lang.String type, java.lang.String output)
-
getStackTrace
private java.lang.String getStackTrace(java.lang.Throwable t)
-
getFilteredTrace
private java.lang.String getFilteredTrace(java.lang.Throwable t)
-
filterStack
private java.lang.String filterStack(java.lang.String stack)
-
filterLine
private boolean filterLine(java.lang.String line)
-
-