Skip to content

Commit

Permalink
Ensure integration tests pass in AOT mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Oct 22, 2023
1 parent 37e6fe5 commit 563112c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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";
Expand Down Expand Up @@ -79,8 +82,8 @@ void test() {
}

@Nested
@SpringJUnitConfig(Config.class)
@TestExecutionListeners(BarTestExecutionListener.class)
@DisabledInAotMode
class ConfigOverriddenByDefaultTests {

@Test
Expand All @@ -91,7 +94,6 @@ void test() {

@Nested
@NestedTestConfiguration(INHERIT)
@SpringJUnitConfig(Config.class)
@TestExecutionListeners(BarTestExecutionListener.class)
class InheritedAndExtendedConfigTests {

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

@Nested
@NestedTestConfiguration(OVERRIDE)
@SpringJUnitConfig(Config.class)
@TestExecutionListeners(BazTestExecutionListener.class)
@DisabledInAotMode
class DoubleNestedWithOverriddenConfigTests {

@Test
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 563112c

Please sign in to comment.