diff --git a/spring-test/src/test/java/org/springframework/test/context/jdbc/BeforeTestClassSqlScriptsTests.java b/spring-test/src/test/java/org/springframework/test/context/jdbc/BeforeTestClassSqlScriptsTests.java index aa8be3e5b8c2..ae96e87dc2f4 100644 --- a/spring-test/src/test/java/org/springframework/test/context/jdbc/BeforeTestClassSqlScriptsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/jdbc/BeforeTestClassSqlScriptsTests.java @@ -23,6 +23,7 @@ import org.springframework.test.context.jdbc.Sql.ExecutionPhase; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; +import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_CLASS; import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TEST_CLASS; import static org.springframework.test.context.jdbc.SqlMergeMode.MergeMode.MERGE; import static org.springframework.test.context.jdbc.SqlMergeMode.MergeMode.OVERRIDE; @@ -36,7 +37,7 @@ * @since 6.1 */ @SpringJUnitConfig(EmptyDatabaseConfig.class) -@DirtiesContext +@DirtiesContext(classMode = BEFORE_CLASS) @Sql(scripts = {"recreate-schema.sql", "data-add-catbert.sql"}, executionPhase = BEFORE_TEST_CLASS) class BeforeTestClassSqlScriptsTests extends AbstractTransactionalTests { diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/TestExecutionListenersNestedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/TestExecutionListenersNestedTests.java index 00ef0f23d048..0d94834ef80b 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/TestExecutionListenersNestedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/TestExecutionListenersNestedTests.java @@ -22,13 +22,13 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.context.annotation.Configuration; import org.springframework.test.context.NestedTestConfiguration; import org.springframework.test.context.TestContext; import org.springframework.test.context.TestExecutionListeners; +import org.springframework.test.context.aot.DisabledInAotMode; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.junit.jupiter.nested.TestExecutionListenersNestedTests.FooTestExecutionListener; import org.springframework.test.context.support.AbstractTestExecutionListener; @@ -44,9 +44,12 @@ * @author Sam Brannen * @since 5.3 */ -@SpringJUnitConfig +@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 class TestExecutionListenersNestedTests { private static final String FOO = "foo"; @@ -79,8 +82,8 @@ void test() { } @Nested - @SpringJUnitConfig(Config.class) @TestExecutionListeners(BarTestExecutionListener.class) + @DisabledInAotMode class ConfigOverriddenByDefaultTests { @Test @@ -91,7 +94,6 @@ void test() { @Nested @NestedTestConfiguration(INHERIT) - @SpringJUnitConfig(Config.class) @TestExecutionListeners(BarTestExecutionListener.class) class InheritedAndExtendedConfigTests { @@ -103,8 +105,8 @@ void test() { @Nested @NestedTestConfiguration(OVERRIDE) - @SpringJUnitConfig(Config.class) @TestExecutionListeners(BazTestExecutionListener.class) + @DisabledInAotMode class DoubleNestedWithOverriddenConfigTests { @Test @@ -139,11 +141,6 @@ void test() { // ------------------------------------------------------------------------- - @Configuration - static class Config { - /* no user beans required for these tests */ - } - private abstract static class BaseTestExecutionListener extends AbstractTestExecutionListener { protected abstract String name();