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 2019/10/01 11:58:45 UTC

[maven-surefire] branch SUREFIRE-1584 created (now 4ad77ed)

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

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


      at 4ad77ed  Fix missing checkstyle padding

This branch includes the following new commits:

     new 573e1ac  Resolve duplicated code in Adapter
     new 4ad77ed  Fix missing checkstyle padding

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.



[maven-surefire] 02/02: Fix missing checkstyle padding

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

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

commit 4ad77edc8f775f79c1aa162b5347a41a0b933fcc
Author: Col-E <mc...@gmu.edu>
AuthorDate: Tue Oct 1 07:55:22 2019 -0400

    Fix missing checkstyle padding
---
 .../org/apache/maven/surefire/junitplatform/RunListenerAdapter.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
index aeeb7ec..668c451 100644
--- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
@@ -257,7 +257,7 @@ final class RunListenerAdapter
             }
             else
             {
-                source = new String[] {realClassName, realClassName};
+                source = new String[] { realClassName, realClassName };
             }
 
             String methodName = methodSource.getMethodName();


[maven-surefire] 01/02: Resolve duplicated code in Adapter

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

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

commit 573e1ac86940183c6a679ca6b2b54ebbe122c223
Author: Col-E <mc...@gmu.edu>
AuthorDate: Tue Oct 1 07:50:49 2019 -0400

    Resolve duplicated code in Adapter
---
 .../surefire/junitplatform/RunListenerAdapter.java | 68 +++++++++-------------
 1 file changed, 27 insertions(+), 41 deletions(-)

diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
index 1205028..aeeb7ec 100644
--- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
@@ -214,6 +214,16 @@ final class RunListenerAdapter
         return new PojoStackTraceWriter( realClassName, realMethodName, throwable );
     }
 
+    private String[] toClassMethodName( TestIdentifier testIdentifier )
+    {
+        return toClassMethodName( testIdentifier, true );
+    }
+
+    public String[] toClassMethodNameWithoutPlan( TestIdentifier testIdentifier )
+    {
+        return toClassMethodName( testIdentifier, false );
+    }
+
     /**
      * <ul>
      *     <li>[0] class name - used in stacktrace parser</li>
@@ -223,9 +233,11 @@ final class RunListenerAdapter
      * </ul>
      *
      * @param testIdentifier a class or method
+     * @param usePlan {@code true} for using the test-plan to fetch sources.
+     *                {@code false} to rely on fallbacks.
      * @return 4 elements string array
      */
-    private String[] toClassMethodName( TestIdentifier testIdentifier )
+    private String[] toClassMethodName( TestIdentifier testIdentifier, boolean usePlan )
     {
         Optional<TestSource> testSource = testIdentifier.getSource();
         String display = testIdentifier.getDisplayName();
@@ -235,45 +247,19 @@ final class RunListenerAdapter
             MethodSource methodSource = testSource.map( MethodSource.class::cast ).get();
             String realClassName = methodSource.getClassName();
 
-            String[] source = testPlan.getParent( testIdentifier )
-                    .map( this::toClassMethodName )
-                    .map( s -> new String[] { s[0], s[1] } )
-                    .orElse( new String[] { realClassName, realClassName } );
-
-            String methodName = methodSource.getMethodName();
-            boolean useMethod = display.equals( methodName ) || display.equals( methodName + "()" );
-            String resolvedMethodName = useMethod ? methodName : display;
-
-            return new String[] { source[0], source[1], methodName, resolvedMethodName };
-        }
-        else if ( testSource.filter( ClassSource.class::isInstance ).isPresent() )
-        {
-            ClassSource classSource = testSource.map( ClassSource.class::cast ).get();
-            String className = classSource.getClassName();
-            String simpleClassName = className.substring( 1 + className.lastIndexOf( '.' ) );
-            String source = display.equals( simpleClassName ) ? className : display;
-            return new String[] { className, source, null, null };
-        }
-        else
-        {
-            String source = testPlan.getParent( testIdentifier )
-                    .map( TestIdentifier::getDisplayName )
-                    .orElse( display );
-            return new String[] { source, source, display, display };
-        }
-    }
-
-    public String[] toClassMethodNameWithoutPlan( TestIdentifier testIdentifier )
-    {
-        Optional<TestSource> testSource = testIdentifier.getSource();
-        String display = testIdentifier.getDisplayName();
-
-        if ( testSource.filter( MethodSource.class::isInstance ).isPresent() )
-        {
-            MethodSource methodSource = testSource.map( MethodSource.class::cast ).get();
-            String realClassName = methodSource.getClassName();
+            String[] source;
+            if ( usePlan )
+            {
+               source = testPlan.getParent( testIdentifier )
+                        .map( this::toClassMethodName )
+                        .map( s -> new String[] { s[0], s[1] } )
+                        .orElse( new String[] { realClassName, realClassName } );
+            }
+            else
+            {
+                source = new String[] {realClassName, realClassName};
+            }
 
-            String[] source = new String[] {realClassName, realClassName};
             String methodName = methodSource.getMethodName();
             boolean useMethod = display.equals( methodName ) || display.equals( methodName + "()" );
             String resolvedMethodName = useMethod ? methodName : display;
@@ -290,8 +276,8 @@ final class RunListenerAdapter
         }
         else
         {
-            String source = testPlan == null ? display : testPlan.getParent( testIdentifier ).map(
-                    TestIdentifier::getDisplayName ).orElse( display );
+            String source = !usePlan ? display : testPlan.getParent( testIdentifier )
+                    .map( TestIdentifier::getDisplayName ).orElse( display );
             return new String[] {source, source, display, display};
         }
     }