Ensure integration tests pass in AOT mode
See gh-29122
This commit is contained in:
@@ -23,6 +23,7 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||
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 @@ import static org.springframework.test.context.jdbc.SqlMergeMode.MergeMode.OVERR
|
||||
* @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 {
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ import java.util.List;
|
||||
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 @@ import static org.springframework.test.context.NestedTestConfiguration.Enclosing
|
||||
* @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 @@ class TestExecutionListenersNestedTests {
|
||||
}
|
||||
|
||||
@Nested
|
||||
@SpringJUnitConfig(Config.class)
|
||||
@TestExecutionListeners(BarTestExecutionListener.class)
|
||||
@DisabledInAotMode
|
||||
class ConfigOverriddenByDefaultTests {
|
||||
|
||||
@Test
|
||||
@@ -91,7 +94,6 @@ class TestExecutionListenersNestedTests {
|
||||
|
||||
@Nested
|
||||
@NestedTestConfiguration(INHERIT)
|
||||
@SpringJUnitConfig(Config.class)
|
||||
@TestExecutionListeners(BarTestExecutionListener.class)
|
||||
class InheritedAndExtendedConfigTests {
|
||||
|
||||
@@ -103,8 +105,8 @@ class TestExecutionListenersNestedTests {
|
||||
|
||||
@Nested
|
||||
@NestedTestConfiguration(OVERRIDE)
|
||||
@SpringJUnitConfig(Config.class)
|
||||
@TestExecutionListeners(BazTestExecutionListener.class)
|
||||
@DisabledInAotMode
|
||||
class DoubleNestedWithOverriddenConfigTests {
|
||||
|
||||
@Test
|
||||
@@ -139,11 +141,6 @@ class TestExecutionListenersNestedTests {
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Configuration
|
||||
static class Config {
|
||||
/* no user beans required for these tests */
|
||||
}
|
||||
|
||||
private abstract static class BaseTestExecutionListener extends AbstractTestExecutionListener {
|
||||
|
||||
protected abstract String name();
|
||||
|
||||
Reference in New Issue
Block a user