maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tibordig...@apache.org
Subject [1/2] maven-surefire git commit: [SUREFIRE-1472] Multibranch Pipeline supports JDK 7-10 Maven 3.2-3.5 Linux Windows [Forced Update!]
Date Fri, 16 Feb 2018 22:49:17 GMT
Repository: maven-surefire
Updated Branches:
  refs/heads/SUREFIRE-1463 334fb462a -> ea8932326 (forced update)


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ea893232/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java
b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java
index e41dbaa..df6ca1c 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerUtilTest.java
@@ -32,7 +32,6 @@ import org.junit.experimental.theories.DataPoint;
 import org.junit.experimental.theories.Theories;
 import org.junit.experimental.theories.Theory;
 import org.junit.rules.ExpectedException;
-import org.junit.rules.Stopwatch;
 import org.junit.runner.JUnitCore;
 import org.junit.runner.Result;
 import org.junit.runner.RunWith;
@@ -46,7 +45,6 @@ import static org.apache.maven.surefire.junitcore.pc.ParallelComputerUtil.*;
 import static org.apache.maven.surefire.junitcore.JUnitCoreParameters.*;
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.*;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
 
 /**
  * Testing an algorithm in {@link ParallelComputerUtil} which configures
@@ -70,9 +68,6 @@ public final class ParallelComputerUtilTest
     @Rule
     public final ExpectedException exception = ExpectedException.none();
 
-    @Rule
-    public final Stopwatch stopwatch = new Stopwatch() {};
-
     @BeforeClass
     public static void beforeClass()
     {
@@ -968,7 +963,6 @@ public final class ParallelComputerUtilTest
 
     @Test
     public void withoutShutdown()
-        throws TestSetFailedException, ExecutionException, InterruptedException
     {
         Map<String, String> properties = new HashMap<String, String>();
         properties.put(PARALLEL_KEY, "methods");
@@ -976,9 +970,12 @@ public final class ParallelComputerUtilTest
         JUnitCoreParameters params = new JUnitCoreParameters( properties );
         ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params );
         ParallelComputer pc = pcBuilder.buildComputer();
-        Result result = new JUnitCore().run( pc, TestClass.class );
-        long timeSpent = stopwatch.runtime( MILLISECONDS );
-        long deltaTime = 500L;
+        final JUnitCore core = new JUnitCore();
+        final long t1 = System.currentTimeMillis();
+        final Result result = core.run( pc, TestClass.class );
+        final long t2 = System.currentTimeMillis();
+        long timeSpent = t2 - t1;
+        final long deltaTime = 500L;
 
         assertTrue( result.wasSuccessful() );
         assertThat( result.getRunCount(), is( 3 ) );
@@ -989,7 +986,7 @@ public final class ParallelComputerUtilTest
 
     @Test
     public void shutdown()
-        throws TestSetFailedException, ExecutionException, InterruptedException
+        throws TestSetFailedException
     {
         // The JUnitCore returns after 2.5s.
         // The test-methods in TestClass are NOT interrupted, and return normally after 5s.
@@ -1000,9 +997,12 @@ public final class ParallelComputerUtilTest
         JUnitCoreParameters params = new JUnitCoreParameters( properties );
         ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params );
         ParallelComputer pc = pcBuilder.buildComputer();
-        new JUnitCore().run( pc, TestClass.class );
-        long timeSpent = stopwatch.runtime( MILLISECONDS );
-        long deltaTime = 500L;
+        final JUnitCore core = new JUnitCore();
+        final long t1 = System.currentTimeMillis();
+        core.run( pc, TestClass.class );
+        final long t2 = System.currentTimeMillis();
+        final long timeSpent = t2 - t1;
+        final long deltaTime = 500L;
 
         assertEquals( 5000L, timeSpent, deltaTime );
         String description = pc.describeElapsedTimeout();
@@ -1013,19 +1013,22 @@ public final class ParallelComputerUtilTest
 
     @Test
     public void forcedShutdown()
-        throws TestSetFailedException, ExecutionException, InterruptedException
+        throws TestSetFailedException
     {
         // The JUnitCore returns after 2.5s, and the test-methods in TestClass are interrupted.
         Map<String, String> properties = new HashMap<String, String>();
         properties.put(PARALLEL_KEY, "methods");
         properties.put(THREADCOUNTMETHODS_KEY, "2");
-        properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(2.5d));
+        properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString( 2.5d ));
         JUnitCoreParameters params = new JUnitCoreParameters( properties );
         ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params );
         ParallelComputer pc = pcBuilder.buildComputer();
-        new JUnitCore().run( pc, TestClass.class );
-        long timeSpent = stopwatch.runtime( MILLISECONDS );
-        long deltaTime = 500L;
+        final JUnitCore core = new JUnitCore();
+        final long t1 = System.currentTimeMillis();
+        core.run( pc, TestClass.class );
+        final long t2 = System.currentTimeMillis();
+        final long timeSpent = t2 - t1;
+        final long deltaTime = 500L;
 
         assertEquals( 2500L, timeSpent, deltaTime );
         String description = pc.describeElapsedTimeout();
@@ -1036,7 +1039,7 @@ public final class ParallelComputerUtilTest
 
     @Test
     public void timeoutAndForcedShutdown()
-        throws TestSetFailedException, ExecutionException, InterruptedException
+        throws TestSetFailedException
     {
         // The JUnitCore returns after 3.5s and the test-methods in TestClass are timed out
after 2.5s.
         // No new test methods are scheduled for execution after 2.5s.
@@ -1044,14 +1047,17 @@ public final class ParallelComputerUtilTest
         Map<String, String> properties = new HashMap<String, String>();
         properties.put(PARALLEL_KEY, "methods");
         properties.put(THREADCOUNTMETHODS_KEY, "2");
-        properties.put(PARALLEL_TIMEOUT_KEY, Double.toString(2.5d));
-        properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString(3.5d));
+        properties.put(PARALLEL_TIMEOUT_KEY, Double.toString( 2.5d ));
+        properties.put(PARALLEL_TIMEOUTFORCED_KEY, Double.toString( 3.5d ));
         JUnitCoreParameters params = new JUnitCoreParameters( properties );
         ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params );
         ParallelComputer pc = pcBuilder.buildComputer();
-        new JUnitCore().run( pc, TestClass.class );
-        long timeSpent = stopwatch.runtime( MILLISECONDS );
-        long deltaTime = 500L;
+        final JUnitCore core = new JUnitCore();
+        final long t1 = System.currentTimeMillis();
+        core.run( pc, TestClass.class );
+        final long t2 = System.currentTimeMillis();
+        final long timeSpent = t2 - t1;
+        final long deltaTime = 500L;
 
         assertEquals( 3500L, timeSpent, deltaTime );
         String description = pc.describeElapsedTimeout();
@@ -1073,9 +1079,12 @@ public final class ParallelComputerUtilTest
         JUnitCoreParameters params = new JUnitCoreParameters( properties );
         ParallelComputerBuilder pcBuilder = new ParallelComputerBuilder( logger, params );
         ParallelComputer pc = pcBuilder.buildComputer();
-        new JUnitCore().run( pc, TestClass.class );
-        long timeSpent = stopwatch.runtime( MILLISECONDS );
-        long deltaTime = 500L;
+        final JUnitCore core = new JUnitCore();
+        final long t1 = System.currentTimeMillis();
+        core.run( pc, TestClass.class );
+        final long t2 = System.currentTimeMillis();
+        final long timeSpent = t2 - t1;
+        final long deltaTime = 500L;
 
         assertEquals( 3500L, timeSpent, deltaTime );
         String description = pc.describeElapsedTimeout();

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ea893232/surefire-report-parser/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-report-parser/pom.xml b/surefire-report-parser/pom.xml
index 60d570f..c91a9ed 100644
--- a/surefire-report-parser/pom.xml
+++ b/surefire-report-parser/pom.xml
@@ -54,16 +54,18 @@
     <plugins>
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <redirectTestOutputToFile>true</redirectTestOutputToFile>
-        </configuration>
         <dependencies>
           <dependency>
             <groupId>org.apache.maven.surefire</groupId>
-            <artifactId>surefire-junit47</artifactId>
-            <version>2.12.4</version>
+            <artifactId>surefire-shadefire</artifactId>
+            <version>2.12.4</version> <!-- ${shadedVersion}, but resolved
due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
           </dependency>
         </dependencies>
+        <configuration>
+          <includes>
+            <include>**/JUnit4SuiteTest.java</include>
+          </includes>
+        </configuration>
       </plugin>
       <plugin>
         <!-- Do we need shading here ?? -->

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ea893232/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java
----------------------------------------------------------------------
diff --git a/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java
b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java
new file mode 100644
index 0000000..142ca9d
--- /dev/null
+++ b/surefire-report-parser/src/test/java/org/apache/maven/plugins/surefire/report/JUnit4SuiteTest.java
@@ -0,0 +1,46 @@
+package org.apache.maven.plugins.surefire.report;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Adapt the JUnit4 tests which use only annotations to the JUnit3 test suite.
+ *
+ * @author Tibor Digana (tibor17)
+ * @since 2.21.0
+ */
+@Suite.SuiteClasses( {
+        ReportTestCaseTest.class,
+        ReportTestSuiteTest.class,
+        SurefireReportParserTest.class,
+        TestSuiteXmlParserTest.class
+} )
+@RunWith( Suite.class )
+public class JUnit4SuiteTest
+{
+    public static Test suite()
+    {
+        return new JUnit4TestAdapter( JUnit4SuiteTest.class );
+    }
+}


Mime
View raw message