Repository: maven-surefire
Updated Branches:
  refs/heads/master bab3175e8 -> 3680bff6d


Add convinient method to check for the currently used Java Version


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/f49249ec
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/f49249ec
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/f49249ec

Branch: refs/heads/master
Commit: f49249ecb877d98477644dcd8a7ab5eba603972c
Parents: bab3175
Author: Benedikt Ritter <benerit...@gmail.com>
Authored: Sat Sep 10 15:13:24 2016 +0200
Committer: Tibor17 <tibo...@lycos.com>
Committed: Sun Sep 18 23:18:09 2016 +0200

----------------------------------------------------------------------
 surefire-integration-tests/pom.xml              |  4 +++
 .../its/CheckTestNgListenerReporterIT.java      | 27 ++++++++++----------
 .../surefire/its/Junit47WithCucumberIT.java     |  6 +++--
 .../surefire/its/fixture/HelperAssertions.java  | 13 +++++++++-
 .../Surefire1177TestngParallelSuitesIT.java     |  7 +++--
 .../its/jiras/Surefire1211JUnitTestNgIT.java    |  2 +-
 6 files changed, 38 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f49249ec/surefire-integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/pom.xml 
b/surefire-integration-tests/pom.xml
index 727a24f..3fe4f55 100644
--- a/surefire-integration-tests/pom.xml
+++ b/surefire-integration-tests/pom.xml
@@ -75,6 +75,10 @@
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f49249ec/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
----------------------------------------------------------------------
diff --git 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
index c169679..e028215 100644
--- 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
+++ 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgListenerReporterIT.java
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.its;
  * under the License.
  */
 
+import org.apache.commons.lang3.JavaVersion;
 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -27,9 +28,9 @@ import org.junit.runners.Parameterized;
 import java.util.Arrays;
 import java.util.Collection;
 
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.junit.Assume.assumeThat;
+import static org.apache.commons.lang3.JavaVersion.JAVA_1_5;
+import static org.apache.commons.lang3.JavaVersion.JAVA_1_7;
+import static 
org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
 import static org.junit.runners.Parameterized.Parameter;
 import static org.junit.runners.Parameterized.Parameters;
 
@@ -47,10 +48,10 @@ public class CheckTestNgListenerReporterIT
     public static Collection<Object[]> data()
     {
         return Arrays.asList(new Object[][] {
-            { "5.6", "1.5" }, // First TestNG version with reporter support
-            { "5.7", "1.5" }, // default version from pom of the test case
-            { "5.10", "1.5" },
-            { "5.13", "1.5" }, // "reporterslist" param becomes String instead 
of List<ReporterConfig>
+            { "5.6", JAVA_1_5 }, // First TestNG version with reporter support
+            { "5.7", JAVA_1_5 }, // default version from pom of the test case
+            { "5.10", JAVA_1_5 },
+            { "5.13", JAVA_1_5 }, // "reporterslist" param becomes String 
instead of List<ReporterConfig>
                         // "listener" param becomes String instead of 
List<Class>
 
                 // configure(Map) in 5.14.1 and 5.14.2 is transforming 
List<Class> into a String with a space as separator.
@@ -69,10 +70,10 @@ public class CheckTestNgListenerReporterIT
             //{ "5.14.4", "1.5" }, { "5.14.5", "1.5" }, // Fails: not able to 
test due to system dependency org.testng:guice missed the path and use to break 
CI
                                         // ClassNotFoundException: 
com.beust.jcommander.ParameterException
 
-            { "5.14.6", "1.5" }, // Usage of org.testng:guice removed
-            { "5.14.9", "1.5" }, // Latest 5.14.x TestNG version
-            { "6.0", "1.5" },
-            { "6.9.9", "1.7" } // Currently latest TestNG version
+            { "5.14.6", JAVA_1_5 }, // Usage of org.testng:guice removed
+            { "5.14.9", JAVA_1_5 }, // Latest 5.14.x TestNG version
+            { "6.0", JAVA_1_5 },
+            { "6.9.9", JAVA_1_7 } // Currently latest TestNG version
         });
     }
 
@@ -80,13 +81,13 @@ public class CheckTestNgListenerReporterIT
     public String version;
 
     @Parameter(1)
