Removed JavaVersion checks from spring-core tests (for JDK 9 compatibility)
Issue: SPR-13344
This commit is contained in:
parent
182b1e99e3
commit
74c07d3085
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -21,7 +21,6 @@ import java.lang.reflect.Method;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import org.junit.AssumptionViolatedException;
|
||||
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
@ -33,38 +32,8 @@ import static org.junit.Assume.*;
|
|||
* conditions hold {@code true}. If the assumption fails, it means the test should be
|
||||
* skipped.
|
||||
*
|
||||
* <p>For example, if a set of tests require at least JDK 1.7 it can use
|
||||
* {@code Assume#atLeast(JavaVersion.JAVA_17)} as shown below:
|
||||
*
|
||||
* <pre class="code">
|
||||
* public void MyTests {
|
||||
*
|
||||
* @BeforeClass
|
||||
* public static void assumptions() {
|
||||
* Assume.atLeast(JavaVersion.JAVA_17);
|
||||
* }
|
||||
*
|
||||
* // ... all the test methods that require at least JDK 1.7
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* If only a single test requires at least JDK 1.7 it can use the
|
||||
* {@code Assume#atLeast(JavaVersion.JAVA_17)} as shown below:
|
||||
*
|
||||
* <pre class="code">
|
||||
* public void MyTests {
|
||||
*
|
||||
* @Test
|
||||
* public void requiresJdk17 {
|
||||
* Assume.atLeast(JavaVersion.JAVA_17);
|
||||
* // ... perform the actual test
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* In addition to assumptions based on the JDK version, tests can be categorized into
|
||||
* {@link TestGroup}s. Active groups are enabled using the 'testGroups' system property,
|
||||
* usually activated from the gradle command line:
|
||||
* Tests can be categorized into {@link TestGroup}s. Active groups are enabled using
|
||||
* the 'testGroups' system property, usually activated from the gradle command line:
|
||||
* <pre>
|
||||
* gradle test -PtestGroups="performance"
|
||||
* </pre>
|
||||
|
@ -76,7 +45,6 @@ import static org.junit.Assume.*;
|
|||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
* @since 3.2
|
||||
* @see #atLeast(JavaVersion)
|
||||
* @see #group(TestGroup)
|
||||
* @see #group(TestGroup, Executable)
|
||||
*/
|
||||
|
@ -85,18 +53,6 @@ public abstract class Assume {
|
|||
private static final Set<TestGroup> GROUPS = TestGroup.parse(System.getProperty("testGroups"));
|
||||
|
||||
|
||||
/**
|
||||
* Assume that a minimum {@link JavaVersion} is running.
|
||||
* @param version the minimum version for the test to run
|
||||
* @throws AssumptionViolatedException if the assumption fails
|
||||
*/
|
||||
public static void atLeast(JavaVersion version) {
|
||||
if (!JavaVersion.runningVersion().isAtLeast(version)) {
|
||||
throw new AssumptionViolatedException("Requires JDK " + version + " but running "
|
||||
+ JavaVersion.runningVersion());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assume that a particular {@link TestGroup} has been specified.
|
||||
* @param group the group that must be specified
|
||||
|
@ -104,8 +60,7 @@ public abstract class Assume {
|
|||
*/
|
||||
public static void group(TestGroup group) {
|
||||
if (!GROUPS.contains(group)) {
|
||||
throw new AssumptionViolatedException("Requires unspecified group " + group
|
||||
+ " from " + GROUPS);
|
||||
throw new AssumptionViolatedException("Requires unspecified group " + group + " from " + GROUPS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,11 +109,13 @@ public abstract class Assume {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public static interface Executable {
|
||||
public interface Executable {
|
||||
|
||||
void execute() throws Exception;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
package org.springframework.tests;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* General build related tests. Part of spring-core to ensure that they run early in the
|
||||
* build process.
|
||||
*/
|
||||
public class BuildTests {
|
||||
|
||||
@Test
|
||||
public void javaVersion() throws Exception {
|
||||
Assume.group(TestGroup.CI);
|
||||
assertThat("Java Version", JavaVersion.runningVersion(), equalTo(JavaVersion.JAVA_18));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
package org.springframework.tests;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Tests for {@link JavaVersion}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class JavaVersionTests {
|
||||
|
||||
@Test
|
||||
public void runningVersion() {
|
||||
assertNotNull(JavaVersion.runningVersion());
|
||||
assertThat(System.getProperty("java.version"), startsWith(JavaVersion.runningVersion().toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAtLeast() throws Exception {
|
||||
assertTrue(JavaVersion.JAVA_16.isAtLeast(JavaVersion.JAVA_16));
|
||||
assertFalse(JavaVersion.JAVA_16.isAtLeast(JavaVersion.JAVA_17));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue