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 2020/10/08 18:32:35 UTC

[maven-surefire] branch gh-build-fix updated (85daaab -> f28e313)

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

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


    from 85daaab  [GH] workspace clean up
     new f919a47  [GH] build fix
     new f28e313  [GH] investigating

The 2 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.


Summary of changes:
 .../booterclient/ForkingRunListenerTest.java       | 75 +++++++++++++++++++---
 .../booterclient/output/ForkClientTest.java        | 13 ++++
 .../extensions/EventConsumerThreadTest.java        | 13 ++++
 .../extensions/ForkedProcessEventNotifierTest.java | 23 +++++++
 4 files changed, 116 insertions(+), 8 deletions(-)


[maven-surefire] 01/02: [GH] build fix

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

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

commit f919a473e9676d06290effd3ab2d4edd5fbd0ad8
Author: tibordigana <ti...@apache.org>
AuthorDate: Thu Oct 8 20:30:51 2020 +0200

    [GH] build fix
---
 .../booterclient/ForkingRunListenerTest.java       | 75 +++++++++++++++++++---
 1 file changed, 67 insertions(+), 8 deletions(-)

diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
index 8887e4d..a8eb91f 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java
@@ -53,6 +53,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
@@ -60,12 +61,8 @@ import static org.apache.maven.surefire.api.util.internal.Channels.newBufferedCh
 import static org.apache.maven.surefire.api.util.internal.Channels.newChannel;
 import static org.fest.assertions.Assertions.assertThat;
 import static org.fest.assertions.MapAssert.entry;
