This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/master by this push:
     new db99f16  [SUREFIRE-2046] Resolved TODOs. Updated callbacks 
ForkedProcessPropertyEventListener and ForkedProcessStandardOutErrEventListener.
db99f16 is described below

commit db99f166dfdbb5859e0b0777d7bc65a2ea322cd8
Author: tibordigana <[email protected]>
AuthorDate: Sat Mar 26 21:27:03 2022 +0100

    [SUREFIRE-2046] Resolved TODOs. Updated callbacks 
ForkedProcessPropertyEventListener and ForkedProcessStandardOutErrEventListener.
---
 .../surefire/booterclient/output/ForkClient.java   | 14 ++++++-------
 .../output/ForkedProcessEventNotifier.java         |  6 ++++--
 .../output/ForkedProcessPropertyEventListener.java |  2 +-
 .../ForkedProcessStandardOutErrEventListener.java  |  2 +-
 .../extensions/ForkedProcessEventNotifierTest.java | 24 ++++++++++++++--------
 5 files changed, 28 insertions(+), 20 deletions(-)

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 f89209b..fe5b9cf 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 final class ForkClient
     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 final class ForkClient
     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 @@ public final class ForkClient
         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<String, String> 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 2e2a174..8effa98 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 @@ public final class ForkedProcessEventNotifier
             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 98cf092..271f367 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 @@ import org.apache.maven.surefire.api.report.RunMode;
  */
 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 86b7bb9..be8b566 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 @@ import org.apache.maven.surefire.api.report.RunMode;
  */
 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 f59c235..dc3c6f3 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 class ForkedProcessEventNotifierTest
 
             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 class ForkedProcessEventNotifierTest
 
             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 class ForkedProcessEventNotifierTest
 
             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 class ForkedProcessEventNotifierTest
 
             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 class ForkedProcessEventNotifierTest
 
             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 class ForkedProcessEventNotifierTest
 
             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 @@ public class ForkedProcessEventNotifierTest
         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 @@ public class ForkedProcessEventNotifierTest
     {
         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 );
 

Reply via email to