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/05/08 22:16:26 UTC

[maven-surefire] branch SUREFIRE-1617 updated (fcba16c -> ed82d7f)

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

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


    omit fcba16c  [SUREFIRE-1617] Surefire fails with bad message when path contains whitespaces and colon
    omit 13ab2d3  did not call two JUnit4 tests
     add aeb3469  [SUREFIRE-1666] printSummary=false does not completely suppress the summary on the console
     new 815bcf5  did not call two JUnit4 tests
     new ed82d7f  [SUREFIRE-1617] Surefire fails with bad message when path contains whitespaces and colon

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (fcba16c)
            \
             N -- N -- N   refs/heads/SUREFIRE-1617 (ed82d7f)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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:
 .../surefire/report/DefaultReporterFactory.java    | 24 ++++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)


[maven-surefire] 01/02: did not call two JUnit4 tests

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

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

commit 815bcf51150f94bd1dea95fbda042c4ae3b90ce5
Author: tibordigana <ti...@apache.org>
AuthorDate: Mon Apr 8 05:35:32 2019 +0200

    did not call two JUnit4 tests
---
 maven-surefire-report-plugin/pom.xml                               | 7 +++++++
 .../org/apache/maven/plugins/surefire/report/Surefire597Test.java  | 6 +++---
 .../plugins/surefire/report/SurefireSchemaValidationTest.java      | 6 +++---
 .../plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java | 2 +-
 .../surefire/report/stubs/SurefireRepMavenProjectStub2.java        | 6 ++++--
 5 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/maven-surefire-report-plugin/pom.xml b/maven-surefire-report-plugin/pom.xml
index 18da79f..cf941ce 100644
--- a/maven-surefire-report-plugin/pom.xml
+++ b/maven-surefire-report-plugin/pom.xml
@@ -185,6 +185,13 @@
                         <classpathDependencyExclude>org.fusesource.jansi:jansi</classpathDependencyExclude>
                     </classpathDependencyExcludes>
                 </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.maven.surefire</groupId>
+                        <artifactId>surefire-shadefire</artifactId>
+                        <version>3.0.0-M3</version> <!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
+                    </dependency>
+                </dependencies>
             </plugin>
         </plugins>
     </build>
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java
index 02af6c4..96e0b33 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/Surefire597Test.java
@@ -19,10 +19,10 @@ package org.apache.maven.plugins.surefire.report;
  * under the License.
  */
 
+import junit.framework.TestCase;
 import org.apache.maven.doxia.module.xhtml.XhtmlSink;
 import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
 import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
-import org.junit.Test;
 
 import java.io.File;
 import java.io.StringWriter;
@@ -37,9 +37,9 @@ import static org.apache.maven.plugins.surefire.report.Utils.toSystemNewLine;
  * Prevent fom NPE if failure type and message is null however detail presents.
  */
 public class Surefire597Test
