You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2022/03/26 20:27:14 UTC

[maven-surefire] branch SUREFIRE-2046 created (now d4f7cb3)

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

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


      at d4f7cb3  [SUREFIRE-2046] Resolved TODOs. Updated callbacks ForkedProcessPropertyEventListener and ForkedProcessStandardOutErrEventListener.

This branch includes the following new commits:

     new d4f7cb3  [SUREFIRE-2046] Resolved TODOs. Updated callbacks ForkedProcessPropertyEventListener and ForkedProcessStandardOutErrEventListener.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[maven-surefire] 01/01: [SUREFIRE-2046] Resolved TODOs. Updated callbacks ForkedProcessPropertyEventListener and ForkedProcessStandardOutErrEventListener.

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d4f7cb375d44c6fcac52de8ed026875e30bde646
Author: tibordigana <ti...@apache.org>
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..99af04a 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 );