-import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
 
 /**
  * @author Kristian Rosenvold
@@ -299,16 +296,15 @@ public class ForkingRunListenerTest
         EH handler = new EH();
         CountdownCloseable countdown = new CountdownCloseable( mock( Closeable.class ), 1 );
         ConsoleLogger logger = mock( ConsoleLogger.class );
-        ForkNodeArguments arguments = mock( ForkNodeArguments.class );
-        when( arguments.dumpStreamText( anyString() ) ).thenReturn( new File( "" ) );
-        when( arguments.getConsoleLogger() ).thenReturn( logger );
+        ForkNodeArgumentsMock arguments = new ForkNodeArgumentsMock( logger, new File( "" ) );
         ReadableByteChannel channel = newChannel( new ByteArrayInputStream( stream ) );
         try ( EventConsumerThread t = new EventConsumerThread( "t", channel, handler, countdown, arguments ) )
         {
             t.start();
             countdown.awaitClosed();
             verifyZeroInteractions( logger );
-            verify( arguments, never() ).dumpStreamText( anyString() );
+            assertThat( arguments.isCalled() )
+                .isFalse();
             for ( int i = 0, size = handler.countEventsInCache(); i < size; i++ )
             {
                 events.add( handler.pullEvent() );
@@ -318,6 +314,69 @@ public class ForkingRunListenerTest
         }
     }
 
+    /**
+     * Threadsafe impl. Mockito and Powermock are not thread-safe.
+     */
+    private static class ForkNodeArgumentsMock implements ForkNodeArguments
+    {
+        private final ConcurrentLinkedQueue<String> dumpStreamText = new ConcurrentLinkedQueue<>();
+        private final ConcurrentLinkedQueue<String> logWarningAtEnd = new ConcurrentLinkedQueue<>();
+        private final ConsoleLogger logger;
+        private final File dumpStreamTextFile;
+
+        ForkNodeArgumentsMock( ConsoleLogger logger, File dumpStreamTextFile )
+        {
+            this.logger = logger;
+            this.dumpStreamTextFile = dumpStreamTextFile;
+        }
+
+        @Nonnull
+        @Override
+        public String getSessionId()
+        {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public int getForkChannelId()
+        {
+            return 0;
+        }
+
+        @Nonnull
+        @Override
+        public File dumpStreamText( @Nonnull String text )
+        {
+            dumpStreamText.add( text );
+            return dumpStreamTextFile;
+        }
+
+        @Nonnull
+        @Override
+        public File dumpStreamException( @Nonnull Throwable t )
+        {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public void logWarningAtEnd( @Nonnull String text )
+        {
+            logWarningAtEnd.add( text );
+        }
+
+        @Nonnull
+        @Override
+        public ConsoleLogger getConsoleLogger()
+        {
+            return logger;
+        }
+
+        boolean isCalled()
+        {
+            return !dumpStreamText.isEmpty() || !logWarningAtEnd.isEmpty();
+        }
+    }
+
     private static class EH implements EventHandler<Event>
     {
         private final BlockingQueue<Event> cache = new LinkedBlockingQueue<>();


[maven-surefire] 02/02: [GH] investigating

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

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

commit f28e31390312da084e3cb5ea3e5b27b03dedd8df
Author: tibordigana <ti...@apache.org>
AuthorDate: Thu Oct 8 20:32:26 2020 +0200

    [GH] investigating
---
 .../booterclient/output/ForkClientTest.java        | 13 ++++++++++++
 .../extensions/EventConsumerThreadTest.java        | 13 ++++++++++++
 .../extensions/ForkedProcessEventNotifierTest.java | 23 ++++++++++++++++++++++
 3 files changed, 49 insertions(+)

diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClientTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClientTest.java
index 60d48f3..7f2dfd0 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClientTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClientTest.java
@@ -54,7 +54,10 @@ import org.apache.maven.surefire.api.report.SafeThrowable;
 import org.apache.maven.surefire.api.report.SimpleReportEntry;
 import org.apache.maven.surefire.api.report.StackTraceWriter;
 import org.apache.maven.surefire.api.report.TestSetReportEntry;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestName;
+import org.junit.runner.Description;
 import org.mockito.ArgumentCaptor;
 
 import javax.annotation.Nonnull;
@@ -107,6 +110,16 @@ public class ForkClientTest
 {
     private static final int ELAPSED_TIME = 102;
 
+    @Rule
+    public final TestName test = new TestName()
+    {
+        @Override
+        protected void starting( Description d )
+        {
+            System.out.println( "Starting " + d.getClassName() + "." + d.getMethodName() + "() ..." );
+        }
+    };
+
     @Test( expected = NullPointerException.class )
     public void shouldFailOnNPE()
     {
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
index 63287df..7b520a3 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/EventConsumerThreadTest.java
@@ -51,7 +51,10 @@ import org.apache.maven.surefire.extensions.EventHandler;
 import org.apache.maven.surefire.extensions.ForkNodeArguments;
 import org.apache.maven.surefire.extensions.util.CountdownCloseable;
 import org.fest.assertions.Condition;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestName;
+import org.junit.runner.Description;
 
 import javax.annotation.Nonnull;
 import java.io.Closeable;
@@ -187,6 +190,16 @@ public class EventConsumerThreadTest
     private static final byte[] PATTERN2_BYTES =
         new byte[]{(byte) -30, (byte) -126, (byte) -84, 'a', 'b', (byte) 0xc2, (byte) 0xa9, 'c'};
 
+    @Rule
+    public final TestName test = new TestName()
+    {
+        @Override
+        protected void starting( Description d )
+        {
+            System.out.println( "Starting " + d.getClassName() + "." + d.getMethodName() + "() ..." );
+        }
+    };
+
     @Test
     public void shouldDecodeHappyCase() throws Exception
     {
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 06fba21..9d2f60a 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
@@ -49,6 +49,8 @@ import org.junit.experimental.theories.FromDataPoints;
 import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.rules.ExpectedException;
+import org.junit.rules.TestName;
+import org.junit.runner.Description;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.powermock.core.classloader.annotations.PowerMockIgnore;
@@ -105,6 +107,16 @@ public class ForkedProcessEventNotifierTest
         @Rule
         public final ExpectedException rule = none();
 
+        @Rule
+        public final TestName test = new TestName()
+        {
+            @Override
+            protected void starting( Description d )
+            {
+                System.out.println( "Starting " + d.getClassName() + "." + d.getMethodName() + "() ..." );
+            }
+        };
+
         @Test
         public void shouldHaveSystemProperty() throws Exception
         {
@@ -957,6 +969,17 @@ public class ForkedProcessEventNotifierTest
     @RunWith( Theories.class )
     public static class ReportEntryTest
     {
+
+        @Rule
+        public final TestName test = new TestName()
+        {
+            @Override
+            protected void starting( Description d )
+            {
+                System.out.println( "Starting " + d.getClassName() + "." + d.getMethodName() + "() ..." );
+            }
+        };
+
         @DataPoints( value = "operation" )
         @SuppressWarnings( "checkstyle:visibilitymodifier" )
         public static String[][] operations = { { "testSetStarting", "setTestSetStartingListener" },