Skip to content

Commit 563112c

Browse files
committed
Ensure integration tests pass in AOT mode
See gh-29122
1 parent 37e6fe5 commit 563112c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

Diff for: spring-test/src/test/java/org/springframework/test/context/jdbc/BeforeTestClassSqlScriptsTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
2424
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2525

26+
import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_CLASS;
2627
import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TEST_CLASS;
2728
import static org.springframework.test.context.jdbc.SqlMergeMode.MergeMode.MERGE;
2829
import static org.springframework.test.context.jdbc.SqlMergeMode.MergeMode.OVERRIDE;
@@ -36,7 +37,7 @@
3637
* @since 6.1
3738
*/
3839
@SpringJUnitConfig(EmptyDatabaseConfig.class)
39-
@DirtiesContext
40+
@DirtiesContext(classMode = BEFORE_CLASS)
4041
@Sql(scripts = {"recreate-schema.sql", "data-add-catbert.sql"}, executionPhase = BEFORE_TEST_CLASS)
4142
class BeforeTestClassSqlScriptsTests extends AbstractTransactionalTests {
4243

Diff for: spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/TestExecutionListenersNestedTests.java

+8-11
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
import org.junit.jupiter.api.AfterEach;
2323
import org.junit.jupiter.api.Nested;
2424
import org.junit.jupiter.api.Test;
25+
import org.junit.jupiter.api.extension.ExtendWith;
2526

26-
import org.springframework.context.annotation.Configuration;
2727
import org.springframework.test.context.NestedTestConfiguration;
2828
import org.springframework.test.context.TestContext;
2929
import org.springframework.test.context.TestExecutionListeners;
30+
import org.springframework.test.context.aot.DisabledInAotMode;
3031
import org.springframework.test.context.junit.jupiter.SpringExtension;
31-
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3232
import org.springframework.test.context.junit.jupiter.nested.TestExecutionListenersNestedTests.FooTestExecutionListener;
3333
import org.springframework.test.context.support.AbstractTestExecutionListener;
3434

@@ -44,9 +44,12 @@
4444
* @author Sam Brannen
4545
* @since 5.3
4646
*/
47-
@SpringJUnitConfig
47+
@ExtendWith(SpringExtension.class)
4848
@TestExecutionListeners(FooTestExecutionListener.class)
4949
@NestedTestConfiguration(OVERRIDE) // since INHERIT is now the global default
50+
// Since this test class does not load an ApplicationContext,
51+
// this test class simply is not supported for AOT processing.
52+
@DisabledInAotMode
5053
class TestExecutionListenersNestedTests {
5154

5255
private static final String FOO = "foo";
@@ -79,8 +82,8 @@ void test() {
7982
}
8083

8184
@Nested
82-
@SpringJUnitConfig(Config.class)
8385
@TestExecutionListeners(BarTestExecutionListener.class)
86+
@DisabledInAotMode
8487
class ConfigOverriddenByDefaultTests {
8588

8689
@Test
@@ -91,7 +94,6 @@ void test() {
9194

9295
@Nested
9396
@NestedTestConfiguration(INHERIT)
94-
@SpringJUnitConfig(Config.class)
9597
@TestExecutionListeners(BarTestExecutionListener.class)
9698
class InheritedAndExtendedConfigTests {
9799

@@ -103,8 +105,8 @@ void test() {
103105

104106
@Nested
105107
@NestedTestConfiguration(OVERRIDE)
106-
@SpringJUnitConfig(Config.class)
107108
@TestExecutionListeners(BazTestExecutionListener.class)
109+
@DisabledInAotMode
108110
class DoubleNestedWithOverriddenConfigTests {
109111

110112
@Test
@@ -139,11 +141,6 @@ void test() {
139141

140142
// -------------------------------------------------------------------------
141143

142-
@Configuration
143-
static class Config {
144-
/* no user beans required for these tests */
145-
}
146-
147144
private abstract static class BaseTestExecutionListener extends AbstractTestExecutionListener {
148145

149146
protected abstract String name();

0 commit comments

Comments
 (0)