-    public String javaVersion;
+    public JavaVersion javaVersion;
 
     @Test
     public void testNgListenerReporter()
     {
 
-        assumeThat( System.getProperty( "java.version" ), is( 
greaterThanOrEqualTo( javaVersion ) ) );
+        assumeJavaVersion( javaVersion );
         unpack( "testng-listener-reporter", "_" + version )
                 .resetInitialGoals( version )
                 .executeTest()

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f49249ec/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47WithCucumberIT.java
----------------------------------------------------------------------
diff --git 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47WithCucumberIT.java
 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47WithCucumberIT.java
index 09e857a..4850005 100644
--- 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47WithCucumberIT.java
+++ 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Junit47WithCucumberIT.java
@@ -20,10 +20,12 @@ package org.apache.maven.surefire.its;
  */
 
 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
-import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.commons.lang3.JavaVersion.JAVA_1_6;
+import static 
org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
+
 /**
  * Tests the JUnit 47 provider with the cucumber runner. At the moment, they 
don't play along that perfectly (minor
  * glitches in the reports with parallel=classes), but at least all tests are 
executed, the execution times are counted
@@ -39,7 +41,7 @@ public class Junit47WithCucumberIT
     @Before
     public void assumeJdk16()
     {
-        Assume.assumeTrue( System.getProperty( "java.version" ).compareTo( 
"1.6" ) > 0 );
+        assumeJavaVersion( JAVA_1_6 );
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f49249ec/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
----------------------------------------------------------------------
diff --git 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
index 2e835da..0a6e918 100644
--- 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
+++ 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
@@ -23,13 +23,18 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
+import org.apache.commons.lang3.JavaVersion;
+import org.apache.commons.lang3.SystemUtils;
 import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
 import org.apache.maven.plugin.surefire.log.api.PrintStreamLogger;
 import org.apache.maven.plugins.surefire.report.ReportTestSuite;
 import org.apache.maven.plugins.surefire.report.SurefireReportParser;
 
-import static junit.framework.Assert.assertTrue;
 import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assume.assumeThat;
 
 @SuppressWarnings( { "JavaDoc" } )
 public class HelperAssertions
@@ -163,4 +168,10 @@ public class HelperAssertions
             throw new RuntimeException( "Couldn't parse XML reports", e );
         }
     }
+
+    public static void assumeJavaVersion( JavaVersion version )
+    {
+        assumeThat( "java.specification.version: ",
+                SystemUtils.JAVA_SPECIFICATION_VERSION, is( 
greaterThanOrEqualTo( version.toString() ) ) );
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f49249ec/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java
----------------------------------------------------------------------
diff --git 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java
 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java
index 4f5befb..a99e636 100644
--- 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java
+++ 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1177TestngParallelSuitesIT.java
@@ -24,11 +24,11 @@ import 
org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
 import org.junit.Test;
 
+import static org.apache.commons.lang3.JavaVersion.JAVA_1_7;
+import static 
org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
 import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assume.assumeThat;
 
 /**
  * IT for https://issues.apache.org/jira/browse/SUREFIRE-1177
@@ -43,8 +43,7 @@ public class Surefire1177TestngParallelSuitesIT
     public void shouldRunTwoSuitesInParallel()
         throws VerificationException
     {
-        assumeThat( "java.specification.version: ",
-                    System.getProperty( "java.specification.version" ), is( 
greaterThanOrEqualTo( "1.7" ) ) );
+        assumeJavaVersion( JAVA_1_7 );
 
         unpack().executeTest()
             .verifyErrorFree( 2 )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f49249ec/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java
----------------------------------------------------------------------
diff --git 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java
 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java
index 7846b7b..da69e9d 100644
--- 
a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java
+++ 
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1211JUnitTestNgIT.java
@@ -1 +1 @@
-package org.apache.maven.surefire.its.jiras;
/*
 * 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 org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher
 ;
import org.junit.Test;

import static java.lang.System.getProperty;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assume.assumeThat;

/**
 * @author <a href="mailto:tibordig...@apache.org";>Tibor Digana (tibor17)</a>
 * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1211}
 * @since 2.19.1
 */
public class Surefire1211JUnitTestNgIT
        extends SurefireJUnit4IntegrationTestCase
{

    @Test
    public void withJUnit()
    {
        assumeThat( "java.specification.version: ",
                          getProperty( "java.specification.version" ), is( 
greaterThanOrEqualTo( "1.7" ) ) );

        unpack().threadCount( 1 )
                .executeTest()
                .verifyErrorFree( 2 );
    }

    @Test
    public void withoutJUnit()
    {
        assumeThat( "java.specification.version: ",
                          getProperty( "java.specification.version" ), is( 
greaterThanOrEqualTo( "1.7" ) 
 ) );

        unpack().threadCount( 1 )
                .sysProp( "junit", "false" )
                .executeTest()
                .verifyErrorFree( 1 );
    }

    private SurefireLauncher unpack()
    {
        return unpack( "surefire-1211" );
    }
}
\ No newline at end of file
+package org.apache.maven.surefire.its.jiras;

/*
 * 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 org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLaunche
 r;
import org.junit.Test;

import static org.apache.commons.lang3.JavaVersion.JAVA_1_7;
import static 
org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;

/**
 * @author <a href="mailto:tibordig...@apache.org";>Tibor Digana (tibor17)</a>
 * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1211}
 * @since 2.19.1
 */
public class Surefire1211JUnitTestNgIT
        extends SurefireJUnit4IntegrationTestCase
{

    @Test
    public void withJUnit()
    {
        assumeJavaVersion( JAVA_1_7 );

        unpack().threadCount( 1 )
                .executeTest()
                .verifyErrorFree( 2 );
    }

    @Test
    public void withoutJUnit()
    {
        assumeJavaVersion( JAVA_1_7 );

        unpack().threadCount( 1 )
                .sysProp( "junit", "false" )
                .executeTest()
                .verifyErrorFree( 1 );
    }

    private SurefireLauncher unpack()
    {
        return unpack( "surefire-1211" );
    }
}
\ No newline at end of file

Reply via email to