Top Description Inners Fields Constructors Methods
org.junit.platform.reporting.legacy.xml

pack-priv Class XmlReportWriter

extends Object
Class Inheritance
Static Imports
java.text.MessageFormat.format, java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME, java.util.Collections.emptyList, .Comparator.naturalOrder, java.util.function.Function.identity, java.util.stream.Collectors.counting, .Collectors.groupingBy, .Collectors.mapping, .Collectors.toList, .Collectors.toMap, org.junit.platform.commons.util.ExceptionUtils.readStackTrace, .StringUtils.isNotBlank, org.junit.platform.engine.TestExecutionResult.Status.FAILED, org.junit.platform.launcher.LauncherConstants.STDERR_REPORT_ENTRY_KEY, .LauncherConstants.STDOUT_REPORT_ENTRY_KEY, org.junit.platform.reporting.legacy.xml.XmlReportWriter.AggregatedTestResult.Type.ERROR, .XmlReportWriter.AggregatedTestResult.Type.FAILURE, .XmlReportWriter.AggregatedTestResult.Type.SKIPPED, .XmlReportWriter.AggregatedTestResult.Type.SUCCESS

XmlReportWriter writes an XML report whose format is compatible with the de facto standard for JUnit 4 based test reports that was made popular by the Ant build system.
Since
1.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
private static class
private class

Field Summary

Modifier and TypeField and Description
private static final Pattern
pack-priv static final char
private static final Map<Character, String>
private final XmlReportData

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static boolean
isAllowedXmlCharacter(int codePoint)

pack-priv static String
private boolean
shouldInclude(TestPlan testPlan, TestIdentifier testIdentifier)

private XmlReportWriter.AggregatedTestResult
pack-priv void
writeXmlReport(TestIdentifier rootDescriptor, Writer out)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CDATA_SPLIT_PATTERNback to summary
private static final Pattern CDATA_SPLIT_PATTERN
ILLEGAL_CHARACTER_REPLACEMENTback to summary
pack-priv static final char ILLEGAL_CHARACTER_REPLACEMENT
REPLACEMENTS_IN_ATTRIBUTE_VALUESback to summary
private static final Map<Character, String> REPLACEMENTS_IN_ATTRIBUTE_VALUES
reportDataback to summary
private final XmlReportData reportData

Constructor Detail

XmlReportWriterback to summary
pack-priv XmlReportWriter(XmlReportData reportData)

Method Detail

isAllowedXmlCharacterback to summary
pack-priv static boolean isAllowedXmlCharacter(int codePoint)
replaceIllegalCharactersback to summary
pack-priv static String replaceIllegalCharacters(String text)
shouldIncludeback to summary
private boolean shouldInclude(TestPlan testPlan, TestIdentifier testIdentifier)
toAggregatedResultback to summary
private XmlReportWriter.AggregatedTestResult toAggregatedResult(TestIdentifier testIdentifier)
writeXmlReportback to summary
pack-priv void writeXmlReport(TestIdentifier rootDescriptor, Writer out) throws XMLStreamException
writeXmlReportback to summary
private void writeXmlReport(TestIdentifier testIdentifier, Map<TestIdentifier, XmlReportWriter.AggregatedTestResult> tests, Writer out) throws XMLStreamException
org.junit.platform.reporting.legacy.xml back to summary

pack-priv Class XmlReportWriter.AggregatedTestResult

extends Object
Class Inheritance
  • java.lang.Object
  • org.junit.platform.reporting.legacy.xml.XmlReportWriter.AggregatedTestResult

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
private final List<TestExecutionResult>
private static final XmlReportWriter.AggregatedTestResult
private final XmlReportWriter.AggregatedTestResult.Type

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Map<XmlReportWriter.AggregatedTestResult.Type, List<Optional<Throwable>>>
public static XmlReportWriter.AggregatedTestResult
nonSkipped(List<TestExecutionResult> executionResults)

public static XmlReportWriter.AggregatedTestResult
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executionResultsback to summary
private final List<TestExecutionResult> executionResults
SKIPPED_RESULTback to summary
private static final XmlReportWriter.AggregatedTestResult SKIPPED_RESULT
typeback to summary
private final XmlReportWriter.AggregatedTestResult.Type type

Constructor Detail

AggregatedTestResultback to summary
private AggregatedTestResult(XmlReportWriter.AggregatedTestResult.Type type, List<TestExecutionResult> executionResults)

Method Detail

getThrowablesByTypeback to summary
public Map<XmlReportWriter.AggregatedTestResult.Type, List<Optional<Throwable>>> getThrowablesByType()
nonSkippedback to summary
public static XmlReportWriter.AggregatedTestResult nonSkipped(List<TestExecutionResult> executionResults)
skippedback to summary
public static XmlReportWriter.AggregatedTestResult skipped()
org.junit.platform.reporting.legacy.xml back to summary

