DATAJDBC-574 - Enables and fixes SqlServer tests.
Utilizes Testcontainers reuse feature. Original pull request: #238.
This commit is contained in:
committed by
Mark Paluch
parent
d24ca640f7
commit
2cf6efbe5c
36
pom.xml
36
pom.xml
@@ -208,24 +208,24 @@
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--<execution>-->
|
||||
<!--<id>mssql-test</id>-->
|
||||
<!--<phase>test</phase>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>test</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--<configuration>-->
|
||||
<!--<includes>-->
|
||||
<!--<include>**/*IntegrationTests.java</include>-->
|
||||
<!--</includes>-->
|
||||
<!--<excludes>-->
|
||||
<!--<exclude>**/*HsqlIntegrationTests.java</exclude>-->
|
||||
<!--</excludes>-->
|
||||
<!--<systemPropertyVariables>-->
|
||||
<!--<spring.profiles.active>mssql</spring.profiles.active>-->
|
||||
<!--</systemPropertyVariables>-->
|
||||
<!--</configuration>-->
|
||||
<!--</execution>-->
|
||||
<execution>
|
||||
<id>mssql-test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*IntegrationTests.java</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/*HsqlIntegrationTests.java</exclude>
|
||||
</excludes>
|
||||
<systemPropertyVariables>
|
||||
<spring.profiles.active>mssql</spring.profiles.active>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -310,7 +310,7 @@ public class JdbcAggregateTemplateIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-112
|
||||
@EnabledOnFeature(SUPPORTS_QUOTED_IDS)
|
||||
@EnabledOnFeature({SUPPORTS_QUOTED_IDS, SUPPORTS_GENERATED_IDS_IN_REFERENCED_ENTITIES})
|
||||
public void updateReferencedEntityFromNull() {
|
||||
|
||||
legoSet.setManual(null);
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.platform.commons.util.ExceptionUtils;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -47,6 +48,7 @@ import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory;
|
||||
import org.springframework.data.jdbc.testing.TestConfiguration;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit4.rules.SpringClassRule;
|
||||
import org.springframework.test.context.junit4.rules.SpringMethodRule;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
@@ -58,6 +60,7 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
* @author Myeonghyeon Lee
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
public class JdbcRepositoryConcurrencyIntegrationTests {
|
||||
|
||||
@Configuration
|
||||
@@ -77,9 +80,6 @@ public class JdbcRepositoryConcurrencyIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@ClassRule public static final SpringClassRule classRule = new SpringClassRule();
|
||||
@Rule public SpringMethodRule methodRule = new SpringMethodRule();
|
||||
|
||||
@Autowired NamedParameterJdbcTemplate template;
|
||||
@Autowired DummyEntityRepository repository;
|
||||
@Autowired PlatformTransactionManager transactionManager;
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.jdbc.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.jdbc.testing.TestDatabaseFeatures.Feature.*;
|
||||
import static org.springframework.test.context.TestExecutionListeners.MergeMode.*;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import lombok.Data;
|
||||
@@ -29,17 +30,21 @@ import java.util.Set;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory;
|
||||
import org.springframework.data.jdbc.testing.AssumeFeatureRule;
|
||||
import org.springframework.data.jdbc.testing.EnabledOnFeature;
|
||||
import org.springframework.data.jdbc.testing.TestConfiguration;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit4.rules.SpringClassRule;
|
||||
import org.springframework.test.context.junit4.rules.SpringMethodRule;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -52,11 +57,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@Transactional
|
||||
@TestExecutionListeners(value = AssumeFeatureRule.class, mergeMode = MERGE_WITH_DEFAULTS)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class JdbcRepositoryWithCollectionsIntegrationTests {
|
||||
|
||||
@ClassRule public static final SpringClassRule classRule = new SpringClassRule();
|
||||
@Rule public SpringMethodRule methodRule = new SpringMethodRule();
|
||||
|
||||
@Autowired NamedParameterJdbcTemplate template;
|
||||
@Autowired DummyEntityRepository repository;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.jdbc.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.jdbc.testing.TestDatabaseFeatures.Feature.*;
|
||||
import static org.springframework.test.context.TestExecutionListeners.MergeMode.*;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import lombok.Data;
|
||||
@@ -35,11 +36,13 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory;
|
||||
import org.springframework.data.jdbc.testing.AssumeFeatureRule;
|
||||
import org.springframework.data.jdbc.testing.EnabledOnFeature;
|
||||
import org.springframework.data.jdbc.testing.TestConfiguration;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.junit4.rules.SpringClassRule;
|
||||
import org.springframework.test.context.junit4.rules.SpringMethodRule;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -52,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@Transactional
|
||||
@TestExecutionListeners(value = AssumeFeatureRule.class, mergeMode = MERGE_WITH_DEFAULTS)
|
||||
public class JdbcRepositoryWithListsIntegrationTests {
|
||||
|
||||
@ClassRule public static final SpringClassRule classRule = new SpringClassRule();
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.jdbc.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.jdbc.testing.TestDatabaseFeatures.Feature.*;
|
||||
import static org.springframework.test.context.TestExecutionListeners.MergeMode.*;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import lombok.Data;
|
||||
@@ -28,17 +29,21 @@ import java.util.Map;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory;
|
||||
import org.springframework.data.jdbc.testing.AssumeFeatureRule;
|
||||
import org.springframework.data.jdbc.testing.EnabledOnFeature;
|
||||
import org.springframework.data.jdbc.testing.TestConfiguration;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit4.rules.SpringClassRule;
|
||||
import org.springframework.test.context.junit4.rules.SpringMethodRule;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -51,6 +56,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@Transactional
|
||||
@TestExecutionListeners(value = AssumeFeatureRule.class, mergeMode = MERGE_WITH_DEFAULTS)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class JdbcRepositoryWithMapsIntegrationTests {
|
||||
|
||||
@Configuration
|
||||
@@ -70,9 +77,6 @@ public class JdbcRepositoryWithMapsIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@ClassRule public static final SpringClassRule classRule = new SpringClassRule();
|
||||
@Rule public SpringMethodRule methodRule = new SpringMethodRule();
|
||||
|
||||
@Autowired NamedParameterJdbcTemplate template;
|
||||
@Autowired DummyEntityRepository repository;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import javax.sql.DataSource;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.testcontainers.containers.MSSQLServerContainer;
|
||||
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
|
||||
@@ -49,7 +50,8 @@ public class MsSqlDataSourceConfiguration extends DataSourceConfiguration {
|
||||
|
||||
if (MSSQL_CONTAINER == null) {
|
||||
|
||||
MSSQLServerContainer<?> container = new MSSQLServerContainer<>();
|
||||
MSSQLServerContainer<?> container = new MSSQLServerContainer<>() //
|
||||
.withReuse(true);
|
||||
container.start();
|
||||
|
||||
MSSQL_CONTAINER = container;
|
||||
@@ -59,6 +61,13 @@ public class MsSqlDataSourceConfiguration extends DataSourceConfiguration {
|
||||
sqlServerDataSource.setURL(MSSQL_CONTAINER.getJdbcUrl());
|
||||
sqlServerDataSource.setUser(MSSQL_CONTAINER.getUsername());
|
||||
sqlServerDataSource.setPassword(MSSQL_CONTAINER.getPassword());
|
||||
|
||||
return sqlServerDataSource;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void customizePopulator(ResourceDatabasePopulator populator) {
|
||||
populator.setIgnoreFailedDrops(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE SCHEMA OTHER;
|
||||
|
||||
CREATE TABLE OTHER.DUMMY_ENTITY
|
||||
(
|
||||
ID BIGINT IDENTITY PRIMARY KEY,
|
||||
NAME VARCHAR(30)
|
||||
);
|
||||
|
||||
CREATE TABLE OTHER.REFERENCED
|
||||
(
|
||||
DUMMY_ENTITY INTEGER,
|
||||
NAME VARCHAR(30)
|
||||
);
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
CREATE TABLE dummy_entity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100));
|
||||
CREATE TABLE element (id BIGINT AUTO_INCREMENT PRIMARY KEY, content BIGINT, Dummy_Entity_key BIGINT,dummy_entity BIGINT);
|
||||
DROP TABLE ELEMENT;
|
||||
DROP TABLE DUMMY_ENTITY;
|
||||
|
||||
CREATE TABLE dummy_entity ( id BIGINT IDENTITY PRIMARY KEY, NAME VARCHAR(100));
|
||||
CREATE TABLE element (id BIGINT IDENTITY PRIMARY KEY, content BIGINT, Dummy_Entity_key BIGINT,dummy_entity BIGINT);
|
||||
|
||||
@@ -3,5 +3,5 @@ CREATE TABLE dummy_entity
|
||||
(
|
||||
id_Prop BIGINT IDENTITY PRIMARY KEY,
|
||||
NAME VARCHAR(100),
|
||||
POINT_IN_TIME TIMESTAMP
|
||||
POINT_IN_TIME DATETIME
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user