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/01/19 01:34:41 UTC

[maven-surefire] branch junit5-displayname updated: finished with JUnit3 provider

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

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


The following commit(s) were added to refs/heads/junit5-displayname by this push:
     new 354c8fb  finished with JUnit3 provider
354c8fb is described below

commit 354c8fb82df8867a3cb9a84ed34f39c970473a83
Author: tibordigana <ti...@apache.org>
AuthorDate: Sat Jan 19 02:34:32 2019 +0100

    finished with JUnit3 provider
---
 .../surefire/report/StatelessXmlReporter.java      |  5 ++-
 .../maven/surefire/booter/ForkingRunListener.java  |  3 +-
 surefire-its/pom.xml                               |  8 +----
 .../its/jiras/Surefire943ReportContentIT.java      |  5 ++-
 .../junit/TestListenerInvocationHandler.java       | 41 ++++++++++++++++------
 .../maven/surefire/junit/JUnitTestSetTest.java     |  4 ++-
 6 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index a0a53cb..c54943c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -47,7 +47,6 @@ import static org.apache.maven.plugin.surefire.report.DefaultReporterFactory.Tes
 import static org.apache.maven.plugin.surefire.report.FileReporterUtils.stripIllegalFilenameChars;
 import static org.apache.maven.plugin.surefire.report.ReportEntryType.SUCCESS;
 import static org.apache.maven.surefire.util.internal.StringUtils.isBlank;
-import static org.apache.maven.surefire.util.internal.StringUtils.isNotBlank;
 
 @SuppressWarnings( { "javadoc", "checkstyle:javadoctype" } )
 // CHECKSTYLE_OFF: LineLength
@@ -406,7 +405,7 @@ public class StatelessXmlReporter
 
         String stackTrace = report.getStackTrace( trimStackTrace );
 
-        if ( isNotBlank( report.getMessage() ) )
+        if ( report.getMessage() != null && !report.getMessage().isEmpty() )
         {
             ppw.addAttribute( "message", extraEscape( report.getMessage(), true ) );
         }
@@ -417,7 +416,7 @@ public class StatelessXmlReporter
             SafeThrowable t = report.getStackTraceWriter().getThrowable();
             if ( t != null )
             {
-                if ( isNotBlank( t.getMessage() ) )
+                if ( t.getMessage() != null )
                 {
                     int delimiter = stackTrace.indexOf( ":" );
                     String type = delimiter == -1 ? stackTrace : stackTrace.substring( 0, delimiter );
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index c7a7acf..80d08db 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -41,7 +41,6 @@ import static org.apache.maven.surefire.util.internal.ObjectUtils.useNonNull;
 import static org.apache.maven.surefire.util.internal.StringUtils.encodeStringForForkCommunication;
 import static org.apache.maven.surefire.util.internal.StringUtils.escapeBytesToPrintable;
 import static org.apache.maven.surefire.util.internal.StringUtils.escapeToPrintable;
-import static org.apache.maven.surefire.util.internal.StringUtils.isBlank;
 
 /**
  * Encodes the full output of the test run to the stdout stream.
@@ -379,7 +378,7 @@ public class ForkingRunListener
 
     private static void nullableEncoding( StringBuilder stringBuilder, String source )
     {
-        if ( isBlank( source ) )
+        if ( source == null || source.isEmpty() )
         {
             stringBuilder.append( "null" );
         }
diff --git a/surefire-its/pom.xml b/surefire-its/pom.xml
index 50ee11d..a90df17 100644
--- a/surefire-its/pom.xml
+++ b/surefire-its/pom.xml
@@ -169,13 +169,7 @@
                     <forkMode>once</forkMode>
                     <argLine>-server -Xmx64m -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
                     <includes>
-                        <include>org/apache/**/*Platform*IT*.java</include>
-                        <include>org/apache/**/*Rerun*IT*.java</include>
-                        <include>org/apache/**/*Flaky*IT*.java</include>
-                        <include>Surefire1209RerunAndForkCountIT</include>
-                        <include>org/apache/**/*TestNG*IT*.java</include>
-                        <include>org/apache/**/*Junit3*IT*.java</include>
-                        <include>org/apache/**/AdditionalClasspathIT.java</include>
+                        <include>org/apache/**/*IT*.java</include>
                     </includes>
                     <!-- Pass current surefire version to the main suite so that it -->
                     <!-- can forward to all integration test projects. SUREFIRE-513 -->
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java
index 59d2170..0d3c4a3 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java
@@ -74,7 +74,7 @@ public class Surefire943ReportContentIT
         Xpp3Dom child = children[0];
 
         Assert.assertEquals( className, child.getAttribute( "classname" ) );
-        Assert.assertEquals( className, child.getAttribute( "name" ) );
+        Assert.assertEquals( "", child.getAttribute( "name" ) );
 
         Assert.assertEquals( "Expected error tag for failed BeforeClass method for " + className, 1,
                              child.getChildren( "error" ).length );
@@ -84,7 +84,6 @@ public class Surefire943ReportContentIT
 
         Assert.assertTrue( "time for test failure in BeforeClass is expected to be resonably low",
                            Double.compare( Double.parseDouble( child.getAttribute( "time" ) ), 2.0d ) <= 0 );
-
     }
 
     private void validateSkipped( OutputValidator validator, String className )
@@ -97,7 +96,7 @@ public class Surefire943ReportContentIT
         Xpp3Dom child = children[0];
 
         Assert.assertEquals( className, child.getAttribute( "classname" ) );
-        Assert.assertEquals( className, child.getAttribute( "name" ) );
+        Assert.assertEquals( "", child.getAttribute( "name" ) );
 
         Assert.assertEquals( "Expected skipped tag for ignored method for " + className, 1,
                              child.getChildren( "skipped" ).length );
diff --git a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java
index 78e78ad..e5d2232 100644
--- a/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java
+++ b/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java
@@ -20,14 +20,19 @@ package org.apache.maven.surefire.junit;
  */
 
 import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.HashSet;
 import java.util.Set;
+
 import org.apache.maven.surefire.report.LegacyPojoStackTraceWriter;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.RunListener;
 import org.apache.maven.surefire.report.SimpleReportEntry;
+import org.apache.maven.surefire.report.StackTraceWriter;
+
+import static org.apache.maven.surefire.report.SimpleReportEntry.withException;
+import static org.apache.maven.surefire.util.internal.TestClassMethodNameUtils.extractClassName;
+import static org.apache.maven.surefire.util.internal.TestClassMethodNameUtils.extractMethodName;
 
 /**
  * Invocation Handler for TestListener proxies to delegate to our {@link RunListener}
@@ -149,25 +154,24 @@ public class TestListenerInvocationHandler
     // Handler for TestListener.startTest(Test)
     private void handleStartTest( Object[] args )
     {
-        ReportEntry report = new SimpleReportEntry( args[0].getClass().getName(), args[0].toString() );
+        ReportEntry report = createStartEndReportEntry( args );
 
         reporter.testStarting( report );
     }
 
     // Handler for TestListener.addFailure(Test, Throwable)
     private void handleAddError( Object[] args )
-        throws IllegalAccessException, InvocationTargetException
+        throws ReflectiveOperationException
     {
-        ReportEntry report = SimpleReportEntry.withException( args[0].getClass().getName(), args[0].toString(),
-                                                              getStackTraceWriter( args ) );
+        ReportEntry report = toReportEntryWithException( args );
 
         reporter.testError( report );
 
         failedTestsSet.add( new FailedTest( args[0], Thread.currentThread() ) );
     }
 
-    private LegacyPojoStackTraceWriter getStackTraceWriter( Object[] args )
-        throws IllegalAccessException, InvocationTargetException
+    private static LegacyPojoStackTraceWriter toStackTraceWriter( Object[] args )
+        throws ReflectiveOperationException
     {
         String testName;
 
@@ -185,10 +189,9 @@ public class TestListenerInvocationHandler
     }
 
     private void handleAddFailure( Object[] args )
-        throws IllegalAccessException, InvocationTargetException
+        throws ReflectiveOperationException
     {
-        ReportEntry report = SimpleReportEntry.withException( args[0].getClass().getName(), args[0].toString(),
-                                                              getStackTraceWriter( args ) );
+        ReportEntry report = toReportEntryWithException( args );
 
         reporter.testFailed( report );
 
@@ -201,9 +204,25 @@ public class TestListenerInvocationHandler
 
         if ( !testHadFailed )
         {
-            ReportEntry report = new SimpleReportEntry( args[0].getClass().getName(), args[0].toString() );
+            ReportEntry report = createStartEndReportEntry( args );
 
             reporter.testSucceeded( report );
         }
     }
+
+    private static ReportEntry toReportEntryWithException( Object[] args )
+            throws ReflectiveOperationException
+    {
+        String description = args[0].toString();
+        String className = extractClassName( description );
+        String methodName = extractMethodName( description );
+        StackTraceWriter stackTraceWriter = toStackTraceWriter( args );
+        return withException( className, methodName, stackTraceWriter );
+    }
+
+    private static SimpleReportEntry createStartEndReportEntry( Object[] args )
+    {
+        String description = args[0].toString();
+        return new SimpleReportEntry( extractClassName( description ), extractMethodName( description ) );
+    }
 }
diff --git a/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java b/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java
index fad855e..1381303 100644
--- a/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java
+++ b/surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java
@@ -44,7 +44,9 @@ public class JUnitTestSetTest
         testSet.execute( listener, testClassLoader );
         List<ReportEntry> succeededTests = listener.getSucceededTests();
         assertEquals( 1, succeededTests.size() );
-        assertEquals( "testSuccess(org.apache.maven.surefire.junit.JUnitTestSetTest$AlwaysSucceeds)",
+        assertEquals( "org.apache.maven.surefire.junit.JUnitTestSetTest$AlwaysSucceeds",
+                succeededTests.get( 0 ).getSourceName() );
+        assertEquals( "testSuccess",
                       succeededTests.get( 0 ).getName() );
     }