pack-priv final Enum XmlReportWriter.AggregatedTestResult.Type

extends Enum<XmlReportWriter.AggregatedTestResult.Type>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final XmlReportWriter.AggregatedTestResult.Type
public static final XmlReportWriter.AggregatedTestResult.Type
public static final XmlReportWriter.AggregatedTestResult.Type
public static final XmlReportWriter.AggregatedTestResult.Type

Constructor Summary

AccessConstructor and Description
private
Type()

Field Detail

ERRORback to summary
public static final XmlReportWriter.AggregatedTestResult.Type ERROR
FAILUREback to summary
public static final XmlReportWriter.AggregatedTestResult.Type FAILURE
SKIPPEDback to summary
public static final XmlReportWriter.AggregatedTestResult.Type SKIPPED
SUCCESSback to summary
public static final XmlReportWriter.AggregatedTestResult.Type SUCCESS

Constructor Detail

Typeback to summary
private Type()

Method Detail

fromback to summary
private static XmlReportWriter.AggregatedTestResult.Type from(TestExecutionResult executionResult)
isFailureback to summary
private static boolean isFailure(TestExecutionResult result)
valueOfback to summary
public static XmlReportWriter.AggregatedTestResult.Type valueOf(String name)
valuesback to summary
public static XmlReportWriter.AggregatedTestResult.Type[] values()
org.junit.platform.reporting.legacy.xml back to summary

private Class XmlReportWriter.ReplacingWriter

extends Writer
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Writer
private boolean
Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Writer
append(CharSequence csq)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends the specified character sequence to this writer.

public Writer
append(CharSequence csq, int start, int end)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this writer.

public Writer
append(char c)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends the specified character to this writer.

public void
close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closes the stream, flushing it first.

public void
flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushes the stream.

pack-priv void
setWhitespaceReplacingEnabled(boolean whitespaceReplacingEnabled)

public void
write(char[] cbuf, int off, int len)

Implements abstract java.io.Writer.write.

Writes a portion of an array of characters.

public void
write(int c)

Overrides java.io.Writer.write.

Writes a single character.

public void
write(char[] cbuf)

Overrides java.io.Writer.write.

Writes an array of characters.

public void
write(String str)

Overrides java.io.Writer.write.

Writes a string.

public void
write(String str, int off, int len)

Overrides java.io.Writer.write.

Writes a portion of a string.

Inherited from java.io.Writer:
nullWriter

Field Detail

delegateback to summary
private final Writer delegate
whitespaceReplacingEnabledback to summary
private boolean whitespaceReplacingEnabled

Constructor Detail

ReplacingWriterback to summary
pack-priv ReplacingWriter(Writer delegate)

Method Detail

appendback to summary
public Writer append(CharSequence csq) throws IOException

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Doc from java.io.Writer.append.

Appends the specified character sequence to this writer.

An invocation of this method of the form out.append(csq) when csq is not null, behaves in exactly the same way as the invocation

out.write(csq.toString())
out.write(csq.toString())

Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. For instance, invoking the toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
appendback to summary
public Writer append(CharSequence csq, int start, int end) throws IOException

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Doc from java.io.Writer.append.

Appends a subsequence of the specified character sequence to this writer.

An invocation of this method of the form out.append(csq, start, end) when csq is not null behaves in exactly the same way as the invocation

out.write(csq.subSequence(start, end).toString())
out.write(csq.subSequence(start, end).toString())
Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
appendback to summary
public Writer append(char c) throws IOException

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Doc from java.io.Writer.append.

Appends the specified character to this writer.

An invocation of this method of the form out.append(c) behaves in exactly the same way as the invocation

out.write(c)
out.write(c)
Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
closeback to summary
public void close() throws IOException

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Doc from java.io.Writer.close.

Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
flushback to summary
public void flush() throws IOException

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Doc from java.io.Writer.flush.

Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
setWhitespaceReplacingEnabledback to summary
pack-priv void setWhitespaceReplacingEnabled(boolean whitespaceReplacingEnabled)
writeback to summary
public void write(char[] cbuf, int off, int len) throws IOException

Implements abstract java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a portion of an array of characters.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(int c) throws IOException

Overrides java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored.

Subclasses that intend to support efficient single-character output should override this method.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(char[] cbuf) throws IOException

Overrides java.io.Writer.write.

Doc from java.io.Writer.write.

Writes an array of characters.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(String str) throws IOException

Overrides java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a string.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(String str, int off, int len) throws IOException

Overrides java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a portion of a string.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
org.junit.platform.reporting.legacy.xml back to summary

