@Test public void shouldHandleExit() { Stream out = Stream.newStream(); LegacyMasterProcessChannelEncoder encoder = new LegacyMasterProcessChannelEncoder( newBufferedChannel( out ) ); StackTraceWriter stackTraceWriter = mock( StackTraceWriter.class ); when( stackTraceWriter.getThrowable() ).thenReturn( new SafeThrowable( "1" ) ); when( stackTraceWriter.smartTrimmedStackTrace() ).thenReturn( "2" ); when( stackTraceWriter.writeTraceToString() ).thenReturn( "3" ); when( stackTraceWriter.writeTrimmedTraceToString() ).thenReturn( "4" ); encoder.sendExitError( stackTraceWriter, false ); assertThat( new String( out.toByteArray(), UTF_8 ) ) .startsWith( ":maven-surefire-event:\u000e:jvm-exit-error:\u0005:UTF-8:\u0000\u0000\u0000\u0001:1:\u0000\u0000\u0000\u0001:2:\u0000\u0000\u0000\u0001:3:" ); }
@Override public void sendExitError( StackTraceWriter stackTraceWriter, boolean trimStackTraces ) { error( stackTraceWriter, trimStackTraces, BOOTERCODE_JVM_EXIT_ERROR, true ); }
LegacyMasterProcessChannelEncoder implements MasterProcessChannelEncoder { @Override public void sendExitError( StackTraceWriter stackTraceWriter, boolean trimStackTraces ) { error( stackTraceWriter, trimStackTraces, BOOTERCODE_JVM_EXIT_ERROR, true ); } }
LegacyMasterProcessChannelEncoder implements MasterProcessChannelEncoder { @Override public void sendExitError( StackTraceWriter stackTraceWriter, boolean trimStackTraces ) { error( stackTraceWriter, trimStackTraces, BOOTERCODE_JVM_EXIT_ERROR, true ); } LegacyMasterProcessChannelEncoder( @Nonnull WritableBufferedByteChannel out ); protected  LegacyMasterProcessChannelEncoder( @Nonnull WritableBufferedByteChannel out, @Nonnull RunMode runMode ); }
LegacyMasterProcessChannelEncoder implements MasterProcessChannelEncoder { @Override public void sendExitError( StackTraceWriter stackTraceWriter, boolean trimStackTraces ) { error( stackTraceWriter, trimStackTraces, BOOTERCODE_JVM_EXIT_ERROR, true ); } LegacyMasterProcessChannelEncoder( @Nonnull WritableBufferedByteChannel out ); protected  LegacyMasterProcessChannelEncoder( @Nonnull WritableBufferedByteChannel out, @Nonnull RunMode runMode ); @Override MasterProcessChannelEncoder asRerunMode(); @Override MasterProcessChannelEncoder asNormalMode(); @Override boolean checkError(); @Override void onJvmExit(); @Override void sendSystemProperties( Map<String, String> sysProps ); @Override void testSetStarting( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testSetCompleted( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testStarting( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testSucceeded( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testFailed( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testSkipped( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testError( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testAssumptionFailure( ReportEntry reportEntry, boolean trimStackTraces ); @Override void stdOut( String msg, boolean newLine ); @Override void stdErr( String msg, boolean newLine ); @Override void consoleInfoLog( String message ); @Override void consoleErrorLog( String message ); @Override void consoleErrorLog( Throwable t ); @Override void consoleErrorLog( String message, Throwable t ); @Override void consoleErrorLog( StackTraceWriter stackTraceWriter, boolean trimStackTraces ); @Override void consoleDebugLog( String message ); @Override void consoleWarningLog( String message ); @Override void bye(); @Override void stopOnNextTest(); @Override void acquireNextTest(); @Override void sendExitError( StackTraceWriter stackTraceWriter, boolean trimStackTraces ); }
LegacyMasterProcessChannelEncoder implements MasterProcessChannelEncoder { @Override public void sendExitError( StackTraceWriter stackTraceWriter, boolean trimStackTraces ) { error( stackTraceWriter, trimStackTraces, BOOTERCODE_JVM_EXIT_ERROR, true ); } LegacyMasterProcessChannelEncoder( @Nonnull WritableBufferedByteChannel out ); protected  LegacyMasterProcessChannelEncoder( @Nonnull WritableBufferedByteChannel out, @Nonnull RunMode runMode ); @Override MasterProcessChannelEncoder asRerunMode(); @Override MasterProcessChannelEncoder asNormalMode(); @Override boolean checkError(); @Override void onJvmExit(); @Override void sendSystemProperties( Map<String, String> sysProps ); @Override void testSetStarting( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testSetCompleted( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testStarting( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testSucceeded( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testFailed( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testSkipped( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testError( ReportEntry reportEntry, boolean trimStackTraces ); @Override void testAssumptionFailure( ReportEntry reportEntry, boolean trimStackTraces ); @Override void stdOut( String msg, boolean newLine ); @Override void stdErr( String msg, boolean newLine ); @Override void consoleInfoLog( String message ); @Override void consoleErrorLog( String message ); @Override void consoleErrorLog( Throwable t ); @Override void consoleErrorLog( String message, Throwable t ); @Override void consoleErrorLog( StackTraceWriter stackTraceWriter, boolean trimStackTraces ); @Override void consoleDebugLog( String message ); @Override void consoleWarningLog( String message ); @Override void bye(); @Override void stopOnNextTest(); @Override void acquireNextTest(); @Override void sendExitError( StackTraceWriter stackTraceWriter, boolean trimStackTraces );  }