Skip to content

Commit 66e3a7a

Browse files
committed
Apply @⁠DisabledInAotMode to appropriate test classes
This commit applies @⁠DisabledInAotMode to test classes in the spring-test module that will never be able to be processed for AOT optimizations. Test classes that fail for reasons that can potentially be addressed in a future version of the framework have not been annotated with @⁠DisabledInAotMode. See gh-29122
1 parent 991afe0 commit 66e3a7a

11 files changed

+38
-0
lines changed

Diff for: spring-test/src/test/java/org/springframework/test/context/env/ExplicitPropertiesFileInClasspathTestPropertySourceTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.test.context.env;
1818

1919
import org.springframework.test.context.TestPropertySource;
20+
import org.springframework.test.context.aot.DisabledInAotMode;
2021

2122
/**
2223
* Integration tests for {@link TestPropertySource @TestPropertySource}
@@ -26,5 +27,7 @@
2627
* @since 4.1
2728
*/
2829
@TestPropertySource("explicit.properties")
30+
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
31+
@DisabledInAotMode
2932
public class ExplicitPropertiesFileInClasspathTestPropertySourceTests extends AbstractExplicitPropertiesFileTests {
3033
}

Diff for: spring-test/src/test/java/org/springframework/test/context/env/ExplicitPropertiesFileTestPropertySourceTests.java

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.jupiter.api.Nested;
2323

2424
import org.springframework.test.context.TestPropertySource;
25+
import org.springframework.test.context.aot.DisabledInAotMode;
2526
import org.springframework.util.ClassUtils;
2627

