Introduce support for a custom reason in @⁠DisabledInAotMode

Closes gh-33833
This commit is contained in:
Sam Brannen
2024-11-01 12:24:53 +01:00
parent fdb763eeaf
commit 86784b61cc
51 changed files with 198 additions and 105 deletions

View File

@@ -0,0 +1,81 @@
/*
* Copyright 2002-2024 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
*
* https://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.test.context.aot;
import org.junit.jupiter.api.Test;
import org.junit.platform.testkit.engine.EngineTestKit;
import org.springframework.aot.AotDetector;
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
import static org.junit.platform.testkit.engine.EventConditions.container;
import static org.junit.platform.testkit.engine.EventConditions.event;
import static org.junit.platform.testkit.engine.EventConditions.skippedWithReason;
/**
* Tests for {@link DisabledInAotMode @DisabledInAotMode}.
*
* @author Sam Brannen
* @since 6.2
*/
class DisabledInAotModeTests {
@Test
void defaultDisabledReason() {
runTestsInAotMode(DefaultReasonTestCase.class, "Disabled in Spring AOT mode");
}
@Test
void customDisabledReason() {
runTestsInAotMode(CustomReasonTestCase.class, "Disabled in Spring AOT mode ==> @ContextHierarchy is not supported in AOT");
}
private static void runTestsInAotMode(Class<?> testClass, String expectedReason) {
try {
System.setProperty(AotDetector.AOT_ENABLED, "true");
EngineTestKit.engine("junit-jupiter")
.selectors(selectClass(testClass))
.execute()
.allEvents()
.assertThatEvents().haveExactly(1,
event(container(testClass.getSimpleName()), skippedWithReason(expectedReason)));
}
finally {
System.clearProperty(AotDetector.AOT_ENABLED);
}
}
@DisabledInAotMode
static class DefaultReasonTestCase {
@Test
void test() {
}
}
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
static class CustomReasonTestCase {
@Test
void test() {
}
}
}

View File

