@Test public void shouldCreateEvent() { Event event = toEvent( BOOTERCODE_BYE, NORMAL_RUN, emptyList() ); assertThat( event ) .isInstanceOf( ControlByeEvent.class ); event = toEvent( BOOTERCODE_STOP_ON_NEXT_TEST, NORMAL_RUN, emptyList() ); assertThat( event ) .isInstanceOf( ControlStopOnNextTestEvent.class ); event = toEvent( BOOTERCODE_NEXT_TEST, NORMAL_RUN, emptyList() ); assertThat( event ) .isInstanceOf( ControlNextTestEvent.class ); List data = asList( "1", "2", "3" ); event = toEvent( BOOTERCODE_CONSOLE_ERROR, NORMAL_RUN, data ); assertThat( event ) .isInstanceOf( ConsoleErrorEvent.class ); ConsoleErrorEvent consoleErrorEvent = (ConsoleErrorEvent) event; assertThat( consoleErrorEvent.getStackTraceWriter().getThrowable().getLocalizedMessage() ) .isEqualTo( "1" ); assertThat( consoleErrorEvent.getStackTraceWriter().smartTrimmedStackTrace() ) .isEqualTo( "2" ); assertThat( consoleErrorEvent.getStackTraceWriter().writeTraceToString() ) .isEqualTo( "3" ); data = asList( null, null, null ); event = toEvent( BOOTERCODE_CONSOLE_ERROR, NORMAL_RUN, data ); assertThat( event ) .isInstanceOf( ConsoleErrorEvent.class ); consoleErrorEvent = (ConsoleErrorEvent) event; assertThat( consoleErrorEvent.getStackTraceWriter() ) .isNull(); data = asList( "1", "2", "3" ); event = toEvent( BOOTERCODE_JVM_EXIT_ERROR, NORMAL_RUN, data ); assertThat( event ) .isInstanceOf( JvmExitErrorEvent.class ); JvmExitErrorEvent jvmExitErrorEvent = (JvmExitErrorEvent) event; assertThat( jvmExitErrorEvent.getStackTraceWriter().getThrowable().getLocalizedMessage() ) .isEqualTo( "1" ); assertThat( jvmExitErrorEvent.getStackTraceWriter().smartTrimmedStackTrace() ) .isEqualTo( "2" ); assertThat( jvmExitErrorEvent.getStackTraceWriter().writeTraceToString() ) .isEqualTo( "3" ); data = asList( null, null, null ); event = toEvent( BOOTERCODE_JVM_EXIT_ERROR, NORMAL_RUN, data ); assertThat( event ) .isInstanceOf( JvmExitErrorEvent.class ); jvmExitErrorEvent = (JvmExitErrorEvent) event; assertThat( jvmExitErrorEvent.getStackTraceWriter() ) .isNull(); data = singletonList( "m" ); event = toEvent( BOOTERCODE_CONSOLE_INFO, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( ConsoleInfoEvent.class ); assertThat( ( (ConsoleInfoEvent) event ).getMessage() ).isEqualTo( "m" ); data = singletonList( "" ); event = toEvent( BOOTERCODE_CONSOLE_WARNING, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( ConsoleWarningEvent.class ); assertThat( ( (ConsoleWarningEvent) event ).getMessage() ).isEmpty(); data = singletonList( null ); event = toEvent( BOOTERCODE_CONSOLE_DEBUG, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( ConsoleDebugEvent.class ); assertThat( ( (ConsoleDebugEvent) event ).getMessage() ).isNull(); data = singletonList( "m" ); event = toEvent( BOOTERCODE_STDOUT, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( StandardStreamOutEvent.class ); assertThat( ( (StandardStreamOutEvent) event ).getMessage() ).isEqualTo( "m" ); assertThat( ( (StandardStreamOutEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); data = singletonList( null ); event = toEvent( BOOTERCODE_STDOUT_NEW_LINE, RERUN_TEST_AFTER_FAILURE, data ); assertThat( event ).isInstanceOf( StandardStreamOutWithNewLineEvent.class ); assertThat( ( (StandardStreamOutWithNewLineEvent) event ).getMessage() ).isNull(); assertThat( ( (StandardStreamOutWithNewLineEvent) event ).getRunMode() ).isEqualTo( RERUN_TEST_AFTER_FAILURE ); data = singletonList( null ); event = toEvent( BOOTERCODE_STDERR, RERUN_TEST_AFTER_FAILURE, data ); assertThat( event ).isInstanceOf( StandardStreamErrEvent.class ); assertThat( ( (StandardStreamErrEvent) event ).getMessage() ).isNull(); assertThat( ( (StandardStreamErrEvent) event ).getRunMode() ).isEqualTo( RERUN_TEST_AFTER_FAILURE ); data = singletonList( "abc" ); event = toEvent( BOOTERCODE_STDERR_NEW_LINE, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( StandardStreamErrWithNewLineEvent.class ); assertThat( ( (StandardStreamErrWithNewLineEvent) event ).getMessage() ).isEqualTo( "abc" ); assertThat( ( (StandardStreamErrWithNewLineEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); data = asList( "key", "value" ); event = toEvent( BOOTERCODE_SYSPROPS, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( SystemPropertyEvent.class ); assertThat( ( (SystemPropertyEvent) event ).getKey() ).isEqualTo( "key" ); assertThat( ( (SystemPropertyEvent) event ).getValue() ).isEqualTo( "value" ); assertThat( ( (SystemPropertyEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); data = asList( "source", "sourceText", "name", "nameText", "group", "message", 5, "traceMessage", "smartTrimmedStackTrace", "stackTrace" ); event = toEvent( BOOTERCODE_TESTSET_STARTING, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( TestsetStartingEvent.class ); assertThat( ( (TestsetStartingEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); assertThat( ( (TestsetStartingEvent) event ).getReportEntry().getSourceName() ).isEqualTo( "source" ); assertThat( ( (TestsetStartingEvent) event ).getReportEntry().getSourceText() ).isEqualTo( "sourceText" ); assertThat( ( (TestsetStartingEvent) event ).getReportEntry().getName() ).isEqualTo( "name" ); assertThat( ( (TestsetStartingEvent) event ).getReportEntry().getNameText() ).isEqualTo( "nameText" ); assertThat( ( (TestsetStartingEvent) event ).getReportEntry().getGroup() ).isEqualTo( "group" ); assertThat( ( (TestsetStartingEvent) event ).getReportEntry().getMessage() ).isEqualTo( "message" ); assertThat( ( (TestsetStartingEvent) event ).getReportEntry().getElapsed() ).isEqualTo( 5 ); assertThat( ( (TestsetStartingEvent) event ) .getReportEntry().getStackTraceWriter().getThrowable().getLocalizedMessage() ) .isEqualTo( "traceMessage" ); assertThat( ( (TestsetStartingEvent) event ).getReportEntry().getStackTraceWriter().smartTrimmedStackTrace() ) .isEqualTo( "smartTrimmedStackTrace" ); assertThat( ( (TestsetStartingEvent) event ).getReportEntry().getStackTraceWriter().writeTraceToString() ) .isEqualTo( "stackTrace" ); data = asList( "source", "sourceText", "name", "nameText", "group", null, 5, "traceMessage", "smartTrimmedStackTrace", "stackTrace" ); event = toEvent( BOOTERCODE_TESTSET_COMPLETED, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( TestsetCompletedEvent.class ); assertThat( ( (TestsetCompletedEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); assertThat( ( (TestsetCompletedEvent) event ).getReportEntry().getSourceName() ).isEqualTo( "source" ); assertThat( ( (TestsetCompletedEvent) event ).getReportEntry().getSourceText() ).isEqualTo( "sourceText" ); assertThat( ( (TestsetCompletedEvent) event ).getReportEntry().getName() ).isEqualTo( "name" ); assertThat( ( (TestsetCompletedEvent) event ).getReportEntry().getNameText() ).isEqualTo( "nameText" ); assertThat( ( (TestsetCompletedEvent) event ).getReportEntry().getGroup() ).isEqualTo( "group" ); assertThat( ( (TestsetCompletedEvent) event ).getReportEntry().getMessage() ).isNull(); assertThat( ( (TestsetCompletedEvent) event ).getReportEntry().getElapsed() ).isEqualTo( 5 ); assertThat( ( (TestsetCompletedEvent) event ) .getReportEntry().getStackTraceWriter().getThrowable().getLocalizedMessage() ) .isEqualTo( "traceMessage" ); assertThat( ( (TestsetCompletedEvent) event ).getReportEntry().getStackTraceWriter().smartTrimmedStackTrace() ) .isEqualTo( "smartTrimmedStackTrace" ); assertThat( ( (TestsetCompletedEvent) event ).getReportEntry().getStackTraceWriter().writeTraceToString() ) .isEqualTo( "stackTrace" ); data = asList( "source", "sourceText", "name", "nameText", "group", "message", 5, null, "smartTrimmedStackTrace", "stackTrace" ); event = toEvent( BOOTERCODE_TEST_STARTING, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( TestStartingEvent.class ); assertThat( ( (TestStartingEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); assertThat( ( (TestStartingEvent) event ).getReportEntry().getSourceName() ).isEqualTo( "source" ); assertThat( ( (TestStartingEvent) event ).getReportEntry().getSourceText() ).isEqualTo( "sourceText" ); assertThat( ( (TestStartingEvent) event ).getReportEntry().getName() ).isEqualTo( "name" ); assertThat( ( (TestStartingEvent) event ).getReportEntry().getNameText() ).isEqualTo( "nameText" ); assertThat( ( (TestStartingEvent) event ).getReportEntry().getGroup() ).isEqualTo( "group" ); assertThat( ( (TestStartingEvent) event ).getReportEntry().getMessage() ).isEqualTo( "message" ); assertThat( ( (TestStartingEvent) event ).getReportEntry().getElapsed() ).isEqualTo( 5 ); assertThat( ( (TestStartingEvent) event ) .getReportEntry().getStackTraceWriter().getThrowable().getLocalizedMessage() ) .isNull(); assertThat( ( (TestStartingEvent) event ).getReportEntry().getStackTraceWriter().smartTrimmedStackTrace() ) .isEqualTo( "smartTrimmedStackTrace" ); assertThat( ( (TestStartingEvent) event ).getReportEntry().getStackTraceWriter().writeTraceToString() ) .isEqualTo( "stackTrace" ); data = asList( "source", "sourceText", "name", "nameText", "group", "message", 5, null, null, null ); event = toEvent( BOOTERCODE_TEST_SUCCEEDED, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( TestSucceededEvent.class ); assertThat( ( (TestSucceededEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); assertThat( ( (TestSucceededEvent) event ).getReportEntry().getSourceName() ).isEqualTo( "source" ); assertThat( ( (TestSucceededEvent) event ).getReportEntry().getSourceText() ).isEqualTo( "sourceText" ); assertThat( ( (TestSucceededEvent) event ).getReportEntry().getName() ).isEqualTo( "name" ); assertThat( ( (TestSucceededEvent) event ).getReportEntry().getNameText() ).isEqualTo( "nameText" ); assertThat( ( (TestSucceededEvent) event ).getReportEntry().getGroup() ).isEqualTo( "group" ); assertThat( ( (TestSucceededEvent) event ).getReportEntry().getMessage() ).isEqualTo( "message" ); assertThat( ( (TestSucceededEvent) event ).getReportEntry().getElapsed() ).isEqualTo( 5 ); assertThat( ( (TestSucceededEvent) event ).getReportEntry().getStackTraceWriter() ).isNull(); data = asList( "source", null, "name", null, "group", null, 5, "traceMessage", "smartTrimmedStackTrace", "stackTrace" ); event = toEvent( BOOTERCODE_TEST_FAILED, RERUN_TEST_AFTER_FAILURE, data ); assertThat( event ).isInstanceOf( TestFailedEvent.class ); assertThat( ( (TestFailedEvent) event ).getRunMode() ).isEqualTo( RERUN_TEST_AFTER_FAILURE ); assertThat( ( (TestFailedEvent) event ).getReportEntry().getSourceName() ).isEqualTo( "source" ); assertThat( ( (TestFailedEvent) event ).getReportEntry().getSourceText() ).isNull(); assertThat( ( (TestFailedEvent) event ).getReportEntry().getName() ).isEqualTo( "name" ); assertThat( ( (TestFailedEvent) event ).getReportEntry().getNameText() ).isNull(); assertThat( ( (TestFailedEvent) event ).getReportEntry().getGroup() ).isEqualTo( "group" ); assertThat( ( (TestFailedEvent) event ).getReportEntry().getMessage() ).isNull(); assertThat( ( (TestFailedEvent) event ).getReportEntry().getElapsed() ).isEqualTo( 5 ); assertThat( ( (TestFailedEvent) event ) .getReportEntry().getStackTraceWriter().getThrowable().getLocalizedMessage() ) .isEqualTo( "traceMessage" ); assertThat( ( (TestFailedEvent) event ).getReportEntry().getStackTraceWriter().smartTrimmedStackTrace() ) .isEqualTo( "smartTrimmedStackTrace" ); assertThat( ( (TestFailedEvent) event ).getReportEntry().getStackTraceWriter().writeTraceToString() ) .isEqualTo( "stackTrace" ); data = asList( "source", null, "name", null, null, null, 5, null, null, "stackTrace" ); event = toEvent( BOOTERCODE_TEST_SKIPPED, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( TestSkippedEvent.class ); assertThat( ( (TestSkippedEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); assertThat( ( (TestSkippedEvent) event ).getReportEntry().getSourceName() ).isEqualTo( "source" ); assertThat( ( (TestSkippedEvent) event ).getReportEntry().getSourceText() ).isNull(); assertThat( ( (TestSkippedEvent) event ).getReportEntry().getName() ).isEqualTo( "name" ); assertThat( ( (TestSkippedEvent) event ).getReportEntry().getNameText() ).isNull(); assertThat( ( (TestSkippedEvent) event ).getReportEntry().getGroup() ).isNull(); assertThat( ( (TestSkippedEvent) event ).getReportEntry().getMessage() ).isNull(); assertThat( ( (TestSkippedEvent) event ).getReportEntry().getElapsed() ).isEqualTo( 5 ); assertThat( ( (TestSkippedEvent) event ) .getReportEntry().getStackTraceWriter().getThrowable().getLocalizedMessage() ) .isNull(); assertThat( ( (TestSkippedEvent) event ) .getReportEntry().getStackTraceWriter().smartTrimmedStackTrace() ) .isNull(); assertThat( ( (TestSkippedEvent) event ) .getReportEntry().getStackTraceWriter().writeTraceToString() ) .isEqualTo( "stackTrace" ); data = asList( "source", null, "name", "nameText", null, null, 0, null, null, "stackTrace" ); event = toEvent( BOOTERCODE_TEST_ERROR, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( TestErrorEvent.class ); assertThat( ( (TestErrorEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); assertThat( ( (TestErrorEvent) event ).getReportEntry().getSourceName() ).isEqualTo( "source" ); assertThat( ( (TestErrorEvent) event ).getReportEntry().getSourceText() ).isNull(); assertThat( ( (TestErrorEvent) event ).getReportEntry().getName() ).isEqualTo( "name" ); assertThat( ( (TestErrorEvent) event ).getReportEntry().getNameText() ).isEqualTo( "nameText" ); assertThat( ( (TestErrorEvent) event ).getReportEntry().getGroup() ).isNull(); assertThat( ( (TestErrorEvent) event ).getReportEntry().getMessage() ).isNull(); assertThat( ( (TestErrorEvent) event ).getReportEntry().getElapsed() ).isZero(); assertThat( ( (TestErrorEvent) event ) .getReportEntry().getStackTraceWriter().getThrowable().getLocalizedMessage() ) .isNull(); assertThat( ( (TestErrorEvent) event ) .getReportEntry().getStackTraceWriter().smartTrimmedStackTrace() ) .isNull(); assertThat( ( (TestErrorEvent) event ) .getReportEntry().getStackTraceWriter().writeTraceToString() ) .isEqualTo( "stackTrace" ); data = asList( "source", null, "name", null, "group", null, 5, null, null, "stackTrace" ); event = toEvent( BOOTERCODE_TEST_ASSUMPTIONFAILURE, NORMAL_RUN, data ); assertThat( event ).isInstanceOf( TestAssumptionFailureEvent.class ); assertThat( ( (TestAssumptionFailureEvent) event ).getRunMode() ).isEqualTo( NORMAL_RUN ); assertThat( ( (TestAssumptionFailureEvent) event ).getReportEntry().getSourceName() ).isEqualTo( "source" ); assertThat( ( (TestAssumptionFailureEvent) event ).getReportEntry().getSourceText() ).isNull(); assertThat( ( (TestAssumptionFailureEvent) event ).getReportEntry().getName() ).isEqualTo( "name" ); assertThat( ( (TestAssumptionFailureEvent) event ).getReportEntry().getNameText() ).isNull(); assertThat( ( (TestAssumptionFailureEvent) event ).getReportEntry().getGroup() ).isEqualTo( "group" ); assertThat( ( (TestAssumptionFailureEvent) event ).getReportEntry().getMessage() ).isNull(); assertThat( ( (TestAssumptionFailureEvent) event ).getReportEntry().getElapsed() ).isEqualTo( 5 ); assertThat( ( (TestAssumptionFailureEvent) event ) .getReportEntry().getStackTraceWriter().getThrowable().getLocalizedMessage() ) .isNull(); assertThat( ( (TestAssumptionFailureEvent) event ) .getReportEntry().getStackTraceWriter().smartTrimmedStackTrace() ) .isNull(); assertThat( ( (TestAssumptionFailureEvent) event ) .getReportEntry().getStackTraceWriter().writeTraceToString() ) .isEqualTo( "stackTrace" ); }
static Event toEvent( ForkedProcessEventType eventType, RunMode runMode, List<Object> args ) { switch ( eventType ) { case BOOTERCODE_BYE: return new ControlByeEvent(); case BOOTERCODE_STOP_ON_NEXT_TEST: return new ControlStopOnNextTestEvent(); case BOOTERCODE_NEXT_TEST: return new ControlNextTestEvent(); case BOOTERCODE_CONSOLE_ERROR: return new ConsoleErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_JVM_EXIT_ERROR: return new JvmExitErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_CONSOLE_INFO: return new ConsoleInfoEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_DEBUG: return new ConsoleDebugEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_WARNING: return new ConsoleWarningEvent( (String) args.get( 0 ) ); case BOOTERCODE_STDOUT: return new StandardStreamOutEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDOUT_NEW_LINE: return new StandardStreamOutWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR: return new StandardStreamErrEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR_NEW_LINE: return new StandardStreamErrWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_SYSPROPS: String key = (String) args.get( 0 ); String value = (String) args.get( 1 ); return new SystemPropertyEvent( runMode, key, value ); case BOOTERCODE_TESTSET_STARTING: return new TestsetStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TESTSET_COMPLETED: return new TestsetCompletedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_STARTING: return new TestStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SUCCEEDED: return new TestSucceededEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_FAILED: return new TestFailedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SKIPPED: return new TestSkippedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ERROR: return new TestErrorEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return new TestAssumptionFailureEvent( runMode, toReportEntry( args ) ); default: throw new IllegalArgumentException( "Missing a branch for the event type " + eventType ); } }
EventConsumerThread extends CloseableDaemonThread { static Event toEvent( ForkedProcessEventType eventType, RunMode runMode, List<Object> args ) { switch ( eventType ) { case BOOTERCODE_BYE: return new ControlByeEvent(); case BOOTERCODE_STOP_ON_NEXT_TEST: return new ControlStopOnNextTestEvent(); case BOOTERCODE_NEXT_TEST: return new ControlNextTestEvent(); case BOOTERCODE_CONSOLE_ERROR: return new ConsoleErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_JVM_EXIT_ERROR: return new JvmExitErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_CONSOLE_INFO: return new ConsoleInfoEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_DEBUG: return new ConsoleDebugEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_WARNING: return new ConsoleWarningEvent( (String) args.get( 0 ) ); case BOOTERCODE_STDOUT: return new StandardStreamOutEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDOUT_NEW_LINE: return new StandardStreamOutWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR: return new StandardStreamErrEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR_NEW_LINE: return new StandardStreamErrWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_SYSPROPS: String key = (String) args.get( 0 ); String value = (String) args.get( 1 ); return new SystemPropertyEvent( runMode, key, value ); case BOOTERCODE_TESTSET_STARTING: return new TestsetStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TESTSET_COMPLETED: return new TestsetCompletedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_STARTING: return new TestStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SUCCEEDED: return new TestSucceededEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_FAILED: return new TestFailedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SKIPPED: return new TestSkippedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ERROR: return new TestErrorEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return new TestAssumptionFailureEvent( runMode, toReportEntry( args ) ); default: throw new IllegalArgumentException( "Missing a branch for the event type " + eventType ); } } }
EventConsumerThread extends CloseableDaemonThread { static Event toEvent( ForkedProcessEventType eventType, RunMode runMode, List<Object> args ) { switch ( eventType ) { case BOOTERCODE_BYE: return new ControlByeEvent(); case BOOTERCODE_STOP_ON_NEXT_TEST: return new ControlStopOnNextTestEvent(); case BOOTERCODE_NEXT_TEST: return new ControlNextTestEvent(); case BOOTERCODE_CONSOLE_ERROR: return new ConsoleErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_JVM_EXIT_ERROR: return new JvmExitErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_CONSOLE_INFO: return new ConsoleInfoEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_DEBUG: return new ConsoleDebugEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_WARNING: return new ConsoleWarningEvent( (String) args.get( 0 ) ); case BOOTERCODE_STDOUT: return new StandardStreamOutEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDOUT_NEW_LINE: return new StandardStreamOutWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR: return new StandardStreamErrEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR_NEW_LINE: return new StandardStreamErrWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_SYSPROPS: String key = (String) args.get( 0 ); String value = (String) args.get( 1 ); return new SystemPropertyEvent( runMode, key, value ); case BOOTERCODE_TESTSET_STARTING: return new TestsetStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TESTSET_COMPLETED: return new TestsetCompletedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_STARTING: return new TestStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SUCCEEDED: return new TestSucceededEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_FAILED: return new TestFailedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SKIPPED: return new TestSkippedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ERROR: return new TestErrorEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return new TestAssumptionFailureEvent( runMode, toReportEntry( args ) ); default: throw new IllegalArgumentException( "Missing a branch for the event type " + eventType ); } } EventConsumerThread( @Nonnull String threadName,
                                @Nonnull ReadableByteChannel channel,
                                @Nonnull EventHandler<Event> eventHandler,
                                @Nonnull CountdownCloseable countdownCloseable,
                                @Nonnull ForkNodeArguments arguments ); }
EventConsumerThread extends CloseableDaemonThread { static Event toEvent( ForkedProcessEventType eventType, RunMode runMode, List<Object> args ) { switch ( eventType ) { case BOOTERCODE_BYE: return new ControlByeEvent(); case BOOTERCODE_STOP_ON_NEXT_TEST: return new ControlStopOnNextTestEvent(); case BOOTERCODE_NEXT_TEST: return new ControlNextTestEvent(); case BOOTERCODE_CONSOLE_ERROR: return new ConsoleErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_JVM_EXIT_ERROR: return new JvmExitErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_CONSOLE_INFO: return new ConsoleInfoEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_DEBUG: return new ConsoleDebugEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_WARNING: return new ConsoleWarningEvent( (String) args.get( 0 ) ); case BOOTERCODE_STDOUT: return new StandardStreamOutEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDOUT_NEW_LINE: return new StandardStreamOutWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR: return new StandardStreamErrEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR_NEW_LINE: return new StandardStreamErrWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_SYSPROPS: String key = (String) args.get( 0 ); String value = (String) args.get( 1 ); return new SystemPropertyEvent( runMode, key, value ); case BOOTERCODE_TESTSET_STARTING: return new TestsetStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TESTSET_COMPLETED: return new TestsetCompletedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_STARTING: return new TestStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SUCCEEDED: return new TestSucceededEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_FAILED: return new TestFailedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SKIPPED: return new TestSkippedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ERROR: return new TestErrorEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return new TestAssumptionFailureEvent( runMode, toReportEntry( args ) ); default: throw new IllegalArgumentException( "Missing a branch for the event type " + eventType ); } } EventConsumerThread( @Nonnull String threadName,
                                @Nonnull ReadableByteChannel channel,
                                @Nonnull EventHandler<Event> eventHandler,
                                @Nonnull CountdownCloseable countdownCloseable,
                                @Nonnull ForkNodeArguments arguments ); @Override void run(); @Override void disable(); @Override void close(); }
EventConsumerThread extends CloseableDaemonThread { static Event toEvent( ForkedProcessEventType eventType, RunMode runMode, List<Object> args ) { switch ( eventType ) { case BOOTERCODE_BYE: return new ControlByeEvent(); case BOOTERCODE_STOP_ON_NEXT_TEST: return new ControlStopOnNextTestEvent(); case BOOTERCODE_NEXT_TEST: return new ControlNextTestEvent(); case BOOTERCODE_CONSOLE_ERROR: return new ConsoleErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_JVM_EXIT_ERROR: return new JvmExitErrorEvent( toStackTraceWriter( args ) ); case BOOTERCODE_CONSOLE_INFO: return new ConsoleInfoEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_DEBUG: return new ConsoleDebugEvent( (String) args.get( 0 ) ); case BOOTERCODE_CONSOLE_WARNING: return new ConsoleWarningEvent( (String) args.get( 0 ) ); case BOOTERCODE_STDOUT: return new StandardStreamOutEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDOUT_NEW_LINE: return new StandardStreamOutWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR: return new StandardStreamErrEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_STDERR_NEW_LINE: return new StandardStreamErrWithNewLineEvent( runMode, (String) args.get( 0 ) ); case BOOTERCODE_SYSPROPS: String key = (String) args.get( 0 ); String value = (String) args.get( 1 ); return new SystemPropertyEvent( runMode, key, value ); case BOOTERCODE_TESTSET_STARTING: return new TestsetStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TESTSET_COMPLETED: return new TestsetCompletedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_STARTING: return new TestStartingEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SUCCEEDED: return new TestSucceededEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_FAILED: return new TestFailedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_SKIPPED: return new TestSkippedEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ERROR: return new TestErrorEvent( runMode, toReportEntry( args ) ); case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return new TestAssumptionFailureEvent( runMode, toReportEntry( args ) ); default: throw new IllegalArgumentException( "Missing a branch for the event type " + eventType ); } } EventConsumerThread( @Nonnull String threadName,
                                @Nonnull ReadableByteChannel channel,
                                @Nonnull EventHandler<Event> eventHandler,
                                @Nonnull CountdownCloseable countdownCloseable,
                                @Nonnull ForkNodeArguments arguments ); @Override void run(); @Override void disable(); @Override void close();  }