From ddec3cc5317dc81f8250260cd61699349cdd3b1c Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Tue, 10 Oct 2023 08:25:29 +0200 Subject: [PATCH] Adapt to new test infrastructure. Originial pull request #1222 See #1220 See #1620 --- ...tomizingNamespaceHsqlIntegrationTests.java | 14 ++++++++------ .../mybatis/MyBatisHsqlIntegrationTests.java | 19 ++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisCustomizingNamespaceHsqlIntegrationTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisCustomizingNamespaceHsqlIntegrationTests.java index 4f7cca8138..37725dcb30 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisCustomizingNamespaceHsqlIntegrationTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisCustomizingNamespaceHsqlIntegrationTests.java @@ -37,6 +37,10 @@ import org.springframework.data.jdbc.core.convert.JdbcConverter; import org.springframework.data.jdbc.core.mapping.JdbcMappingContext; import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; +import org.springframework.data.jdbc.testing.DatabaseType; +import org.springframework.data.jdbc.testing.EnabledOnDatabase; +import org.springframework.data.jdbc.testing.IntegrationTest; +import org.springframework.data.jdbc.testing.TestClass; import org.springframework.data.jdbc.testing.TestConfiguration; import org.springframework.data.relational.core.dialect.HsqlDbDialect; import org.springframework.data.relational.core.mapping.RelationalMappingContext; @@ -54,10 +58,8 @@ * @author Jens Schauder * @author Tyler Van Gorder */ -@ContextConfiguration -@ActiveProfiles("hsql") -@Transactional -@ExtendWith(SpringExtension.class) +@IntegrationTest +@EnabledOnDatabase(DatabaseType.HSQL) public class MyBatisCustomizingNamespaceHsqlIntegrationTests { @Autowired SqlSessionFactory sqlSessionFactory; @@ -84,8 +86,8 @@ interface DummyEntityRepository extends CrudRepository {} static class Config { @Bean - Class testClass() { - return MyBatisCustomizingNamespaceHsqlIntegrationTests.class; + TestClass testClass() { + return TestClass.of(MyBatisCustomizingNamespaceHsqlIntegrationTests.class); } @Bean diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisHsqlIntegrationTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisHsqlIntegrationTests.java index f66b5de03f..28bac0b1a5 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisHsqlIntegrationTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisHsqlIntegrationTests.java @@ -23,7 +23,6 @@ import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.beans.factory.annotation.Autowired; @@ -33,16 +32,16 @@ import org.springframework.data.jdbc.core.convert.DataAccessStrategy; import org.springframework.data.jdbc.core.convert.JdbcConverter; import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; +import org.springframework.data.jdbc.testing.DatabaseType; +import org.springframework.data.jdbc.testing.EnabledOnDatabase; +import org.springframework.data.jdbc.testing.IntegrationTest; +import org.springframework.data.jdbc.testing.TestClass; import org.springframework.data.jdbc.testing.TestConfiguration; import org.springframework.data.relational.core.dialect.HsqlDbDialect; import org.springframework.data.relational.core.mapping.RelationalMappingContext; import org.springframework.data.repository.CrudRepository; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.transaction.annotation.Transactional; /** * Tests the integration with Mybatis. @@ -51,10 +50,8 @@ * @author Greg Turnquist * @author Mark Paluch */ -@ContextConfiguration -@ActiveProfiles("hsql") -@Transactional -@ExtendWith(SpringExtension.class) +@IntegrationTest +@EnabledOnDatabase(DatabaseType.HSQL) public class MyBatisHsqlIntegrationTests { @Autowired SqlSessionFactory sqlSessionFactory; @@ -91,8 +88,8 @@ interface DummyEntityRepository extends CrudRepository { static class Config { @Bean - Class testClass() { - return MyBatisHsqlIntegrationTests.class; + TestClass testClass() { + return TestClass.of(MyBatisHsqlIntegrationTests.class); } @Bean