@@ -38,7 +38,7 @@ import static org.mockito.BDDMockito.then;
* @see MockitoSpyBeanAndCircularDependenciesWithLazyResolutionProxyIntegrationTests
*/
@SpringJUnitConfig
@DisabledInAotMode // Circular dependencies cannot be resolved in AOT mode unless a @Lazy resolution proxy is used.
@DisabledInAotMode("Circular dependencies cannot be resolved in AOT mode unless a @Lazy resolution proxy is used")
class MockitoSpyBeanAndCircularDependenciesWithAutowiredSettersIntegrationTests {
@MockitoSpyBean

View File

@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @see MockitoBeanAndContextHierarchyParentIntegrationTests
*/
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class MockitoSpyBeanAndContextHierarchyChildIntegrationTests extends
MockitoBeanAndContextHierarchyParentIntegrationTests {

View File

@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 4.3
*/
@ExtendWith(SpringExtension.class)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class ContextHierarchyInterfaceTests implements ContextHierarchyTestInterface {
@Autowired

View File

@@ -27,7 +27,6 @@ import org.springframework.test.context.aot.DisabledInAotMode;
* @since 4.1
*/
@TestPropertySource("explicit.properties")
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
@DisabledInAotMode
@DisabledInAotMode("Because ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode")
public class ExplicitPropertiesFileInClasspathTestPropertySourceTests extends AbstractExplicitPropertiesFileTests {
}

View File

@@ -35,9 +35,7 @@ import org.springframework.util.ClassUtils;
* @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
@DisabledInAotMode("Spring test's AOT processing support does not invoke lifecycle methods such as @BeforeAll/@AfterAll")
class ExplicitPropertiesFileTestPropertySourceTests {
static final String CURRENT_TEST_PACKAGE = "current.test.package";

View File

@@ -27,8 +27,7 @@ import org.springframework.test.context.aot.DisabledInAotMode;
* @author Sam Brannen
* @since 4.1
*/
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
@DisabledInAotMode
@DisabledInAotMode("Because ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode")
class InheritedRelativePathPropertiesFileTestPropertySourceTests extends
ExplicitPropertiesFileInClasspathTestPropertySourceTests {

View File

@@ -32,8 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 4.1
*/
@TestPropertySource(properties = { "explicit = inlined", "extended = inlined1", "extended = inlined2" })
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
@DisabledInAotMode
@DisabledInAotMode("Because ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode")
class MergedPropertiesFilesOverriddenByInlinedPropertiesTestPropertySourceTests extends
MergedPropertiesFilesTestPropertySourceTests {

View File

@@ -31,8 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 4.1
*/
@TestPropertySource("extended.properties")
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
@DisabledInAotMode
@DisabledInAotMode("Because ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode")
class MergedPropertiesFilesTestPropertySourceTests extends
ExplicitPropertiesFileInClasspathTestPropertySourceTests {

View File

@@ -28,8 +28,7 @@ import org.springframework.test.context.env.ExplicitPropertiesFileInClasspathTes
* @author Sam Brannen
* @since 4.1
*/
// Since ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode, this class must be also.
@DisabledInAotMode
@DisabledInAotMode("Because ExplicitPropertiesFileTestPropertySourceTests is disabled in AOT mode")
class SubpackageInheritedRelativePathPropertiesFileTestPropertySourceTests extends
ExplicitPropertiesFileInClasspathTestPropertySourceTests {

View File

@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*/
@SpringJUnitConfig
@DisabledInAotMode // SpEL is not supported in AOT
@DisabledInAotMode("SpEL is not supported in AOT")
class ExpressionUsageTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@MetaMetaContextHierarchyConfig
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class MetaHierarchyLevelOneTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ContextConfiguration
@ActiveProfiles("prod")
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class MetaHierarchyLevelTwoTests extends MetaHierarchyLevelOneTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@ContextConfiguration(name = "parent", classes = ClassHierarchyWithMergedConfigLevelOneTests.AppConfig.class),//
@ContextConfiguration(name = "child", classes = ClassHierarchyWithMergedConfigLevelOneTests.UserConfig.class) //
})
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class ClassHierarchyWithMergedConfigLevelOneTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ContextHierarchy(@ContextConfiguration(name = "child", classes = ClassHierarchyWithMergedConfigLevelTwoTests.OrderConfig.class))
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class ClassHierarchyWithMergedConfigLevelTwoTests extends ClassHierarchyWithMergedConfigLevelOneTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ContextHierarchy(@ContextConfiguration(name = "child", classes = ClassHierarchyWithOverriddenConfigLevelTwoTests.TestUserConfig.class, inheritLocations = false))
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class ClassHierarchyWithOverriddenConfigLevelTwoTests extends ClassHierarchyWithMergedConfigLevelOneTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -52,7 +52,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@ContextConfiguration(classes = DirtiesContextWithContextHierarchyTests.ChildConfig.class)
})
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class DirtiesContextWithContextHierarchyTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class SingleTestClassWithSingleLevelContextHierarchyTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@ContextHierarchy({
@ContextConfiguration(classes = SingleTestClassWithTwoLevelContextHierarchyAndMixedConfigTypesTests.ParentConfig.class),
@ContextConfiguration("SingleTestClassWithTwoLevelContextHierarchyAndMixedConfigTypesTests-ChildConfig.xml") })
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class SingleTestClassWithTwoLevelContextHierarchyAndMixedConfigTypesTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@ContextHierarchy({
@ContextConfiguration(classes = SingleTestClassWithTwoLevelContextHierarchyTests.ParentConfig.class),
@ContextConfiguration(classes = SingleTestClassWithTwoLevelContextHierarchyTests.ChildConfig.class) })
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class SingleTestClassWithTwoLevelContextHierarchyTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class TestHierarchyLevelOneWithBareContextConfigurationInSubclassTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class TestHierarchyLevelOneWithSingleLevelContextHierarchyTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class TestHierarchyLevelTwoWithBareContextConfigurationInSubclassTests extends
TestHierarchyLevelOneWithBareContextConfigurationInSubclassTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class TestHierarchyLevelTwoWithBareContextConfigurationInSuperclassTests extends
TestHierarchyLevelOneWithBareContextConfigurationInSuperclassTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class TestHierarchyLevelTwoWithSingleLevelContextHierarchyAndMixedConfigTypesTests extends
TestHierarchyLevelOneWithSingleLevelContextHierarchyTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(SpringExtension.class)
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class TestHierarchyLevelTwoWithSingleLevelContextHierarchyTests extends
TestHierarchyLevelOneWithSingleLevelContextHierarchyTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@ContextConfiguration(name = "root", classes = AppConfig.class),
@ContextConfiguration(name = "dispatcher", classes = WebConfig.class)
})
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class ControllerIntegrationTests {
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.2.2
*/
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class DispatcherWacRootWacEarTests extends RootWacEarTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@WebAppConfiguration
@ContextHierarchy(@ContextConfiguration)
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class RootWacEarTests extends EarTests {
@Configuration(proxyBeanMethods = false)

View File

@@ -38,7 +38,7 @@ class PropertyPlaceholderSqlScriptsTests {
@ContextConfiguration(classes = PopulatedSchemaDatabaseConfig.class)
@TestPropertySource(properties = "vendor = db1")
@DirtiesContext
@DisabledInAotMode // ${vendor} does not get resolved during AOT processing
@DisabledInAotMode("${vendor} does not get resolved during AOT processing")
class DatabaseOneTests extends AbstractTransactionalTests {
@Test
@@ -52,7 +52,7 @@ class PropertyPlaceholderSqlScriptsTests {
@ContextConfiguration(classes = PopulatedSchemaDatabaseConfig.class)
@TestPropertySource(properties = "vendor = db2")
@DirtiesContext
@DisabledInAotMode // ${vendor} does not get resolved during AOT processing
@DisabledInAotMode("${vendor} does not get resolved during AOT processing")
class DatabaseTwoTests extends AbstractTransactionalTests {
@Test

View File

@@ -47,7 +47,7 @@ import static org.springframework.test.context.NestedTestConfiguration.Enclosing
@ExtendWith(SpringExtension.class)
@ContextHierarchy(@ContextConfiguration(classes = ParentConfig.class))
@NestedTestConfiguration(OVERRIDE) // since INHERIT is now the global default
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class ContextHierarchyNestedTests {
private static final String FOO = "foo";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -47,9 +47,7 @@ import static org.springframework.test.context.NestedTestConfiguration.Enclosing
@ExtendWith(SpringExtension.class)
@TestExecutionListeners(FooTestExecutionListener.class)
@NestedTestConfiguration(OVERRIDE) // since INHERIT is now the global default
// Since this test class does not load an ApplicationContext,
// this test class simply is not supported for AOT processing.
@DisabledInAotMode
@DisabledInAotMode("Does not load an ApplicationContext and thus not supported for AOT processing")
class TestExecutionListenersNestedTests {
private static final String FOO = "foo";
@@ -83,7 +81,7 @@ class TestExecutionListenersNestedTests {
@Nested
@TestExecutionListeners(BarTestExecutionListener.class)
@DisabledInAotMode
@DisabledInAotMode("Does not load an ApplicationContext and thus not supported for AOT processing")
class ConfigOverriddenByDefaultTests {
@Test
@@ -106,7 +104,7 @@ class TestExecutionListenersNestedTests {
@Nested
@NestedTestConfiguration(OVERRIDE)
@TestExecutionListeners(BazTestExecutionListener.class)
@DisabledInAotMode
@DisabledInAotMode("Does not load an ApplicationContext and thus not supported for AOT processing")
class DoubleNestedWithOverriddenConfigTests {
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -34,9 +34,7 @@ import static org.assertj.core.api.Assertions.fail;
@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
@DisabledInAotMode("@IfProfileValue is not supported for AOT processing")
public class ClassLevelDisabledSpringRunnerTests {
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -48,9 +48,7 @@ import static org.assertj.core.api.Assertions.fail;
*/
@RunWith(SpringRunner.class)
@TestExecutionListeners({})
// Since this test class does not load an ApplicationContext,
// this test class simply is not supported for AOT processing.
@DisabledInAotMode
@DisabledInAotMode("Does not load an ApplicationContext and thus not supported for AOT processing")
public class EnabledAndIgnoredSpringRunnerTests {
protected static final String NAME = "EnabledAndIgnoredSpringRunnerTests.profile_value.name";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -37,8 +37,7 @@ import org.springframework.test.context.aot.DisabledInAotMode;
* @see EnabledAndIgnoredSpringRunnerTests
*/
@ProfileValueSourceConfiguration(HardCodedProfileValueSourceSpringRunnerTests.HardCodedProfileValueSource.class)
// Since EnabledAndIgnoredSpringRunnerTests is disabled in AOT mode, this test class must be also.
@DisabledInAotMode
@DisabledInAotMode("Because EnabledAndIgnoredSpringRunnerTests is disabled in AOT mode")
public class HardCodedProfileValueSourceSpringRunnerTests extends EnabledAndIgnoredSpringRunnerTests {
@BeforeClass

View File

@@ -37,9 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@TestExecutionListeners({})
// Since this test class does not load an ApplicationContext,
// this test class simply is not supported for AOT processing.
@DisabledInAotMode
@DisabledInAotMode("Does not load an ApplicationContext and thus not supported for AOT processing")
public class SpringJUnit47ClassRunnerRuleTests {
@Rule

View File

@@ -38,9 +38,7 @@ import org.springframework.test.context.aot.DisabledInAotMode;
*/
@RunWith(SpringRunner.class)
@TestExecutionListeners({})
// Since this test class does not load an ApplicationContext,
// this test class simply is not supported for AOT processing.
@DisabledInAotMode
@DisabledInAotMode("Does not load an ApplicationContext and thus not supported for AOT processing")
public class StandardJUnit4FeaturesSpringRunnerTests extends StandardJUnit4FeaturesTests {
/* All tests are in the parent class... */

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -33,7 +33,7 @@ import org.springframework.test.context.transaction.ejb.dao.RequiredEjbTxTestEnt
*/
@ContextConfiguration("required-tx-config.xml")
@Commit
@DisabledInAotMode // @EJB is not supported in Spring AOT
@DisabledInAotMode("@EJB is not supported in Spring AOT")
class CommitForRequiredEjbTxDaoTests extends AbstractEjbTxDaoTests {
/* test methods in superclass */

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -33,7 +33,7 @@ import org.springframework.test.context.transaction.ejb.dao.RequiresNewEjbTxTest
*/
@ContextConfiguration("requires-new-tx-config.xml")
@Commit
@DisabledInAotMode // @EJB is not supported in Spring AOT
@DisabledInAotMode("@EJB is not supported in Spring AOT")
class CommitForRequiresNewEjbTxDaoTests extends AbstractEjbTxDaoTests {
/* test methods in superclass */

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 4.0.1
*/
@Rollback
@DisabledInAotMode // @EJB is not supported in Spring AOT
@DisabledInAotMode("@EJB is not supported in Spring AOT")
class RollbackForRequiredEjbTxDaoTests extends CommitForRequiredEjbTxDaoTests {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -36,7 +36,7 @@ import org.springframework.test.context.transaction.TransactionalTestExecutionLi
* @since 4.0.1
*/
@Rollback
@DisabledInAotMode // @EJB is not supported in Spring AOT
@DisabledInAotMode("@EJB is not supported in Spring AOT")
class RollbackForRequiresNewEjbTxDaoTests extends CommitForRequiresNewEjbTxDaoTests {
/* test methods in superclass */

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -56,7 +56,7 @@ import static org.mockito.Mockito.mock;
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextHierarchy(@ContextConfiguration(classes = AsyncControllerJavaConfigTests.WebConfig.class))
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class AsyncControllerJavaConfigTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -56,7 +56,7 @@ import static org.mockito.Mockito.mock;
@ContextConfiguration(classes = JavaConfigTests.RootConfig.class),
@ContextConfiguration(classes = JavaConfigTests.WebConfig.class)
})
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
class JavaConfigTests {
@Autowired

View File

@@ -48,7 +48,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ContextConfiguration("../../context/root-context.xml"),
@ContextConfiguration("../../context/servlet-context.xml")
})
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class WebAppResourceTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -47,7 +47,7 @@ import static org.mockito.BDDMockito.given;
@ContextConfiguration("../../context/root-context.xml"),
@ContextConfiguration("../../context/servlet-context.xml")
})
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class XmlConfigTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -62,7 +62,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextHierarchy(@ContextConfiguration(classes = AsyncControllerJavaConfigTests.WebConfig.class))
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class AsyncControllerJavaConfigTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -68,7 +68,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ContextConfiguration(classes = RootConfig.class),
@ContextConfiguration(classes = WebConfig.class)
})
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class JavaConfigTests {
@Autowired

View File

@@ -49,7 +49,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ContextConfiguration("root-context.xml"),
@ContextConfiguration("servlet-context.xml")
})
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class WebAppResourceTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@@ -50,7 +50,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@ContextConfiguration("root-context.xml"),
@ContextConfiguration("servlet-context.xml")
})
@DisabledInAotMode // @ContextHierarchy is not supported in AOT.
@DisabledInAotMode("@ContextHierarchy is not supported in AOT")
public class XmlConfigTests {
@Autowired