Ensure integration tests are suitable for AOT processing

This commit is contained in:
Sam Brannen 2024-09-23 16:18:37 +02:00
parent 7d99790c34
commit 59eaed0b28
5 changed files with 12 additions and 8 deletions

View File

@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 6.2 * @since 6.2
*/ */
@SpringJUnitConfig @SpringJUnitConfig
class TestBeanForByTypeLookupIntegrationTests { public class TestBeanForByTypeLookupIntegrationTests {
@TestBean @TestBean
ExampleService anyNameForService; ExampleService anyNameForService;

View File

@ -40,14 +40,14 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen * @author Sam Brannen
* @since 6.2 * @since 6.2
*/ */
class TestBeanForInheritanceIntegrationTests { public class TestBeanForInheritanceIntegrationTests {
static Pojo enclosingClassBeanOverride() { static Pojo enclosingClassBeanOverride() {
return new FakePojo("in enclosing test class"); return new FakePojo("in enclosing test class");
} }
@SpringJUnitConfig @SpringJUnitConfig
abstract static class AbstractTestBeanIntegrationTestCase { public abstract static class AbstractTestBeanIntegrationTestCase {
@TestBean(name = "someBean") @TestBean(name = "someBean")
Pojo someBean; Pojo someBean;
@ -70,7 +70,7 @@ class TestBeanForInheritanceIntegrationTests {
return new FakePojo("in superclass"); return new FakePojo("in superclass");
} }
interface Pojo { public interface Pojo {
default String getValue() { default String getValue() {
return "Prod"; return "Prod";

View File

@ -40,7 +40,7 @@ import static org.mockito.BDDMockito.when;
*/ */
@SpringJUnitConfig @SpringJUnitConfig
@TestMethodOrder(OrderAnnotation.class) @TestMethodOrder(OrderAnnotation.class)
class MockitoBeanForBeanFactoryIntegrationTests { public class MockitoBeanForBeanFactoryIntegrationTests {
@MockitoBean @MockitoBean
private TestBean testBean; private TestBean testBean;
@ -98,7 +98,7 @@ class MockitoBeanForBeanFactoryIntegrationTests {
} }
interface TestBean { public interface TestBean {
String hello(); String hello();

View File

@ -123,7 +123,7 @@ public class MockitoBeanForByTypeLookupIntegrationTests {
} }
interface AnotherService { public interface AnotherService {
String hello(); String hello();

View File

@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.aot.DisabledInAotMode;
/** /**
* Integration tests that verify support for property placeholders in SQL script locations. * Integration tests that verify support for property placeholders in SQL script locations.
@ -29,14 +30,15 @@ import org.springframework.test.context.TestPropertySource;
* @author Sam Brannen * @author Sam Brannen
* @since 6.2 * @since 6.2
*/ */
@ContextConfiguration(classes = PopulatedSchemaDatabaseConfig.class)
class PropertyPlaceholderSqlScriptsTests { class PropertyPlaceholderSqlScriptsTests {
private static final String SCRIPT_LOCATION = "classpath:org/springframework/test/context/jdbc/${vendor}/data.sql"; private static final String SCRIPT_LOCATION = "classpath:org/springframework/test/context/jdbc/${vendor}/data.sql";
@Nested @Nested
@ContextConfiguration(classes = PopulatedSchemaDatabaseConfig.class)
@TestPropertySource(properties = "vendor = db1") @TestPropertySource(properties = "vendor = db1")
@DirtiesContext @DirtiesContext
@DisabledInAotMode // ${vendor} does not get resolved during AOT processing
class DatabaseOneTests extends AbstractTransactionalTests { class DatabaseOneTests extends AbstractTransactionalTests {
@Test @Test
@ -47,8 +49,10 @@ class PropertyPlaceholderSqlScriptsTests {
} }
@Nested @Nested
@ContextConfiguration(classes = PopulatedSchemaDatabaseConfig.class)
@TestPropertySource(properties = "vendor = db2") @TestPropertySource(properties = "vendor = db2")
@DirtiesContext @DirtiesContext
@DisabledInAotMode // ${vendor} does not get resolved during AOT processing
class DatabaseTwoTests extends AbstractTransactionalTests { class DatabaseTwoTests extends AbstractTransactionalTests {
@Test @Test