diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java index f89209b63f..fe5b9cf263 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java @@ -211,7 +211,7 @@ public void handle( ReportEntry reportEntry ) private final class SystemPropertiesListener implements ForkedProcessPropertyEventListener { @Override - public void handle( RunMode runMode, String key, String value ) + public void handle( String key, String value, RunMode runMode, Long testRunId ) { testVmSystemProperties.put( key, value ); } @@ -220,18 +220,18 @@ public void handle( RunMode runMode, String key, String value ) private final class StdOutListener implements ForkedProcessStandardOutErrEventListener { @Override - public void handle( RunMode runMode, String output, boolean newLine ) + public void handle( String output, boolean newLine, RunMode runMode, Long testRunId ) { - writeTestOutput( output, newLine, true ); + writeTestOutput( output, true, newLine, runMode, testRunId ); } } private final class StdErrListener implements ForkedProcessStandardOutErrEventListener { @Override - public void handle( RunMode runMode, String output, boolean newLine ) + public void handle( String output, boolean newLine, RunMode runMode, Long testRunId ) { - writeTestOutput( output, newLine, false ); + writeTestOutput( output, false, newLine, runMode, testRunId ); } } @@ -393,10 +393,10 @@ void dumpToLoFile( String msg ) util.dumpStreamText( msg, reportsDir, forkNumber ); } - private void writeTestOutput( String output, boolean newLine, boolean isStdout ) + private void writeTestOutput( String output, boolean isStdout, boolean newLine, RunMode runMode, Long testRunId ) { getConsoleOutputReceiver() - .writeTestOutput( new TestOutputReportEntry( output, isStdout, newLine, /*todo*/ null, null ) ); + .writeTestOutput( new TestOutputReportEntry( output, isStdout, newLine, runMode, testRunId ) ); } public Map getTestVmSystemProperties() diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessEventNotifier.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessEventNotifier.java index 2e2a174de8..8effa98cc8 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessEventNotifier.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessEventNotifier.java @@ -207,18 +207,20 @@ else if ( event.isStandardStreamCategory() ) ForkedProcessStandardOutErrEventListener listener = stdOutErrEventListeners.get( eventType ); if ( listener != null ) { - listener.handle( standardStreamEvent.getRunMode(), standardStreamEvent.getMessage(), newLine ); + listener.handle( standardStreamEvent.getMessage(), newLine, + standardStreamEvent.getRunMode(), standardStreamEvent.getTestRunId() ); } } else if ( event.isSysPropCategory() ) { SystemPropertyEvent systemPropertyEvent = (SystemPropertyEvent) event; RunMode runMode = systemPropertyEvent.getRunMode(); + Long testRunId = systemPropertyEvent.getTestRunId(); String key = systemPropertyEvent.getKey(); String value = systemPropertyEvent.getValue(); if ( propertyEventListener != null ) { - propertyEventListener.handle( runMode, key, value ); + propertyEventListener.handle( key, value, runMode, testRunId ); } } else if ( event.isTestCategory() ) diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessPropertyEventListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessPropertyEventListener.java index 98cf09260b..271f367a85 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessPropertyEventListener.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessPropertyEventListener.java @@ -27,5 +27,5 @@ */ public interface ForkedProcessPropertyEventListener { - void handle( RunMode runMode, String key, String value ); + void handle( String key, String value, RunMode runMode, Long testRunId ); } diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessStandardOutErrEventListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessStandardOutErrEventListener.java index 86b7bb9b8f..be8b5663fa 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessStandardOutErrEventListener.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkedProcessStandardOutErrEventListener.java @@ -27,5 +27,5 @@ */ public interface ForkedProcessStandardOutErrEventListener { - void handle( RunMode runMode, String output, boolean newLine ); + void handle( String output, boolean newLine, RunMode runMode, Long testRunId ); } diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/ForkedProcessEventNotifierTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/ForkedProcessEventNotifierTest.java index f59c2351df..dc3c6f381a 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/ForkedProcessEventNotifierTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/ForkedProcessEventNotifierTest.java @@ -540,7 +540,7 @@ public void testStdOutStream() throws Exception ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier(); StandardOutErrEventAssertionListener listener = - new StandardOutErrEventAssertionListener( NORMAL_RUN, "msg", false ); + new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, "msg", false ); notifier.setStdOutListener( listener ); EH eventHandler = new EH(); @@ -579,7 +579,7 @@ public void testStdOutStreamPrint() throws Exception ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier(); StandardOutErrEventAssertionListener listener = - new StandardOutErrEventAssertionListener( NORMAL_RUN, "", false ); + new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, "", false ); notifier.setStdOutListener( listener ); EH eventHandler = new EH(); @@ -618,7 +618,7 @@ public void testStdOutStreamPrintWithNull() throws Exception ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier(); StandardOutErrEventAssertionListener listener = - new StandardOutErrEventAssertionListener( NORMAL_RUN, null, false ); + new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, null, false ); notifier.setStdOutListener( listener ); EH eventHandler = new EH(); @@ -657,7 +657,7 @@ public void testStdOutStreamPrintln() throws Exception ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier(); StandardOutErrEventAssertionListener listener = - new StandardOutErrEventAssertionListener( NORMAL_RUN, "", true ); + new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, "", true ); notifier.setStdOutListener( listener ); EH eventHandler = new EH(); @@ -696,7 +696,7 @@ public void testStdOutStreamPrintlnWithNull() throws Exception ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier(); StandardOutErrEventAssertionListener listener = - new StandardOutErrEventAssertionListener( NORMAL_RUN, null, true ); + new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, null, true ); notifier.setStdOutListener( listener ); EH eventHandler = new EH(); @@ -735,7 +735,7 @@ public void testStdErrStream() throws Exception ForkedProcessEventNotifier notifier = new ForkedProcessEventNotifier(); StandardOutErrEventAssertionListener listener = - new StandardOutErrEventAssertionListener( NORMAL_RUN, "msg", false ); + new StandardOutErrEventAssertionListener( NORMAL_RUN, 1L, "msg", false ); notifier.setStdErrListener( listener ); EH eventHandler = new EH(); @@ -995,11 +995,12 @@ private static class PropertyEventAssertionListener implements ForkedProcessProp private final Map sysProps = System.getProperties(); private final AtomicInteger counter = new AtomicInteger(); - public void handle( RunMode runMode, String key, String value ) + public void handle( String key, String value, RunMode runMode, Long testRunId ) { called.set( true ); counter.incrementAndGet(); assertThat( runMode ).isEqualTo( NORMAL_RUN ); + assertThat( testRunId ).isEqualTo( 1L ); assertTrue( sysProps.containsKey( key ) ); assertThat( sysProps.get( key ) ).isEqualTo( value ); } @@ -1067,23 +1068,28 @@ private static class StandardOutErrEventAssertionListener implements ForkedProce { final AtomicBoolean called = new AtomicBoolean(); private final RunMode runMode; + private final long testRunId; private final String output; private final boolean newLine; - StandardOutErrEventAssertionListener( RunMode runMode, String output, boolean newLine ) + StandardOutErrEventAssertionListener( RunMode runMode, long testRunId, String output, boolean newLine ) { this.runMode = runMode; + this.testRunId = testRunId; this.output = output; this.newLine = newLine; } - public void handle( RunMode runMode, String output, boolean newLine ) + public void handle( String output, boolean newLine, RunMode runMode, Long testRunId ) { called.set( true ); assertThat( runMode ) .isEqualTo( this.runMode ); + assertThat( testRunId ) + .isEqualTo( this.testRunId ); + assertThat( output ) .isEqualTo( this.output );