2728
/**
@@ -34,6 +35,9 @@
3435
* @since 5.2
3536
*/
3637
@DisplayName("Explicit properties file in @TestPropertySource")
38+
// Since Spring test's AOT processing support does not invoke test lifecycle methods such
39+
// as @BeforeAll/@AfterAll, this test class simply is not supported for AOT processing.
40+
@DisabledInAotMode
3741
class ExplicitPropertiesFileTestPropertySourceTests {
3842

3943
static final String CURRENT_TEST_PACKAGE = "current.test.package";

Diff for: spring-test/src/test/java/org/springframework/test/context/env/InheritedRelativePathPropertiesFileTestPropertySourceTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.test.context.env;
1818

1919
import org.springframework.test.context.TestPropertySource;
20+
import org.springframework.test.context.aot.DisabledInAotMode;
2021

2122
/**
2223
* Integration tests for {@link TestPropertySource @TestPropertySource}
@@ -26,6 +27,8 @@
2627
* @author Sam Brannen
2728
* @since 4.1
2829
*/
30+
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
31+
@DisabledInAotMode
2932
class InheritedRelativePathPropertiesFileTestPropertySourceTests extends
3033
ExplicitPropertiesFileInClasspathTestPropertySourceTests {
3134

Diff for: spring-test/src/test/java/org/springframework/test/context/env/MergedPropertiesFilesOverriddenByInlinedPropertiesTestPropertySourceTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.test.context.TestPropertySource;
22+
import org.springframework.test.context.aot.DisabledInAotMode;
2223

2324
import static org.assertj.core.api.Assertions.assertThat;
2425

@@ -31,6 +32,8 @@
3132
* @since 4.1
3233
*/
3334
@TestPropertySource(properties = { "explicit = inlined", "extended = inlined1", "extended = inlined2" })
35+
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
36+
@DisabledInAotMode
3437
class MergedPropertiesFilesOverriddenByInlinedPropertiesTestPropertySourceTests extends
3538
MergedPropertiesFilesTestPropertySourceTests {
3639

Diff for: spring-test/src/test/java/org/springframework/test/context/env/MergedPropertiesFilesTestPropertySourceTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.test.context.TestPropertySource;
22+
import org.springframework.test.context.aot.DisabledInAotMode;
2223

2324
import static org.assertj.core.api.Assertions.assertThat;
2425

@@ -30,6 +31,8 @@
3031
* @since 4.1
3132
*/
3233
@TestPropertySource("extended.properties")
34+
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
35+
@DisabledInAotMode
3336
class MergedPropertiesFilesTestPropertySourceTests extends
3437
ExplicitPropertiesFileInClasspathTestPropertySourceTests {
3538

Diff for: spring-test/src/test/java/org/springframework/test/context/env/subpackage/SubpackageInheritedRelativePathPropertiesFileTestPropertySourceTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.test.context.env.subpackage;
1818

1919
import org.springframework.test.context.TestPropertySource;
20+
import org.springframework.test.context.aot.DisabledInAotMode;
2021
import org.springframework.test.context.env.ExplicitPropertiesFileInClasspathTestPropertySourceTests;
2122

2223
/**
@@ -27,6 +28,8 @@
2728
* @author Sam Brannen
2829
* @since 4.1
2930
*/
31+
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
32+
@DisabledInAotMode
3033
class SubpackageInheritedRelativePathPropertiesFileTestPropertySourceTests extends
3134
ExplicitPropertiesFileInClasspathTestPropertySourceTests {
3235

Diff for: spring-test/src/test/java/org/springframework/test/context/junit4/ClassLevelDisabledSpringRunnerTests.java

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.test.context.TestContext;
2424
import org.springframework.test.context.TestExecutionListener;
2525
import org.springframework.test.context.TestExecutionListeners;
26+
import org.springframework.test.context.aot.DisabledInAotMode;
2627

2728
import static org.assertj.core.api.Assertions.fail;
2829

@@ -33,6 +34,9 @@
3334
@RunWith(SpringRunner.class)
3435
@TestExecutionListeners(ClassLevelDisabledSpringRunnerTests.CustomTestExecutionListener.class)
3536
@IfProfileValue(name = "ClassLevelDisabledSpringRunnerTests.profile_value.name", value = "enigmaX")
37+
// Since Spring test's AOT processing support does not evaluate @IfProfileValue,
38+
// this test class simply is not supported for AOT processing.
39+
@DisabledInAotMode
3640
public class ClassLevelDisabledSpringRunnerTests {
3741

3842
@Test

Diff for: spring-test/src/test/java/org/springframework/test/context/junit4/EnabledAndIgnoredSpringRunnerTests.java

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.test.annotation.ProfileValueSource;
2727
import org.springframework.test.annotation.ProfileValueSourceConfiguration;
2828
import org.springframework.test.context.TestExecutionListeners;
29+
import org.springframework.test.context.aot.DisabledInAotMode;
2930

3031
import static org.assertj.core.api.Assertions.assertThat;
3132
import static org.assertj.core.api.Assertions.fail;
@@ -47,6 +48,9 @@
4748
*/
4849
@RunWith(SpringRunner.class)
4950
@TestExecutionListeners({})
51+
// Since this test class does not load an ApplicationContext,
52+
// this test class simply is not supported for AOT processing.
53+
@DisabledInAotMode
5054
public class EnabledAndIgnoredSpringRunnerTests {
5155

5256
protected static final String NAME = "EnabledAndIgnoredSpringRunnerTests.profile_value.name";

Diff for: spring-test/src/test/java/org/springframework/test/context/junit4/HardCodedProfileValueSourceSpringRunnerTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.springframework.test.annotation.ProfileValueSource;
2222
import org.springframework.test.annotation.ProfileValueSourceConfiguration;
23+
import org.springframework.test.context.aot.DisabledInAotMode;
2324

2425
/**
2526
* <p>
@@ -36,6 +37,8 @@
3637
* @see EnabledAndIgnoredSpringRunnerTests
3738
*/
3839
@ProfileValueSourceConfiguration(HardCodedProfileValueSourceSpringRunnerTests.HardCodedProfileValueSource.class)
40+
// Since EnabledAndIgnoredSpringRunnerTests is disabled in AOT mode, this test class must be also.
41+
@DisabledInAotMode
3942
public class HardCodedProfileValueSourceSpringRunnerTests extends EnabledAndIgnoredSpringRunnerTests {
4043

4144
@BeforeClass

Diff for: spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit47ClassRunnerRuleTests.java

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.runner.RunWith;
2323

2424
import org.springframework.test.context.TestExecutionListeners;
25+
import org.springframework.test.context.aot.DisabledInAotMode;
2526

2627
import static org.assertj.core.api.Assertions.assertThat;
2728

@@ -36,6 +37,9 @@
3637
*/
3738
@RunWith(SpringRunner.class)
3839
@TestExecutionListeners({})
40+
// Since this test class does not load an ApplicationContext,
41+
// this test class simply is not supported for AOT processing.
42+
@DisabledInAotMode
3943
public class SpringJUnit47ClassRunnerRuleTests {
4044

4145
@Rule

Diff for: spring-test/src/test/java/org/springframework/test/context/junit4/StandardJUnit4FeaturesSpringRunnerTests.java

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.runner.RunWith;
2020

2121
import org.springframework.test.context.TestExecutionListeners;
22+
import org.springframework.test.context.aot.DisabledInAotMode;
2223

2324
/**
2425
* <p>
@@ -37,6 +38,9 @@
3738
*/
3839
@RunWith(SpringRunner.class)
3940
@TestExecutionListeners({})
41+
// Since this test class does not load an ApplicationContext,
42+
// this test class simply is not supported for AOT processing.
43+
@DisabledInAotMode
4044
public class StandardJUnit4FeaturesSpringRunnerTests extends StandardJUnit4FeaturesTests {
4145

4246
/* All tests are in the parent class... */

0 commit comments

Comments
 (0)