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 2018/12/19 04:56:29 UTC

[maven-surefire] branch master updated: Build fix (linux-jdk12-maven3.2.x) Surefire1535TestNGParallelSuitesIT.forks2Redirected:86 File doesn't exist: target/surefire-reports-2/TEST-TestSuite.xml

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

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


The following commit(s) were added to refs/heads/master by this push:
     new c1b925f  Build fix (linux-jdk12-maven3.2.x) Surefire1535TestNGParallelSuitesIT.forks2Redirected:86 File doesn't exist: target/surefire-reports-2/TEST-TestSuite.xml
c1b925f is described below

commit c1b925f3aa3ed8772d6ddee3d17851366f45dc60
Author: Tibor17 <ti...@apache.org>
AuthorDate: Wed Dec 19 01:01:36 2018 +0100

    Build fix (linux-jdk12-maven3.2.x) Surefire1535TestNGParallelSuitesIT.forks2Redirected:86 File doesn't exist: target/surefire-reports-2/TEST-TestSuite.xml
---
 .../maven/surefire/its/fixture/TestFile.java       | 11 ++---
 .../jiras/Surefire1535TestNGParallelSuitesIT.java  | 51 +++++++++++++++++++++-
 .../surefire-1535-parallel-testng/pom.xml          | 10 ++++-
 3 files changed, 63 insertions(+), 9 deletions(-)

diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
index 29e8038..f7f05f7 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java
@@ -23,8 +23,8 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.net.URI;
 import java.nio.charset.Charset;
 import java.util.List;
@@ -33,6 +33,7 @@ import org.apache.commons.io.FileUtils;
 import junit.framework.Assert;
 import org.hamcrest.Matcher;
 
+import static java.nio.charset.Charset.defaultCharset;
 import static junit.framework.Assert.assertTrue;
 import static org.hamcrest.Matchers.containsString;
 
@@ -49,7 +50,7 @@ public class TestFile
 
     public TestFile( File file, OutputValidator surefireVerifier )
     {
-        this( file, Charset.defaultCharset(), surefireVerifier);
+        this( file, defaultCharset(), surefireVerifier);
     }
 
     public TestFile( File file, Charset charset, OutputValidator surefireVerifier )
@@ -57,7 +58,7 @@ public class TestFile
         try
         {
             this.file = file.getCanonicalFile();
-            this.encoding = charset == null ? Charset.defaultCharset() : charset;
+            this.encoding = charset == null ? defaultCharset() : charset;
             this.surefireVerifier = surefireVerifier;
         }
         catch ( IOException e )
