Package org.apache.maven.surefire.booter
Class ForkingRunListener
- java.lang.Object
-
- org.apache.maven.surefire.booter.ForkingRunListener
-
- All Implemented Interfaces:
ConsoleLogger,ConsoleOutputReceiver,ConsoleStream,RunListener
public class ForkingRunListener extends java.lang.Object implements RunListener, ConsoleLogger, ConsoleOutputReceiver, ConsoleStream
Encodes the full output of the test run to the stdout stream.
This class and the ForkClient contain the full definition of the "wire-level" protocol used by the forked process. The protocol is *not* part of any public api and may change without further notice.
This class is threadsafe.
The synchronization in the underlying PrintStream (target instance) is used to preserve thread safety of the output stream. To perform multiple writes/prints for a single request, they must synchronize on "target" variable in this class.
-
-
Field Summary
Fields Modifier and Type Field Description static byteBOOTERCODE_BYEstatic byteBOOTERCODE_CONSOLEINFO loggerstatic byteBOOTERCODE_DEBUGDEBUG loggerstatic byteBOOTERCODE_ERRORERROR loggerstatic byteBOOTERCODE_NEXT_TESTstatic byteBOOTERCODE_STDERRstatic byteBOOTERCODE_STDOUTstatic byteBOOTERCODE_STOP_ON_NEXT_TESTstatic byteBOOTERCODE_SYSPROPSstatic byteBOOTERCODE_TEST_ASSUMPTIONFAILUREstatic byteBOOTERCODE_TEST_ERRORstatic byteBOOTERCODE_TEST_FAILEDstatic byteBOOTERCODE_TEST_SKIPPEDstatic byteBOOTERCODE_TEST_STARTINGstatic byteBOOTERCODE_TEST_SUCCEEDEDstatic byteBOOTERCODE_TESTSET_COMPLETEDstatic byteBOOTERCODE_TESTSET_STARTINGstatic byteBOOTERCODE_WARNINGWARNING loggerprivate byte[]stdErrHeaderprivate byte[]stdOutHeaderprivate java.io.PrintStreamtargetprivate inttestSetChannelIdprivate booleantrimStackTraces
-
Constructor Summary
Constructors Constructor Description ForkingRunListener(java.io.PrintStream target, int testSetChannelId, boolean trimStackTraces)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappend(java.lang.StringBuilder stringBuilder, byte b)private voidappend(java.lang.StringBuilder stringBuilder, java.lang.String message)private static voidcomma(java.lang.StringBuilder stringBuilder)static byte[]createHeader(byte booterCode, int testSetChannel)voiddebug(java.lang.String message)private java.lang.Stringencode(java.lang.String source)private voidencode(java.lang.StringBuilder stringBuilder, StackTraceWriter stackTraceWriter)static voidencode(java.lang.StringBuilder stringBuilder, StackTraceWriter stackTraceWriter, boolean trimStackTraces)private voidencodeAndWriteToTarget(java.lang.String string)voiderror(java.lang.String message)voiderror(java.lang.String message, java.lang.Throwable t)Simply delegates toerror( toString( t, message ) ).voiderror(java.lang.Throwable t)Simply delegates to methoderror(null, Throwable).voidinfo(java.lang.String message)booleanisDebugEnabled()booleanisErrorEnabled()booleanisInfoEnabled()booleanisWarnEnabled()private voidlog(byte bootCode, java.lang.String message)private voidnullableEncoding(java.lang.StringBuilder stringBuilder, java.lang.Integer source)private static voidnullableEncoding(java.lang.StringBuilder stringBuilder, java.lang.String source)voidprintln(byte[] buf, int off, int len)voidprintln(java.lang.String message)private voidsendProps()voidtestAssumptionFailure(ReportEntry report)Event fired when a test assumption failure was encountered.voidtestError(ReportEntry report)Event fired when a test ended with an error (non anticipated problem)voidtestExecutionSkippedByUser()Event fired skipping an execution of remaining test-set in other fork(s); or does nothing if no forks.voidtestFailed(ReportEntry report)Event fired when a test ended with a failure (anticipated problem)voidtestSetCompleted(TestSetReportEntry report)Indicates end of a given test-setvoidtestSetStarting(TestSetReportEntry report)Indicates the start of a given test-setvoidtestSkipped(ReportEntry report)Event fired when a test is skippedvoidtestStarting(ReportEntry report)Event fired when a test is about to startvoidtestSucceeded(ReportEntry report)Event fired when a test ended successfullyprivate java.lang.StringtoPropertyString(java.lang.String key, java.lang.String value)private java.lang.StringtoString(byte operationCode, ReportEntry reportEntry, int testSetChannelId)voidwarning(java.lang.String message)voidwriteTestOutput(byte[] buf, int off, int len, boolean stdout)Forwards process output from the running test-case into the reporting system
-
-
-
Field Detail
-
BOOTERCODE_TESTSET_STARTING
public static final byte BOOTERCODE_TESTSET_STARTING
- See Also:
- Constant Field Values
-
BOOTERCODE_TESTSET_COMPLETED
public static final byte BOOTERCODE_TESTSET_COMPLETED
- See Also:
- Constant Field Values
-
BOOTERCODE_STDOUT
public static final byte BOOTERCODE_STDOUT
- See Also:
- Constant Field Values
-
BOOTERCODE_STDERR
public static final byte BOOTERCODE_STDERR
- See Also:
- Constant Field Values
-
BOOTERCODE_TEST_STARTING
public static final byte BOOTERCODE_TEST_STARTING
- See Also:
- Constant Field Values
-
BOOTERCODE_TEST_SUCCEEDED
public static final byte BOOTERCODE_TEST_SUCCEEDED
- See Also:
- Constant Field Values
-
BOOTERCODE_TEST_ERROR
public static final byte BOOTERCODE_TEST_ERROR
- See Also:
- Constant Field Values
-
BOOTERCODE_TEST_FAILED
public static final byte BOOTERCODE_TEST_FAILED
- See Also:
- Constant Field Values
-
BOOTERCODE_TEST_SKIPPED
public static final byte BOOTERCODE_TEST_SKIPPED
- See Also:
- Constant Field Values
-
BOOTERCODE_TEST_ASSUMPTIONFAILURE
public static final byte BOOTERCODE_TEST_ASSUMPTIONFAILURE
- See Also:
- Constant Field Values
-
BOOTERCODE_CONSOLE
public static final byte BOOTERCODE_CONSOLE
INFO logger- See Also:
ConsoleLogger.info(String), Constant Field Values
-
BOOTERCODE_SYSPROPS
public static final byte BOOTERCODE_SYSPROPS
- See Also:
- Constant Field Values
-
BOOTERCODE_NEXT_TEST
public static final byte BOOTERCODE_NEXT_TEST
- See Also:
- Constant Field Values
-
BOOTERCODE_STOP_ON_NEXT_TEST
public static final byte BOOTERCODE_STOP_ON_NEXT_TEST
- See Also:
- Constant Field Values
-
BOOTERCODE_ERROR
public static final byte BOOTERCODE_ERROR
ERROR logger- See Also:
ConsoleLogger.error(String), Constant Field Values
-
BOOTERCODE_BYE
public static final byte BOOTERCODE_BYE
- See Also:
- Constant Field Values
-
BOOTERCODE_DEBUG
public static final byte BOOTERCODE_DEBUG
DEBUG logger- See Also:
ConsoleLogger.debug(String), Constant Field Values
-
BOOTERCODE_WARNING
public static final byte BOOTERCODE_WARNING
WARNING logger
-
target
private final java.io.PrintStream target
-
testSetChannelId
private final int testSetChannelId
-
trimStackTraces
private final boolean trimStackTraces
-
stdOutHeader
private final byte[] stdOutHeader
-
stdErrHeader
private final byte[] stdErrHeader
-
-
Method Detail
-
testSetStarting
public void testSetStarting(TestSetReportEntry report)
Description copied from interface:RunListenerIndicates the start of a given test-set- Specified by:
testSetStartingin interfaceRunListener- Parameters:
report- the report entry describing the testset
-
testSetCompleted
public void testSetCompleted(TestSetReportEntry report)
Description copied from interface:RunListenerIndicates end of a given test-set- Specified by:
testSetCompletedin interfaceRunListener- Parameters:
report- the report entry describing the testset
-
testStarting
public void testStarting(ReportEntry report)
Description copied from interface:RunListenerEvent fired when a test is about to start- Specified by:
testStartingin interfaceRunListener- Parameters:
report- The report entry to log for
-
testSucceeded
public void testSucceeded(ReportEntry report)
Description copied from interface:RunListenerEvent fired when a test ended successfully- Specified by:
testSucceededin interfaceRunListener- Parameters:
report- The report entry to log for
-
testAssumptionFailure
public void testAssumptionFailure(ReportEntry report)
Description copied from interface:RunListenerEvent fired when a test assumption failure was encountered. An assumption failure indicates that the test is not relevant- Specified by:
testAssumptionFailurein interfaceRunListener- Parameters:
report- The report entry to log for
-
testError
public void testError(ReportEntry report)
Description copied from interface:RunListenerEvent fired when a test ended with an error (non anticipated problem)- Specified by:
testErrorin interfaceRunListener- Parameters:
report- The report entry to log for
-
testFailed
public void testFailed(ReportEntry report)
Description copied from interface:RunListenerEvent fired when a test ended with a failure (anticipated problem)- Specified by:
testFailedin interfaceRunListener- Parameters:
report- The report entry to log for
-
testSkipped
public void testSkipped(ReportEntry report)
Description copied from interface:RunListenerEvent fired when a test is skipped- Specified by:
testSkippedin interfaceRunListener- Parameters:
report- The report entry to log for
-
testExecutionSkippedByUser
public void testExecutionSkippedByUser()
Description copied from interface:RunListenerEvent fired skipping an execution of remaining test-set in other fork(s); or does nothing if no forks. The method is called bySurefireProvider.(The event is fired after the Nth test failed to signal skipping the rest of test-set.)
- Specified by:
testExecutionSkippedByUserin interfaceRunListener
-
sendProps
private void sendProps()
-
writeTestOutput
public void writeTestOutput(byte[] buf, int off, int len, boolean stdout)Description copied from interface:ConsoleOutputReceiverForwards process output from the running test-case into the reporting system- Specified by:
writeTestOutputin interfaceConsoleOutputReceiver- Parameters:
buf- the buffer to writeoff- offsetlen- lenstdout- Indicates if this is stdout
-
createHeader
public static byte[] createHeader(byte booterCode, int testSetChannel)
-
log
private void log(byte bootCode, java.lang.String message)
-
isDebugEnabled
public boolean isDebugEnabled()
- Specified by:
isDebugEnabledin interfaceConsoleLogger
-
debug
public void debug(java.lang.String message)
- Specified by:
debugin interfaceConsoleLogger
-
isInfoEnabled
public boolean isInfoEnabled()
- Specified by:
isInfoEnabledin interfaceConsoleLogger
-
info
public void info(java.lang.String message)
- Specified by:
infoin interfaceConsoleLogger
-
isWarnEnabled
public boolean isWarnEnabled()
- Specified by:
isWarnEnabledin interfaceConsoleLogger
-
warning
public void warning(java.lang.String message)
- Specified by:
warningin interfaceConsoleLogger
-
isErrorEnabled
public boolean isErrorEnabled()
- Specified by:
isErrorEnabledin interfaceConsoleLogger
-
error
public void error(java.lang.String message)
- Specified by:
errorin interfaceConsoleLogger- Parameters:
message- message to log
-
error
public void error(java.lang.String message, java.lang.Throwable t)Description copied from interface:ConsoleLoggerSimply delegates toerror( toString( t, message ) ).- Specified by:
errorin interfaceConsoleLogger- Parameters:
message- message to logt- exception, message and trace to log
-
error
public void error(java.lang.Throwable t)
Description copied from interface:ConsoleLoggerSimply delegates to methoderror(null, Throwable).- Specified by:
errorin interfaceConsoleLogger- Parameters:
t- exception, message and trace to log
-
encodeAndWriteToTarget
private void encodeAndWriteToTarget(java.lang.String string)
-
toPropertyString
private java.lang.String toPropertyString(java.lang.String key, java.lang.String value)
-
toString
private java.lang.String toString(byte operationCode, ReportEntry reportEntry, int testSetChannelId)
-
comma
private static void comma(java.lang.StringBuilder stringBuilder)
-
append
private void append(java.lang.StringBuilder stringBuilder, java.lang.String message)
-
append
private void append(java.lang.StringBuilder stringBuilder, byte b)
-
nullableEncoding
private void nullableEncoding(java.lang.StringBuilder stringBuilder, java.lang.Integer source)
-
encode
private java.lang.String encode(java.lang.String source)
-
nullableEncoding
private static void nullableEncoding(java.lang.StringBuilder stringBuilder, java.lang.String source)
-
encode
private void encode(java.lang.StringBuilder stringBuilder, StackTraceWriter stackTraceWriter)
-
encode
public static void encode(java.lang.StringBuilder stringBuilder, StackTraceWriter stackTraceWriter, boolean trimStackTraces)
-
println
public void println(java.lang.String message)
- Specified by:
printlnin interfaceConsoleStream
-
println
public void println(byte[] buf, int off, int len)- Specified by:
printlnin interfaceConsoleStream
-
-