private Class XmlReportWriter.XmlReport

extends Object
implements AutoCloseable
Class Inheritance
  • java.lang.Object
  • org.junit.platform.reporting.legacy.xml.XmlReportWriter.XmlReport
All Implemented Interfaces
java.lang.AutoCloseable

Field Summary

Modifier and TypeField and Description
private final XmlReportWriter.ReplacingWriter
private final XMLStreamWriter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
buildReportEntryDescription(LocalDateTime timestamp, Map<String, String> keyValuePairs, int entryNumber, StringBuilder result)

public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

private void
collectReportEntries(TestIdentifier testIdentifier, List<String> systemOutElements, List<String> systemErrElements)

private String
private String
getClassName(TestIdentifier testIdentifier)

private LocalDateTime
private Optional<String>
private String
getName(TestIdentifier testIdentifier)

private String
getTime(TestIdentifier testIdentifier, NumberFormat numberFormat)

private void
private void
pack-priv void
private void
private void
private void
private void
private void
writeOutputElement(String elementName, String content)

private void
writeOutputElements(String elementName, List<String> elements)

private void
private void
private void
private void
private void
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

outback to summary
private final XmlReportWriter.ReplacingWriter out
xmlback to summary
private final XMLStreamWriter xml

Constructor Detail

XmlReportback to summary
pack-priv XmlReport(Writer out) throws XMLStreamException

Method Detail

buildReportEntryDescriptionback to summary
private void buildReportEntryDescription(LocalDateTime timestamp, Map<String, String> keyValuePairs, int entryNumber, StringBuilder result)
closeback to summary
public void close() throws XMLStreamException

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
collectReportEntriesback to summary
private void collectReportEntries(TestIdentifier testIdentifier, List<String> systemOutElements, List<String> systemErrElements)
formatNonStandardAttributesAsStringback to summary
private String formatNonStandardAttributesAsString(TestIdentifier testIdentifier)
getClassNameback to summary
private String getClassName(TestIdentifier testIdentifier)
getCurrentDateTimeback to summary
private LocalDateTime getCurrentDateTime()
getHostnameback to summary
private Optional<String> getHostname()
getNameback to summary
private String getName(TestIdentifier testIdentifier)
getTimeback to summary
private String getTime(TestIdentifier testIdentifier, NumberFormat numberFormat)
newLineback to summary
private void newLine() throws XMLStreamException
removeIfPresentAndAddAsSeparateElementback to summary
private void removeIfPresentAndAddAsSeparateElement(Map<String, String> keyValuePairs, String key, List<String> elements)
writeback to summary
pack-priv void write(TestIdentifier testIdentifier, Map<TestIdentifier, XmlReportWriter.AggregatedTestResult> tests) throws XMLStreamException
writeAttributeSafelyback to summary
private void writeAttributeSafely(String name, String value) throws XMLStreamException
writeCDataSafelyback to summary
private void writeCDataSafely(String data) throws XMLStreamException
writeErrorOrFailureElementback to summary
private void writeErrorOrFailureElement(XmlReportWriter.AggregatedTestResult.Type type, @Nullable Throwable throwable, XMLStreamWriter writer) throws XMLStreamException
writeFailureAttributesAndContentback to summary
private void writeFailureAttributesAndContent(Throwable throwable) throws XMLStreamException
writeOutputElementback to summary
private void writeOutputElement(String elementName, String content) throws XMLStreamException
writeOutputElementsback to summary
private void writeOutputElements(String elementName, List<String> elements) throws XMLStreamException
writeSkippedElementback to summary
private void writeSkippedElement(@Nullable String reason, XMLStreamWriter writer) throws XMLStreamException
writeSkippedOrErrorOrFailureElementback to summary
private void writeSkippedOrErrorOrFailureElement(TestIdentifier testIdentifier, XmlReportWriter.AggregatedTestResult testResult) throws XMLStreamException
writeSuiteAttributesback to summary
private void writeSuiteAttributes(TestIdentifier testIdentifier, Collection<XmlReportWriter.AggregatedTestResult> testResults, NumberFormat numberFormat) throws XMLStreamException
writeSystemPropertiesback to summary
private void writeSystemProperties() throws XMLStreamException
writeTestcaseback to summary
private void writeTestcase(TestIdentifier testIdentifier, XmlReportWriter.AggregatedTestResult testResult, NumberFormat numberFormat) throws XMLStreamException
writeTestCountsback to summary
private void writeTestCounts(Collection<XmlReportWriter.AggregatedTestResult> testResults) throws XMLStreamException
writeTestsuiteback to summary
private void writeTestsuite(TestIdentifier testIdentifier, Map<TestIdentifier, XmlReportWriter.AggregatedTestResult> tests) throws XMLStreamException