@@ -103,7 +104,7 @@ public class TestFile
     public String slurpFile()
     {
         StringBuilder sb = new StringBuilder();
-        try ( BufferedReader reader = new BufferedReader( new FileReader( file ) ) )
+        try ( BufferedReader reader = new BufferedReader( new InputStreamReader( getFileInputStream(), encoding ) ) )
         {
             for ( String line = reader.readLine(); line != null; line = reader.readLine() )
             {
@@ -121,7 +122,7 @@ public class TestFile
     {
         try
         {
-            return FileUtils.readFileToString( file );
+            return FileUtils.readFileToString( file, encoding );
         }
         catch ( IOException e )
         {
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java
index ec6ea34..b6e534e 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java
@@ -31,6 +31,7 @@ import java.nio.charset.Charset;
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.is;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class Surefire1535TestNGParallelSuitesIT
         extends SurefireJUnit4IntegrationTestCase
@@ -38,8 +39,8 @@ public class Surefire1535TestNGParallelSuitesIT
     private static final Charset UTF8 = Charset.forName( "UTF-8" );
     private static final String TEST_RESULT_1 = platformEncoding( "Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, " );
     private static final String TEST_RESULT_2 = platformEncoding( "Tests run: 2, Failures: 0, Errors: 0, Skipped: 0" );
-    private static final String SUITE1 = platformEncoding( "Suite1.xml" );
-    private static final String SUITE2 = platformEncoding( "Suite2.xml" );
+    private static final String SUITE1 = platformEncoding( "Suite1" );
+    private static final String SUITE2 = platformEncoding( "Suite2" );
     private static final String TEST1 = platformEncoding( "test 1" );
     private static final String TEST2 = platformEncoding( "test 2" );
     private static final String TEST_SUITE = platformEncoding( "Running TestSuite" );
@@ -55,10 +56,23 @@ public class Surefire1535TestNGParallelSuitesIT
         TestFile testFile = validator.getSurefireReportsFile( "../surefire-reports-1/TEST-TestSuite.xml", UTF8 );
         testFile.assertFileExists();
         testFile.assertContainsText( "<testcase name=\"test\" classname=\"it.ParallelTest" );
+        String xml = testFile.readFileToString();
+        boolean parallelTest11 = xml.contains( "<testcase name=\"test\" classname=\"it.ParallelTest1\"" );
+        boolean parallelTest12 = xml.contains( "<testcase name=\"test\" classname=\"it.ParallelTest2\"" );
+        assertThat( parallelTest11 ^ parallelTest12 )
+                .isTrue();
 
         testFile = validator.getSurefireReportsFile( "../surefire-reports-2/TEST-TestSuite.xml", UTF8 );
         testFile.assertFileExists();
         testFile.assertContainsText( "<testcase name=\"test\" classname=\"it.ParallelTest" );
+        xml = testFile.readFileToString();
+        boolean parallelTest21 = xml.contains( "<testcase name=\"test\" classname=\"it.ParallelTest1\"" );
+        boolean parallelTest22 = xml.contains( "<testcase name=\"test\" classname=\"it.ParallelTest2\"" );
+        assertThat( parallelTest21 ^ parallelTest22 )
+                .isTrue();
+
+        assertThat( parallelTest11 && parallelTest22 || parallelTest12 && parallelTest21 )
+                .isTrue();
 
         validator.assertThatLogLine( containsString( TEST_RESULT_2 ), is( 1 ) )
                 .assertThatLogLine( containsString( TEST_RESULT_1 ), is( 2 ) )
@@ -81,10 +95,43 @@ public class Surefire1535TestNGParallelSuitesIT
         TestFile testFile = validator.getSurefireReportsFile( "../surefire-reports-1/TEST-TestSuite.xml", UTF8 );
         testFile.assertFileExists();
         testFile.assertContainsText( "<testcase name=\"test\" classname=\"it.ParallelTest" );
+        String xml = testFile.readFileToString();
+        boolean parallelTest11 = xml.contains( "<testcase name=\"test\" classname=\"it.ParallelTest1\"" );
+        boolean parallelTest12 = xml.contains( "<testcase name=\"test\" classname=\"it.ParallelTest2\"" );
+        assertThat( parallelTest11 ^ parallelTest12 )
+                .isTrue();
+        String log = validator.getSurefireReportsFile( "../surefire-reports-1/TestSuite-output.txt", UTF8 )
+                .readFileToString();
+        assertThat( log.contains( TEST1 ) )
+                .isEqualTo( parallelTest11 );
+        assertThat( log.contains( SUITE1 ) )
+                .isEqualTo( parallelTest11 );
+        assertThat( log.contains( TEST2 ) )
+                .isEqualTo( parallelTest12 );
+        assertThat( log.contains( SUITE2 ) )
+                .isEqualTo( parallelTest12 );
 
         testFile = validator.getSurefireReportsFile( "../surefire-reports-2/TEST-TestSuite.xml", UTF8 );
         testFile.assertFileExists();
         testFile.assertContainsText( "<testcase name=\"test\" classname=\"it.ParallelTest" );
+        xml = testFile.readFileToString();
+        boolean parallelTest21 = xml.contains( "<testcase name=\"test\" classname=\"it.ParallelTest1\"" );
+        boolean parallelTest22 = xml.contains( "<testcase name=\"test\" classname=\"it.ParallelTest2\"" );
+        assertThat( parallelTest21 ^ parallelTest22 )
+                .isTrue();
+        log = validator.getSurefireReportsFile( "../surefire-reports-2/TestSuite-output.txt", UTF8 )
+                .readFileToString();
+        assertThat( log.contains( TEST1 ) )
+                .isEqualTo( parallelTest21 );
+        assertThat( log.contains( SUITE1 ) )
+                .isEqualTo( parallelTest21 );
+        assertThat( log.contains( TEST2 ) )
+                .isEqualTo( parallelTest22 );
+        assertThat( log.contains( SUITE2 ) )
+                .isEqualTo( parallelTest22 );
+
+        assertThat( parallelTest11 && parallelTest22 || parallelTest12 && parallelTest21 )
+                .isTrue();
 
         validator.assertThatLogLine( containsString( TEST_RESULT_2 ), is( 1 ) )
                 .assertThatLogLine( containsString( TEST_RESULT_1 ), is( 2 ) )
diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml b/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml
index 4fcc715..6aa6599 100644
--- a/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml
+++ b/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml
@@ -37,8 +37,8 @@
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
-            <version>5.7</version>
-            <classifier>jdk15</classifier>
+            <version>6.13.1</version>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 
@@ -71,6 +71,12 @@
                         <suiteXmlFile>src/test/resources/Suite1.xml</suiteXmlFile>
                         <suiteXmlFile>src/test/resources/Suite2.xml</suiteXmlFile>
                     </suiteXmlFiles>
+                    <properties>
+                        <property>
+                            <name>surefire.testng.verbose</name>
+                            <value>1</value>
+                        </property>
+                    </properties>
                 </configuration>
             </plugin>
         </plugins>