Remove TestGroup.CI enum constant
Prior to this commit, the TestGroup.CI enum constant was only used in a single test method in spring-core. In order to enable that test, the `testGroups` JVM system property was configured for the Publication-master CI build plan; however, the `testGroups` system property is not set when executing local builds. Consequently, there has been a Gradle cache miss for every `test` task when building something locally that's already been built on the CI server. This commit addresses this issue by removing the `TestGroup.CI` enum constant. The `-PtestGroups=ci` command line configuration for the Publication-master CI build plan has also been removed on the CI server. Closes gh-23918
This commit is contained in:
@@ -21,6 +21,8 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.file.Path;
|
||||
@@ -29,12 +31,11 @@ import java.util.HashSet;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.tests.EnabledForTestGroups;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.springframework.tests.TestGroup.CI;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
|
||||
/**
|
||||
* Unit tests for various {@link Resource} implementations.
|
||||
@@ -220,12 +221,28 @@ class ResourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(CI)
|
||||
void testNonFileResourceExists() throws Exception {
|
||||
Resource resource = new UrlResource("https://spring.io/");
|
||||
void nonFileResourceExists() throws Exception {
|
||||
URL url = new URL("https://spring.io/");
|
||||
|
||||
// Abort if spring.io is not reachable.
|
||||
assumeTrue(urlIsReachable(url));
|
||||
|
||||
Resource resource = new UrlResource(url);
|
||||
assertThat(resource.exists()).isTrue();
|
||||
}
|
||||
|
||||
private boolean urlIsReachable(URL url) {
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("HEAD");
|
||||
connection.setReadTimeout(5_000);
|
||||
return connection.getResponseCode() == HttpURLConnection.HTTP_OK;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void abstractResourceExceptions() throws Exception {
|
||||
final String name = "test-resource";
|
||||
|
||||
@@ -29,7 +29,6 @@ import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.springframework.tests.Assume.TEST_GROUPS_SYSTEM_PROPERTY;
|
||||
import static org.springframework.tests.TestGroup.CI;
|
||||
import static org.springframework.tests.TestGroup.LONG_RUNNING;
|
||||
import static org.springframework.tests.TestGroup.PERFORMANCE;
|
||||
|
||||
@@ -70,7 +69,7 @@ class AssumeTests {
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void assumeGroupWithNoMatchingActiveTestGroup() {
|
||||
setTestGroups(PERFORMANCE, CI);
|
||||
setTestGroups(PERFORMANCE);
|
||||
assertThatExceptionOfType(TestAbortedException.class).isThrownBy(() -> Assume.group(LONG_RUNNING));
|
||||
}
|
||||
|
||||
@@ -99,7 +98,7 @@ class AssumeTests {
|
||||
//
|
||||
// java.lang.IllegalStateException: Failed to parse 'testGroups' system property:
|
||||
// Unable to find test group 'bogus' when parsing testGroups value: 'all-bogus'.
|
||||
// Available groups include: [LONG_RUNNING,PERFORMANCE,CI]
|
||||
// Available groups include: [LONG_RUNNING,PERFORMANCE]
|
||||
|
||||
setTestGroups(testGroups);
|
||||
assertThatIllegalStateException()
|
||||
@@ -109,7 +108,7 @@ class AssumeTests {
|
||||
.satisfies(ex ->
|
||||
assertThat(ex.getCause().getMessage()).isEqualTo(
|
||||
"Unable to find test group 'bogus' when parsing testGroups value: '" + testGroups +
|
||||
"'. Available groups include: [LONG_RUNNING,PERFORMANCE,CI]"));
|
||||
"'. Available groups include: [LONG_RUNNING,PERFORMANCE]"));
|
||||
}
|
||||
|
||||
private void setTestGroups(TestGroup... testGroups) {
|
||||
|
||||
@@ -49,12 +49,7 @@ public enum TestGroup {
|
||||
* {@code StopWatch}, etc. should be considered a candidate as their successful
|
||||
* execution is likely to be based on events occurring within a given time window.
|
||||
*/
|
||||
PERFORMANCE,
|
||||
|
||||
/**
|
||||
* Tests that should only be run on the continuous integration server.
|
||||
*/
|
||||
CI;
|
||||
PERFORMANCE;
|
||||
|
||||
|
||||
/**
|
||||
@@ -82,6 +77,7 @@ public enum TestGroup {
|
||||
"' system property: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the specified comma separated string of groups.
|
||||
* @param value the comma separated string of groups
|
||||
|
||||
@@ -64,7 +64,7 @@ class TestGroupTests {
|
||||
.isThrownBy(() -> TestGroup.parse("performance, missing"))
|
||||
.withMessageContaining("Unable to find test group 'missing' when parsing " +
|
||||
"testGroups value: 'performance, missing'. Available groups include: " +
|
||||
"[LONG_RUNNING,PERFORMANCE,CI]");
|
||||
"[LONG_RUNNING,PERFORMANCE]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,7 +85,7 @@ class TestGroupTests {
|
||||
.isThrownBy(() -> TestGroup.parse("all-missing"))
|
||||
.withMessageContaining("Unable to find test group 'missing' when parsing " +
|
||||
"testGroups value: 'all-missing'. Available groups include: " +
|
||||
"[LONG_RUNNING,PERFORMANCE,CI]");
|
||||
"[LONG_RUNNING,PERFORMANCE]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user