+        extends TestCase
 {
-    @Test
-    public void corruptedTestCaseFailureWithMissingErrorTypeAndMessage()
+    public void testCorruptedTestCaseFailureWithMissingErrorTypeAndMessage()
         throws Exception
     {
         File basedir = new File( "." ).getCanonicalFile();
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireSchemaValidationTest.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireSchemaValidationTest.java
index 008f206..9292fcf 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireSchemaValidationTest.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/SurefireSchemaValidationTest.java
@@ -28,20 +28,20 @@ import java.nio.file.Paths;
 
 import javax.xml.transform.stream.StreamSource;
 
+import junit.framework.TestCase;
 import org.apache.maven.shared.utils.io.DirectoryScanner;
 import org.fest.assertions.Assertions;
 import org.junit.Assert;
-import org.junit.Test;
 import org.xmlunit.validation.Languages;
 import org.xmlunit.validation.ValidationProblem;
 import org.xmlunit.validation.ValidationResult;
 import org.xmlunit.validation.Validator;
 
 public class SurefireSchemaValidationTest
+        extends TestCase
 {
 
-    @Test
-    public void validate_XMLs_against_schema()
+    public void testValidate_XMLs_against_schema()
         throws Exception
     {
         File basedir = getProjectBasedir();
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java
index 155b683..d1f2c11 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub.java
@@ -35,7 +35,7 @@ public class SurefireRepMavenProjectStub
      * {@inheritDoc}
      */
     @Override
-    public List getReportPlugins()
+    public List<ReportPlugin> getReportPlugins()
     {
         Reporting reporting = new Reporting();
 
diff --git a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java
index 23b1e4e..0a41412 100644
--- a/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java
+++ b/maven-surefire-report-plugin/src/test/java/org/apache/maven/plugins/surefire/report/stubs/SurefireRepMavenProjectStub2.java
@@ -21,6 +21,8 @@ package org.apache.maven.plugins.surefire.report.stubs;
 
 import java.util.ArrayList;
 import java.util.List;
+
+import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 
 /**
@@ -33,8 +35,8 @@ public class SurefireRepMavenProjectStub2
      * {@inheritDoc}
      */
     @Override
-    public List getReportPlugins()
+    public List<ReportPlugin> getReportPlugins()
     {
-        return new ArrayList();
+        return new ArrayList<>();
     }
 }


[maven-surefire] 02/02: [SUREFIRE-1617] Surefire fails with bad message when path contains whitespaces and colon

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

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

commit ed82d7f6cea63a6aa3aef057f5e784fc22854565
Author: tibordigana <ti...@apache.org>
AuthorDate: Sun Apr 7 23:06:45 2019 +0200

    [SUREFIRE-1617] Surefire fails with bad message when path contains whitespaces and colon
---
 .../booterclient/JarManifestForkConfiguration.java | 56 ++++++++++++--------
 .../JarManifestForkConfigurationTest.java          | 61 +++++++++++++++++++++-
 2 files changed, 94 insertions(+), 23 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
index 62fa4c1..1a3dd4f 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfiguration.java
@@ -31,8 +31,9 @@ import javax.annotation.Nullable;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Iterator;
@@ -43,8 +44,11 @@ import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static java.nio.file.Files.isDirectory;
 import static org.apache.maven.plugin.surefire.SurefireHelper.escapeToPlatformPath;
+import static org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.ClasspathElementUri.absolute;
+import static org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.ClasspathElementUri.relative;
 import static org.apache.maven.surefire.util.internal.StringUtils.NL;
 
 /**
@@ -168,14 +172,11 @@ public final class JarManifestForkConfiguration
                                          @Nonnull Path classPathElement,
                                          @Nonnull File dumpLogDirectory,
                                          boolean dumpError )
-            throws IOException
     {
         try
         {
-            String relativeUriPath = relativize( parent, classPathElement )
-                    .replace( '\\', '/' );
-
-            return new ClasspathElementUri( new URI( null, relativeUriPath, null ) );
+            String relativePath = relativize( parent, classPathElement );
+            return relative( escapeUri( relativePath, UTF_8 ) );
         }
         catch ( IllegalArgumentException e )
         {
@@ -190,15 +191,7 @@ public final class JarManifestForkConfiguration
                         .dumpStreamText( error, dumpLogDirectory );
             }
 
-            return new ClasspathElementUri( toAbsoluteUri( classPathElement ) );
-        }
-        catch ( URISyntaxException e )
-        {
-            // This is really unexpected, so fail
-            throw new IOException( "Could not create a relative path "
-                    + classPathElement
-                    + " against "
-                    + parent, e );
+            return absolute( toAbsoluteUri( classPathElement ) );
         }
     }
 
@@ -207,16 +200,37 @@ public final class JarManifestForkConfiguration
         final String uri;
         final boolean absolute;
 
-        ClasspathElementUri( String uri )
+        private ClasspathElementUri( String uri, boolean absolute )
         {
             this.uri = uri;
-            absolute = true;
+            this.absolute = absolute;
         }
 
-        ClasspathElementUri( URI uri )
+        static ClasspathElementUri absolute( String uri )
+        {
+            return new ClasspathElementUri( uri, true );
+        }
+
+        static ClasspathElementUri relative( String uri )
+        {
+            return new ClasspathElementUri( uri, false );
+        }
+    }
+
+    static String escapeUri( String input, Charset encoding )
+    {
+        try
+        {
+            String uriFormEncoded = URLEncoder.encode( input, encoding.name() );
+
+            String uriPathEncoded = uriFormEncoded.replaceAll( "\\+", "%20" );
+            uriPathEncoded = uriPathEncoded.replaceAll( "%2F|%5C", "/" );
+
+            return uriPathEncoded;
+        }
+        catch ( UnsupportedEncodingException e )
         {
-            this.uri = uri.toASCIIString();
-            absolute = false;
+            throw new IllegalStateException( "avoided by using Charset" );
         }
     }
 }
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
index 5e71238..08b3030 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
@@ -22,14 +22,18 @@ package org.apache.maven.plugin.surefire.booterclient;
 import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.nio.charset.Charset;
 import java.nio.file.Path;
 
 import org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.ClasspathElementUri;
 import org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.relativize;
 import static org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.toAbsoluteUri;
 import static org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.toClasspathElementUri;
+import static org.apache.maven.plugin.surefire.booterclient.JarManifestForkConfiguration.escapeUri;
 import static org.fest.assertions.Assertions.assertThat;
 
 import org.junit.AfterClass;
@@ -39,7 +43,9 @@ import org.junit.runner.RunWith;
 
 import static org.fest.util.Files.delete;
 import static org.fest.util.Files.newTemporaryFolder;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.same;
 import static org.powermock.api.mockito.PowerMockito.mock;
 import static org.powermock.api.mockito.PowerMockito.mockStatic;
@@ -88,6 +94,8 @@ public class JarManifestForkConfigurationTest
                 .thenReturn( "../../../.m2/repository/grp/art/1.0/art-1.0.jar" );
         when( toClasspathElementUri( same( parent ), same( classPathElement ), same( dumpDirectory ), anyBoolean() ) )
                 .thenCallRealMethod();
+        when( escapeUri( anyString(), any( Charset.class ) ) )
+                .thenCallRealMethod();
         assertThat( toClasspathElementUri( parent, classPathElement, dumpDirectory, true ).uri )
                 .isEqualTo( "../../../.m2/repository/grp/art/1.0/art-1.0.jar" );
     }
@@ -105,6 +113,8 @@ public class JarManifestForkConfigurationTest
                 .thenReturn( "../../../../../the Maven repo/grp/art/1.0/art-1.0.jar" );
         when( toClasspathElementUri( same( parent ), same( classPathElement ), same( dumpDirectory ), anyBoolean() ) )
                 .thenCallRealMethod();
+        when( escapeUri( anyString(), any( Charset.class ) ) )
+                .thenCallRealMethod();
         assertThat( toClasspathElementUri( parent, classPathElement, dumpDirectory, true ).uri )
                 .isEqualTo( "../../../../../the%20Maven%20repo/grp/art/1.0/art-1.0.jar" );
     }
@@ -122,6 +132,8 @@ public class JarManifestForkConfigurationTest
                 .thenReturn( "..\\..\\..\\Users\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar" );
         when( toClasspathElementUri( same( parent ), same( classPathElement ), same( dumpDirectory ), anyBoolean() ) )
                 .thenCallRealMethod();
+        when( escapeUri( anyString(), any( Charset.class )  ) )
+                .thenCallRealMethod();
         assertThat( toClasspathElementUri( parent, classPathElement, dumpDirectory, true ).uri )
                 .isEqualTo( "../../../Users/me/.m2/repository/grp/art/1.0/art-1.0.jar" );
     }
@@ -134,11 +146,14 @@ public class JarManifestForkConfigurationTest
         Path parent = mock( Path.class );
         when( parent.toString() ).thenReturn( "C:\\Windows\\Temp\\surefire" );
         Path classPathElement = mock( Path.class );
-        when( classPathElement.toString() ).thenReturn( "C:\\Test User\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar" );
+        when( classPathElement.toString() )
+                .thenReturn("C:\\Test User\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar");
         when( relativize( parent, classPathElement ) )
                 .thenReturn( "..\\..\\..\\Test User\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar" );
         when( toClasspathElementUri( same( parent ), same( classPathElement ), same( dumpDirectory ), anyBoolean() ) )
                 .thenCallRealMethod();
+        when( escapeUri( anyString(), any( Charset.class ) ) )
+                .thenCallRealMethod();
         assertThat( toClasspathElementUri( parent, classPathElement, dumpDirectory, true ).uri )
                 .isEqualTo( "../../../Test%20User/me/.m2/repository/grp/art/1.0/art-1.0.jar" );
     }
@@ -168,6 +183,8 @@ public class JarManifestForkConfigurationTest
                 .thenThrow( new IllegalArgumentException() );
         when( toClasspathElementUri( same( parent ), same( classPathElement ), same( dumpDirectory ), anyBoolean() ) )
                 .thenCallRealMethod();
+        when( escapeUri( anyString(), any( Charset.class ) ) )
+                .thenCallRealMethod();
         when( toAbsoluteUri( same( classPathElement ) ) )
                 .thenCallRealMethod();
         assertThat( toClasspathElementUri( parent, classPathElement, dumpDirectory, true ).uri )
@@ -175,6 +192,46 @@ public class JarManifestForkConfigurationTest
     }
 
     @Test
+    public void shouldEscapeUri()
+            throws Exception
+    {
+        assertThat( escapeUri( "a", UTF_8 ) ).isEqualTo( "a" );
+        assertThat( escapeUri( " ", UTF_8 ) ).isEqualTo( "%20" );
+        assertThat( escapeUri( "%", UTF_8 ) ).isEqualTo( "%25" );
+        assertThat( escapeUri( "+", UTF_8 ) ).isEqualTo( "%2B" );
+        assertThat( escapeUri( ",", UTF_8 ) ).isEqualTo( "%2C" );
+        assertThat( escapeUri( "/", UTF_8 ) ).isEqualTo( "/" );
+        assertThat( escapeUri( "7", UTF_8 ) ).isEqualTo( "7" );
+        assertThat( escapeUri( ":", UTF_8 ) ).isEqualTo( "%3A" );
+        assertThat( escapeUri( "@", UTF_8 ) ).isEqualTo( "%40" );
+        assertThat( escapeUri( "A", UTF_8 ) ).isEqualTo( "A" );
+        assertThat( escapeUri( "[", UTF_8 ) ).isEqualTo( "%5B" );
+        assertThat( escapeUri( "\\", UTF_8 ) ).isEqualTo( "/" );
+        assertThat( escapeUri( "]", UTF_8 ) ).isEqualTo( "%5D" );
+        assertThat( escapeUri( "`", UTF_8 ) ).isEqualTo( "%60" );
+        assertThat( escapeUri( "a", UTF_8 ) ).isEqualTo( "a" );
+        assertThat( escapeUri( "{", UTF_8 ) ).isEqualTo( "%7B" );
+        assertThat( escapeUri( "" + (char) 0xFF, UTF_8 ) ).isEqualTo( "%C3%BF" );
+
+        assertThat( escapeUri( "..\\..\\..\\Test : User\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar",
+                UTF_8 ) )
+                .isEqualTo( "../../../Test%20%3A%20User/me/.m2/repository/grp/art/1.0/art-1.0.jar" );
+
+        assertThat( escapeUri( "..\\..\\..\\Test : User\\me\\.m2\\repository\\grp\\art\\1.0\\art-1.0.jar",
+                Charset.defaultCharset() ) )
+                .isEqualTo( "../../../Test%20%3A%20User/me/.m2/repository/grp/art/1.0/art-1.0.jar" );
+
+        assertThat( escapeUri( "../../surefire-its/target/junit-pathWithÜmlaut_1/target/surefire", UTF_8 ) )
+                .isEqualTo( "../../surefire-its/target/junit-pathWith%C3%9Cmlaut_1/target/surefire" );
+
+        String source = "../../surefire-its/target/junit-pathWithÜmlaut_1/target/surefire";
+        String encoded = escapeUri( "../../surefire-its/target/junit-pathWithÜmlaut_1/target/surefire", UTF_8 );
+        String decoded = URLDecoder.decode( encoded, UTF_8.name() );
+        assertThat( decoded )
+                .isEqualTo( source );
+    }
+
+    @Test
     public void shouldRelativizeOnRealPlatform()
     {
         Path parentDir = new File( TMP, "test-parent-1" )
@@ -218,6 +275,6 @@ public class JarManifestForkConfigurationTest
         ClasspathElementUri testDirUriPath = toClasspathElementUri( parentDir, testDir, dumpDirectory, true );
 
         assertThat( testDirUriPath.uri )
-                .isEqualTo( "../@3%20test%20with%20white%20spaces" );
+                .isEqualTo( "../%403%20test%20with%20white%20spaces" );
     }
 }