@Test public void shouldMapEventTypeToSegmentType() { SegmentType[] segmentTypes = nextSegmentType( BOOTERCODE_BYE ); assertThat( segmentTypes ) .hasSize( 1 ) .containsOnly( END_OF_FRAME ); segmentTypes = nextSegmentType( BOOTERCODE_STOP_ON_NEXT_TEST ); assertThat( segmentTypes ) .hasSize( 1 ) .containsOnly( END_OF_FRAME ); segmentTypes = nextSegmentType( BOOTERCODE_NEXT_TEST ); assertThat( segmentTypes ) .hasSize( 1 ) .containsOnly( END_OF_FRAME ); segmentTypes = nextSegmentType( BOOTERCODE_CONSOLE_ERROR ); assertThat( segmentTypes ) .hasSize( 5 ) .satisfies( new InOrder( STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_JVM_EXIT_ERROR ); assertThat( segmentTypes ) .hasSize( 5 ) .satisfies( new InOrder( STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( BOOTERCODE_CONSOLE_INFO ); assertThat( segmentTypes ) .hasSize( 3 ) .satisfies( new InOrder( STRING_ENCODING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_CONSOLE_DEBUG ); assertThat( segmentTypes ) .hasSize( 3 ) .satisfies( new InOrder( STRING_ENCODING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_CONSOLE_WARNING ); assertThat( segmentTypes ) .hasSize( 3 ) .satisfies( new InOrder( STRING_ENCODING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( BOOTERCODE_STDOUT ); assertThat( segmentTypes ) .hasSize( 4 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_STDOUT_NEW_LINE ); assertThat( segmentTypes ) .hasSize( 4 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_STDERR ); assertThat( segmentTypes ) .hasSize( 4 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_STDERR_NEW_LINE ); assertThat( segmentTypes ) .hasSize( 4 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( BOOTERCODE_SYSPROPS ); assertThat( segmentTypes ) .hasSize( 5 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( BOOTERCODE_TESTSET_STARTING ); assertThat( segmentTypes ) .hasSize( 13 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_INT, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_TESTSET_COMPLETED ); assertThat( segmentTypes ) .hasSize( 13 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_INT, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_TEST_STARTING ); assertThat( segmentTypes ) .hasSize( 13 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_INT, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( BOOTERCODE_TEST_SUCCEEDED ); assertThat( segmentTypes ) .hasSize( 13 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_INT, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( BOOTERCODE_TEST_FAILED ); assertThat( segmentTypes ) .hasSize( 13 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_INT, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_TEST_SKIPPED ); assertThat( segmentTypes ) .hasSize( 13 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_INT, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_TEST_ERROR ); assertThat( segmentTypes ) .hasSize( 13 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_INT, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); segmentTypes = nextSegmentType( ForkedProcessEventType.BOOTERCODE_TEST_ASSUMPTIONFAILURE ); assertThat( segmentTypes ) .hasSize( 13 ) .satisfies( new InOrder( RUN_MODE, STRING_ENCODING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_STRING, DATA_INT, DATA_STRING, DATA_STRING, DATA_STRING, END_OF_FRAME ) ); }
static SegmentType[] nextSegmentType( ForkedProcessEventType eventType ) { switch ( eventType ) { case BOOTERCODE_BYE: case BOOTERCODE_STOP_ON_NEXT_TEST: case BOOTERCODE_NEXT_TEST: return EVENT_WITHOUT_DATA; case BOOTERCODE_CONSOLE_ERROR: case BOOTERCODE_JVM_EXIT_ERROR: return EVENT_WITH_ERROR_TRACE; case BOOTERCODE_CONSOLE_INFO: case BOOTERCODE_CONSOLE_DEBUG: case BOOTERCODE_CONSOLE_WARNING: return EVENT_WITH_ONE_STRING; case BOOTERCODE_STDOUT: case BOOTERCODE_STDOUT_NEW_LINE: case BOOTERCODE_STDERR: case BOOTERCODE_STDERR_NEW_LINE: return EVENT_WITH_RUNMODE_AND_ONE_STRING; case BOOTERCODE_SYSPROPS: return EVENT_WITH_RUNMODE_AND_TWO_STRINGS; case BOOTERCODE_TESTSET_STARTING: case BOOTERCODE_TESTSET_COMPLETED: case BOOTERCODE_TEST_STARTING: case BOOTERCODE_TEST_SUCCEEDED: case BOOTERCODE_TEST_FAILED: case BOOTERCODE_TEST_SKIPPED: case BOOTERCODE_TEST_ERROR: case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return EVENT_TEST_CONTROL; default: throw new IllegalArgumentException( "Unknown enum " + eventType ); } }
EventConsumerThread extends CloseableDaemonThread { static SegmentType[] nextSegmentType( ForkedProcessEventType eventType ) { switch ( eventType ) { case BOOTERCODE_BYE: case BOOTERCODE_STOP_ON_NEXT_TEST: case BOOTERCODE_NEXT_TEST: return EVENT_WITHOUT_DATA; case BOOTERCODE_CONSOLE_ERROR: case BOOTERCODE_JVM_EXIT_ERROR: return EVENT_WITH_ERROR_TRACE; case BOOTERCODE_CONSOLE_INFO: case BOOTERCODE_CONSOLE_DEBUG: case BOOTERCODE_CONSOLE_WARNING: return EVENT_WITH_ONE_STRING; case BOOTERCODE_STDOUT: case BOOTERCODE_STDOUT_NEW_LINE: case BOOTERCODE_STDERR: case BOOTERCODE_STDERR_NEW_LINE: return EVENT_WITH_RUNMODE_AND_ONE_STRING; case BOOTERCODE_SYSPROPS: return EVENT_WITH_RUNMODE_AND_TWO_STRINGS; case BOOTERCODE_TESTSET_STARTING: case BOOTERCODE_TESTSET_COMPLETED: case BOOTERCODE_TEST_STARTING: case BOOTERCODE_TEST_SUCCEEDED: case BOOTERCODE_TEST_FAILED: case BOOTERCODE_TEST_SKIPPED: case BOOTERCODE_TEST_ERROR: case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return EVENT_TEST_CONTROL; default: throw new IllegalArgumentException( "Unknown enum " + eventType ); } } }
EventConsumerThread extends CloseableDaemonThread { static SegmentType[] nextSegmentType( ForkedProcessEventType eventType ) { switch ( eventType ) { case BOOTERCODE_BYE: case BOOTERCODE_STOP_ON_NEXT_TEST: case BOOTERCODE_NEXT_TEST: return EVENT_WITHOUT_DATA; case BOOTERCODE_CONSOLE_ERROR: case BOOTERCODE_JVM_EXIT_ERROR: return EVENT_WITH_ERROR_TRACE; case BOOTERCODE_CONSOLE_INFO: case BOOTERCODE_CONSOLE_DEBUG: case BOOTERCODE_CONSOLE_WARNING: return EVENT_WITH_ONE_STRING; case BOOTERCODE_STDOUT: case BOOTERCODE_STDOUT_NEW_LINE: case BOOTERCODE_STDERR: case BOOTERCODE_STDERR_NEW_LINE: return EVENT_WITH_RUNMODE_AND_ONE_STRING; case BOOTERCODE_SYSPROPS: return EVENT_WITH_RUNMODE_AND_TWO_STRINGS; case BOOTERCODE_TESTSET_STARTING: case BOOTERCODE_TESTSET_COMPLETED: case BOOTERCODE_TEST_STARTING: case BOOTERCODE_TEST_SUCCEEDED: case BOOTERCODE_TEST_FAILED: case BOOTERCODE_TEST_SKIPPED: case BOOTERCODE_TEST_ERROR: case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return EVENT_TEST_CONTROL; default: throw new IllegalArgumentException( "Unknown enum " + eventType ); } } EventConsumerThread( @Nonnull String threadName,
                                @Nonnull ReadableByteChannel channel,
                                @Nonnull EventHandler<Event> eventHandler,
                                @Nonnull CountdownCloseable countdownCloseable,
                                @Nonnull ForkNodeArguments arguments ); }
EventConsumerThread extends CloseableDaemonThread { static SegmentType[] nextSegmentType( ForkedProcessEventType eventType ) { switch ( eventType ) { case BOOTERCODE_BYE: case BOOTERCODE_STOP_ON_NEXT_TEST: case BOOTERCODE_NEXT_TEST: return EVENT_WITHOUT_DATA; case BOOTERCODE_CONSOLE_ERROR: case BOOTERCODE_JVM_EXIT_ERROR: return EVENT_WITH_ERROR_TRACE; case BOOTERCODE_CONSOLE_INFO: case BOOTERCODE_CONSOLE_DEBUG: case BOOTERCODE_CONSOLE_WARNING: return EVENT_WITH_ONE_STRING; case BOOTERCODE_STDOUT: case BOOTERCODE_STDOUT_NEW_LINE: case BOOTERCODE_STDERR: case BOOTERCODE_STDERR_NEW_LINE: return EVENT_WITH_RUNMODE_AND_ONE_STRING; case BOOTERCODE_SYSPROPS: return EVENT_WITH_RUNMODE_AND_TWO_STRINGS; case BOOTERCODE_TESTSET_STARTING: case BOOTERCODE_TESTSET_COMPLETED: case BOOTERCODE_TEST_STARTING: case BOOTERCODE_TEST_SUCCEEDED: case BOOTERCODE_TEST_FAILED: case BOOTERCODE_TEST_SKIPPED: case BOOTERCODE_TEST_ERROR: case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return EVENT_TEST_CONTROL; default: throw new IllegalArgumentException( "Unknown enum " + 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 SegmentType[] nextSegmentType( ForkedProcessEventType eventType ) { switch ( eventType ) { case BOOTERCODE_BYE: case BOOTERCODE_STOP_ON_NEXT_TEST: case BOOTERCODE_NEXT_TEST: return EVENT_WITHOUT_DATA; case BOOTERCODE_CONSOLE_ERROR: case BOOTERCODE_JVM_EXIT_ERROR: return EVENT_WITH_ERROR_TRACE; case BOOTERCODE_CONSOLE_INFO: case BOOTERCODE_CONSOLE_DEBUG: case BOOTERCODE_CONSOLE_WARNING: return EVENT_WITH_ONE_STRING; case BOOTERCODE_STDOUT: case BOOTERCODE_STDOUT_NEW_LINE: case BOOTERCODE_STDERR: case BOOTERCODE_STDERR_NEW_LINE: return EVENT_WITH_RUNMODE_AND_ONE_STRING; case BOOTERCODE_SYSPROPS: return EVENT_WITH_RUNMODE_AND_TWO_STRINGS; case BOOTERCODE_TESTSET_STARTING: case BOOTERCODE_TESTSET_COMPLETED: case BOOTERCODE_TEST_STARTING: case BOOTERCODE_TEST_SUCCEEDED: case BOOTERCODE_TEST_FAILED: case BOOTERCODE_TEST_SKIPPED: case BOOTERCODE_TEST_ERROR: case BOOTERCODE_TEST_ASSUMPTIONFAILURE: return EVENT_TEST_CONTROL; default: throw new IllegalArgumentException( "Unknown enum " + 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();  }