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_FILTERS
private org.w3c.dom.Document
doc
The XML document.private int
errorCount
private java.util.Set<JUnitReportWriter.TestDescription>
failedTests
tests that failed.private int
failureCount
private boolean
filterTrace
private java.io.OutputStream
out
Where to write the log to.private org.w3c.dom.Element
rootElement
The wrapper for the whole testsuite.private int
runCount
private long
startTime
private java.util.Map<JUnitReportWriter.TestDescription,org.w3c.dom.Element>
testElements
Element for the current test.private java.util.Map<JUnitReportWriter.TestDescription,java.lang.Long>
testStarts
Timing helper.private static java.lang.String
UNKNOWN
constant 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 void
addError(JUnitReportWriter.TestDescription test, java.lang.Throwable t)
An error occurred.void
addFailure(JUnitReportWriter.TestDescription test, java.lang.Throwable t)
A failure occurred.void
endTest(JUnitReportWriter.TestDescription test)
A test ended.void
endTest(JUnitReportWriter.TestDescription test, long duration)
A test ended.org.w3c.dom.Element
endTestHelper(JUnitReportWriter.TestDescription test)
JUnitReportWriter.TestCounts
endTestSuite()
The whole testsuite ended.private boolean
filterLine(java.lang.String line)
private java.lang.String
filterStack(java.lang.String stack)
private void
formatError(java.lang.String type, JUnitReportWriter.TestDescription test, java.lang.Throwable t)
private void
formatOutput(java.lang.String type, java.lang.String output)
private static javax.xml.parsers.DocumentBuilder
getDocumentBuilder()
private java.lang.String
getFilteredTrace(java.lang.Throwable t)
private java.lang.String
getHostname()
private java.lang.String
getStackTrace(java.lang.Throwable t)
void
setOutput(java.io.OutputStream out)
Sets the stream the formatter is supposed to write its results to.void
setSystemError(java.lang.String out)
This is what the test has written to System.errvoid
setSystemOutput(java.lang.String out)
This is what the test has written to System.outvoid
startTest(JUnitReportWriter.TestDescription t)
A test started.void
startTestSuite(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:JUnitReportWriter
Sets the stream the formatter is supposed to write its results to.- Specified by:
setOutput
in interfaceJUnitReportWriter
- Parameters:
out
- the output stream to use.
-
setSystemOutput
public void setSystemOutput(java.lang.String out)
Description copied from interface:JUnitReportWriter
This is what the test has written to System.out- Specified by:
setSystemOutput
in interfaceJUnitReportWriter
- Parameters:
out
- the string to write.
-
setSystemError
public void setSystemError(java.lang.String out)
Description copied from interface:JUnitReportWriter
This is what the test has written to System.err- Specified by:
setSystemError
in interfaceJUnitReportWriter
- Parameters:
out
- the string to write.
-
startTestSuite
public void startTestSuite(java.lang.String name, java.util.Properties props)
Description copied from interface:JUnitReportWriter
The whole testsuite started.- Specified by:
startTestSuite
in interfaceJUnitReportWriter
- Parameters:
name
- the suite.
-
getHostname
private java.lang.String getHostname()
-
endTestSuite
public JUnitReportWriter.TestCounts endTestSuite()
Description copied from interface:JUnitReportWriter
The whole testsuite ended.- Specified by:
endTestSuite
in interfaceJUnitReportWriter
-
startTest
public void startTest(JUnitReportWriter.TestDescription t)
Description copied from interface:JUnitReportWriter
A test started.- Specified by:
startTest
in interfaceJUnitReportWriter
-
endTest
public void endTest(JUnitReportWriter.TestDescription test, long duration)
Description copied from interface:JUnitReportWriter
A test ended. Here we supply the duration, in case the duration is not determined by the [ startTest, endTest ] interval.- Specified by:
endTest
in interfaceJUnitReportWriter
-
endTest
public void endTest(JUnitReportWriter.TestDescription test)
Description copied from interface:JUnitReportWriter
A test ended.- Specified by:
endTest
in 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:JUnitReportWriter
A failure occurred.- Specified by:
addFailure
in interfaceJUnitReportWriter
-
addError
public void addError(JUnitReportWriter.TestDescription test, java.lang.Throwable t)
Description copied from interface:JUnitReportWriter
An error occurred.- Specified by:
addError
in 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)
-
-