Skip to content

Commit

Permalink
Apply @⁠DisabledInAotMode to appropriate test classes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sbrannen committed Oct 16, 2023
1 parent 991afe0 commit 66e3a7a
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.test.context.env;

import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.aot.DisabledInAotMode;

/**
* Integration tests for {@link TestPropertySource @TestPropertySource}
Expand All @@ -26,5 +27,7 @@
* @since 4.1
*/
@TestPropertySource("explicit.properties")
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
@DisabledInAotMode
public class ExplicitPropertiesFileInClasspathTestPropertySourceTests extends AbstractExplicitPropertiesFileTests {
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.jupiter.api.Nested;

import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.util.ClassUtils;

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

static final String CURRENT_TEST_PACKAGE = "current.test.package";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.test.context.env;

import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.aot.DisabledInAotMode;

/**
* Integration tests for {@link TestPropertySource @TestPropertySource}
Expand All @@ -26,6 +27,8 @@
* @author Sam Brannen
* @since 4.1
*/
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
@DisabledInAotMode
class InheritedRelativePathPropertiesFileTestPropertySourceTests extends
ExplicitPropertiesFileInClasspathTestPropertySourceTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.jupiter.api.Test;

import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.aot.DisabledInAotMode;

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.jupiter.api.Test;

import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.aot.DisabledInAotMode;

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

Expand All @@ -30,6 +31,8 @@
* @since 4.1
*/
@TestPropertySource("extended.properties")
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
@DisabledInAotMode
class MergedPropertiesFilesTestPropertySourceTests extends
ExplicitPropertiesFileInClasspathTestPropertySourceTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.test.context.env.subpackage;

import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.aot.DisabledInAotMode;
import org.springframework.test.context.env.ExplicitPropertiesFileInClasspathTestPropertySourceTests;

/**
Expand All @@ -27,6 +28,8 @@
* @author Sam Brannen
* @since 4.1
*/
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
@DisabledInAotMode
class SubpackageInheritedRelativePathPropertiesFileTestPropertySourceTests extends
ExplicitPropertiesFileInClasspathTestPropertySourceTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.test.context.TestContext;
import org.springframework.test.context.TestExecutionListener;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.aot.DisabledInAotMode;

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

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

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.test.annotation.ProfileValueSource;
import org.springframework.test.annotation.ProfileValueSourceConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.aot.DisabledInAotMode;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
Expand All @@ -47,6 +48,9 @@
*/
@RunWith(SpringRunner.class)
@TestExecutionListeners({})
// Since this test class does not load an ApplicationContext,
// this test class simply is not supported for AOT processing.
@DisabledInAotMode
public class EnabledAndIgnoredSpringRunnerTests {

protected static final String NAME = "EnabledAndIgnoredSpringRunnerTests.profile_value.name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.springframework.test.annotation.ProfileValueSource;
import org.springframework.test.annotation.ProfileValueSourceConfiguration;
import org.springframework.test.context.aot.DisabledInAotMode;

/**
* <p>
Expand All @@ -36,6 +37,8 @@
* @see EnabledAndIgnoredSpringRunnerTests
*/
@ProfileValueSourceConfiguration(HardCodedProfileValueSourceSpringRunnerTests.HardCodedProfileValueSource.class)
// Since EnabledAndIgnoredSpringRunnerTests is disabled in AOT mode, this test class must be also.
@DisabledInAotMode
public class HardCodedProfileValueSourceSpringRunnerTests extends EnabledAndIgnoredSpringRunnerTests {

@BeforeClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.runner.RunWith;

import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.aot.DisabledInAotMode;

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

Expand All @@ -36,6 +37,9 @@
*/
@RunWith(SpringRunner.class)
@TestExecutionListeners({})
// Since this test class does not load an ApplicationContext,
// this test class simply is not supported for AOT processing.
@DisabledInAotMode
public class SpringJUnit47ClassRunnerRuleTests {

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.runner.RunWith;

import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.aot.DisabledInAotMode;

/**
* <p>
Expand All @@ -37,6 +38,9 @@
*/
@RunWith(SpringRunner.class)
@TestExecutionListeners({})
// Since this test class does not load an ApplicationContext,
// this test class simply is not supported for AOT processing.
@DisabledInAotMode
public class StandardJUnit4FeaturesSpringRunnerTests extends StandardJUnit4FeaturesTests {

/* All tests are in the parent class... */
Expand Down

0 comments on commit 66e3a7a

Please sign in to comment.