Update integration tests
- upgrade TestContainers to 1.7.1 - update Docker images - improve MariaDB/MySQL tests to use UTF-8 Closes gh-1034
This commit is contained in:
@@ -5,6 +5,7 @@ dependencyManagement {
|
|||||||
mavenBom 'org.springframework:spring-framework-bom:5.0.4.RELEASE'
|
mavenBom 'org.springframework:spring-framework-bom:5.0.4.RELEASE'
|
||||||
mavenBom 'org.springframework.data:spring-data-releasetrain:Kay-SR4'
|
mavenBom 'org.springframework.data:spring-data-releasetrain:Kay-SR4'
|
||||||
mavenBom 'org.springframework.security:spring-security-bom:5.0.2.RELEASE'
|
mavenBom 'org.springframework.security:spring-security-bom:5.0.2.RELEASE'
|
||||||
|
mavenBom 'org.testcontainers:testcontainers-bom:1.7.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -13,14 +14,6 @@ dependencyManagement {
|
|||||||
entry 'hazelcast-client'
|
entry 'hazelcast-client'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencySet(group: 'org.testcontainers', version: '1.6.0') {
|
|
||||||
entry 'mariadb'
|
|
||||||
entry 'mssqlserver'
|
|
||||||
entry 'mysql'
|
|
||||||
entry 'postgresql'
|
|
||||||
entry 'testcontainers'
|
|
||||||
}
|
|
||||||
|
|
||||||
dependency 'com.h2database:h2:1.4.196'
|
dependency 'com.h2database:h2:1.4.196'
|
||||||
dependency 'com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8'
|
dependency 'com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8'
|
||||||
dependency 'edu.umd.cs.mtc:multithreadedtc:1.01'
|
dependency 'edu.umd.cs.mtc:multithreadedtc:1.01'
|
||||||
|
|||||||
@@ -17,8 +17,9 @@
|
|||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.ClassRule;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
@@ -49,12 +50,21 @@ import org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDr
|
|||||||
@ContextConfiguration(initializers = FindByUsernameTests.Initializer.class)
|
@ContextConfiguration(initializers = FindByUsernameTests.Initializer.class)
|
||||||
public class FindByUsernameTests {
|
public class FindByUsernameTests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "redis:4.0.8";
|
private static final String DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@ClassRule
|
private static GenericContainer container = new GenericContainer(DOCKER_IMAGE)
|
||||||
public static GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE)
|
|
||||||
.withExposedPorts(6379);
|
.withExposedPorts(6379);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@@ -93,8 +103,8 @@ public class FindByUsernameTests {
|
|||||||
public void initialize(
|
public void initialize(
|
||||||
ConfigurableApplicationContext configurableApplicationContext) {
|
ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
TestPropertyValues
|
TestPropertyValues
|
||||||
.of("spring.redis.host=" + redisContainer.getContainerIpAddress(),
|
.of("spring.redis.host=" + container.getContainerIpAddress(),
|
||||||
"spring.redis.port=" + redisContainer.getFirstMappedPort())
|
"spring.redis.port=" + container.getFirstMappedPort())
|
||||||
.applyTo(configurableApplicationContext.getEnvironment());
|
.applyTo(configurableApplicationContext.getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ package sample;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.ClassRule;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
@@ -53,12 +54,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@ContextConfiguration(initializers = HttpRedisJsonTest.Initializer.class)
|
@ContextConfiguration(initializers = HttpRedisJsonTest.Initializer.class)
|
||||||
public class HttpRedisJsonTest {
|
public class HttpRedisJsonTest {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "redis:4.0.8";
|
private static final String DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@ClassRule
|
private static GenericContainer container = new GenericContainer(DOCKER_IMAGE)
|
||||||
public static GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE)
|
|
||||||
.withExposedPorts(6379);
|
.withExposedPorts(6379);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@@ -117,8 +127,8 @@ public class HttpRedisJsonTest {
|
|||||||
public void initialize(
|
public void initialize(
|
||||||
ConfigurableApplicationContext configurableApplicationContext) {
|
ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
TestPropertyValues
|
TestPropertyValues
|
||||||
.of("spring.redis.host=" + redisContainer.getContainerIpAddress(),
|
.of("spring.redis.host=" + container.getContainerIpAddress(),
|
||||||
"spring.redis.port=" + redisContainer.getFirstMappedPort())
|
"spring.redis.port=" + container.getFirstMappedPort())
|
||||||
.applyTo(configurableApplicationContext.getEnvironment());
|
.applyTo(configurableApplicationContext.getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
@@ -42,12 +43,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@ContextConfiguration(initializers = RedisSerializerTest.Initializer.class)
|
@ContextConfiguration(initializers = RedisSerializerTest.Initializer.class)
|
||||||
public class RedisSerializerTest {
|
public class RedisSerializerTest {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "redis:4.0.8";
|
private static final String DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@ClassRule
|
private static GenericContainer container = new GenericContainer(DOCKER_IMAGE)
|
||||||
public static GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE)
|
|
||||||
.withExposedPorts(6379);
|
.withExposedPorts(6379);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@SpringSessionRedisOperations
|
@SpringSessionRedisOperations
|
||||||
private RedisTemplate<Object, Object> sessionRedisTemplate;
|
private RedisTemplate<Object, Object> sessionRedisTemplate;
|
||||||
|
|
||||||
@@ -66,8 +76,8 @@ public class RedisSerializerTest {
|
|||||||
public void initialize(
|
public void initialize(
|
||||||
ConfigurableApplicationContext configurableApplicationContext) {
|
ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
TestPropertyValues
|
TestPropertyValues
|
||||||
.of("spring.redis.host=" + redisContainer.getContainerIpAddress(),
|
.of("spring.redis.host=" + container.getContainerIpAddress(),
|
||||||
"spring.redis.port=" + redisContainer.getFirstMappedPort())
|
"spring.redis.port=" + container.getFirstMappedPort())
|
||||||
.applyTo(configurableApplicationContext.getEnvironment());
|
.applyTo(configurableApplicationContext.getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,9 @@
|
|||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.ClassRule;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
@@ -48,12 +49,21 @@ import org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDr
|
|||||||
@ContextConfiguration(initializers = BootTests.Initializer.class)
|
@ContextConfiguration(initializers = BootTests.Initializer.class)
|
||||||
public class BootTests {
|
public class BootTests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "redis:4.0.8";
|
private static final String DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@ClassRule
|
private static GenericContainer container = new GenericContainer(DOCKER_IMAGE)
|
||||||
public static GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE)
|
|
||||||
.withExposedPorts(6379);
|
.withExposedPorts(6379);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@@ -99,8 +109,8 @@ public class BootTests {
|
|||||||
public void initialize(
|
public void initialize(
|
||||||
ConfigurableApplicationContext configurableApplicationContext) {
|
ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
TestPropertyValues
|
TestPropertyValues
|
||||||
.of("spring.redis.host=" + redisContainer.getContainerIpAddress(),
|
.of("spring.redis.host=" + container.getContainerIpAddress(),
|
||||||
"spring.redis.port=" + redisContainer.getFirstMappedPort())
|
"spring.redis.port=" + container.getFirstMappedPort())
|
||||||
.applyTo(configurableApplicationContext.getEnvironment());
|
.applyTo(configurableApplicationContext.getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ package sample;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.ClassRule;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
@@ -49,12 +50,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
@ContextConfiguration(initializers = AttributeTests.Initializer.class)
|
@ContextConfiguration(initializers = AttributeTests.Initializer.class)
|
||||||
public class AttributeTests {
|
public class AttributeTests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "redis:4.0.8";
|
private static final String DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@ClassRule
|
private static GenericContainer container = new GenericContainer(DOCKER_IMAGE)
|
||||||
public static GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE)
|
|
||||||
.withExposedPorts(6379);
|
.withExposedPorts(6379);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@LocalServerPort
|
@LocalServerPort
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
@@ -106,8 +116,8 @@ public class AttributeTests {
|
|||||||
public void initialize(
|
public void initialize(
|
||||||
ConfigurableApplicationContext configurableApplicationContext) {
|
ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
TestPropertyValues
|
TestPropertyValues
|
||||||
.of("spring.redis.host=" + redisContainer.getContainerIpAddress(),
|
.of("spring.redis.host=" + container.getContainerIpAddress(),
|
||||||
"spring.redis.port=" + redisContainer.getFirstMappedPort())
|
"spring.redis.port=" + container.getFirstMappedPort())
|
||||||
.applyTo(configurableApplicationContext.getEnvironment());
|
.applyTo(configurableApplicationContext.getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
@@ -55,12 +56,21 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|||||||
@ContextConfiguration(initializers = ApplicationTests.Initializer.class)
|
@ContextConfiguration(initializers = ApplicationTests.Initializer.class)
|
||||||
public class ApplicationTests {
|
public class ApplicationTests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "redis:4.0.8";
|
private static final String DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@ClassRule
|
private static GenericContainer container = new GenericContainer(DOCKER_IMAGE)
|
||||||
public static GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE)
|
|
||||||
.withExposedPorts(6379);
|
.withExposedPorts(6379);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Value("${local.server.port}")
|
@Value("${local.server.port}")
|
||||||
private String port;
|
private String port;
|
||||||
|
|
||||||
@@ -88,8 +98,8 @@ public class ApplicationTests {
|
|||||||
public void initialize(
|
public void initialize(
|
||||||
ConfigurableApplicationContext configurableApplicationContext) {
|
ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
TestPropertyValues
|
TestPropertyValues
|
||||||
.of("spring.redis.host=" + redisContainer.getContainerIpAddress(),
|
.of("spring.redis.host=" + container.getContainerIpAddress(),
|
||||||
"spring.redis.port=" + redisContainer.getFirstMappedPort())
|
"spring.redis.port=" + container.getFirstMappedPort())
|
||||||
.applyTo(configurableApplicationContext.getEnvironment());
|
.applyTo(configurableApplicationContext.getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -30,23 +28,11 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor
|
|||||||
@Profile("embedded-redis")
|
@Profile("embedded-redis")
|
||||||
public class EmbeddedRedisConfig {
|
public class EmbeddedRedisConfig {
|
||||||
|
|
||||||
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.8";
|
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@Bean(initMethod = "start")
|
@Bean(initMethod = "start")
|
||||||
public GenericContainer redisContainer() {
|
public GenericContainer redisContainer() {
|
||||||
return new GenericContainer(REDIS_DOCKER_IMAGE) {
|
return new GenericContainer(REDIS_DOCKER_IMAGE).withExposedPorts(6379);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
super.close();
|
|
||||||
try {
|
|
||||||
this.dockerClient.close();
|
|
||||||
}
|
|
||||||
catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}.withExposedPorts(6379);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -30,23 +28,11 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor
|
|||||||
@Profile("embedded-redis")
|
@Profile("embedded-redis")
|
||||||
public class EmbeddedRedisConfig {
|
public class EmbeddedRedisConfig {
|
||||||
|
|
||||||
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.8";
|
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@Bean(initMethod = "start")
|
@Bean(initMethod = "start")
|
||||||
public GenericContainer redisContainer() {
|
public GenericContainer redisContainer() {
|
||||||
return new GenericContainer(REDIS_DOCKER_IMAGE) {
|
return new GenericContainer(REDIS_DOCKER_IMAGE).withExposedPorts(6379);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
super.close();
|
|
||||||
try {
|
|
||||||
this.dockerClient.close();
|
|
||||||
}
|
|
||||||
catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}.withExposedPorts(6379);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ dependencies {
|
|||||||
testCompile "org.springframework.security:spring-security-test"
|
testCompile "org.springframework.security:spring-security-test"
|
||||||
testCompile "org.assertj:assertj-core"
|
testCompile "org.assertj:assertj-core"
|
||||||
testCompile "org.springframework:spring-test"
|
testCompile "org.springframework:spring-test"
|
||||||
testCompile "commons-codec:commons-codec"
|
|
||||||
|
|
||||||
integrationTestCompile "org.testcontainers:testcontainers"
|
integrationTestCompile "org.testcontainers:testcontainers"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
package rest;
|
package rest;
|
||||||
|
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.ClassRule;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
@@ -55,12 +56,21 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
public class RestMockMvcTests {
|
public class RestMockMvcTests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "redis:4.0.8";
|
private static final String DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@ClassRule
|
private static GenericContainer container = new GenericContainer(DOCKER_IMAGE)
|
||||||
public static GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE)
|
|
||||||
.withExposedPorts(6379);
|
.withExposedPorts(6379);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SessionRepositoryFilter<? extends Session> sessionRepositoryFilter;
|
private SessionRepositoryFilter<? extends Session> sessionRepositoryFilter;
|
||||||
|
|
||||||
@@ -99,8 +109,8 @@ public class RestMockMvcTests {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public LettuceConnectionFactory redisConnectionFactory() {
|
public LettuceConnectionFactory redisConnectionFactory() {
|
||||||
return new LettuceConnectionFactory(redisContainer.getContainerIpAddress(),
|
return new LettuceConnectionFactory(container.getContainerIpAddress(),
|
||||||
redisContainer.getFirstMappedPort());
|
container.getFirstMappedPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2017 the original author or authors.
|
* Copyright 2014-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -122,6 +122,6 @@ public class RestTests {
|
|||||||
|
|
||||||
private String getAuth(String user, String password) {
|
private String getAuth(String user, String password) {
|
||||||
String auth = user + ":" + password;
|
String auth = user + ":" + password;
|
||||||
return new String(Base64.encodeBase64(auth.getBytes()));
|
return Base64.getEncoder().encodeToString(auth.getBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -30,23 +28,11 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor
|
|||||||
@Profile("embedded-redis")
|
@Profile("embedded-redis")
|
||||||
public class EmbeddedRedisConfig {
|
public class EmbeddedRedisConfig {
|
||||||
|
|
||||||
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.8";
|
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@Bean(initMethod = "start")
|
@Bean(initMethod = "start")
|
||||||
public GenericContainer redisContainer() {
|
public GenericContainer redisContainer() {
|
||||||
return new GenericContainer(REDIS_DOCKER_IMAGE) {
|
return new GenericContainer(REDIS_DOCKER_IMAGE).withExposedPorts(6379);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
super.close();
|
|
||||||
try {
|
|
||||||
this.dockerClient.close();
|
|
||||||
}
|
|
||||||
catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}.withExposedPorts(6379);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -30,23 +28,11 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor
|
|||||||
@Profile("embedded-redis")
|
@Profile("embedded-redis")
|
||||||
public class EmbeddedRedisConfig {
|
public class EmbeddedRedisConfig {
|
||||||
|
|
||||||
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.8";
|
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@Bean(initMethod = "start")
|
@Bean(initMethod = "start")
|
||||||
public GenericContainer redisContainer() {
|
public GenericContainer redisContainer() {
|
||||||
return new GenericContainer(REDIS_DOCKER_IMAGE) {
|
return new GenericContainer(REDIS_DOCKER_IMAGE).withExposedPorts(6379);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
super.close();
|
|
||||||
try {
|
|
||||||
this.dockerClient.close();
|
|
||||||
}
|
|
||||||
catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}.withExposedPorts(6379);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -30,23 +28,11 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor
|
|||||||
@Profile("embedded-redis")
|
@Profile("embedded-redis")
|
||||||
public class EmbeddedRedisConfig {
|
public class EmbeddedRedisConfig {
|
||||||
|
|
||||||
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.8";
|
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@Bean(initMethod = "start")
|
@Bean(initMethod = "start")
|
||||||
public GenericContainer redisContainer() {
|
public GenericContainer redisContainer() {
|
||||||
return new GenericContainer(REDIS_DOCKER_IMAGE) {
|
return new GenericContainer(REDIS_DOCKER_IMAGE).withExposedPorts(6379);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
super.close();
|
|
||||||
try {
|
|
||||||
this.dockerClient.close();
|
|
||||||
}
|
|
||||||
catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}.withExposedPorts(6379);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
package org.springframework.session.data.redis;
|
package org.springframework.session.data.redis;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -30,19 +31,27 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractRedisITests {
|
public abstract class AbstractRedisITests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "redis:4.0.8";
|
private static final String DOCKER_IMAGE = "redis:4.0.9";
|
||||||
|
|
||||||
@ClassRule
|
private static GenericContainer container = new GenericContainer(DOCKER_IMAGE)
|
||||||
public static GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE)
|
|
||||||
.withExposedPorts(6379);
|
.withExposedPorts(6379);
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
protected static class BaseConfig {
|
protected static class BaseConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public LettuceConnectionFactory redisConnectionFactory() {
|
public LettuceConnectionFactory redisConnectionFactory() {
|
||||||
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(
|
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(
|
||||||
redisContainer.getContainerIpAddress(),
|
container.getContainerIpAddress(), container.getFirstMappedPort());
|
||||||
redisContainer.getFirstMappedPort());
|
|
||||||
return new LettuceConnectionFactory(configuration);
|
return new LettuceConnectionFactory(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ import java.sql.SQLException;
|
|||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mariadb.jdbc.MariaDbDataSource;
|
import org.mariadb.jdbc.MariaDbDataSource;
|
||||||
import org.testcontainers.containers.MariaDBContainer;
|
import org.testcontainers.containers.MariaDBContainer;
|
||||||
@@ -43,23 +44,29 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class MariaDB10JdbcOperationsSessionRepositoryITests
|
public class MariaDb10JdbcOperationsSessionRepositoryITests
|
||||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "mariadb:10.2.13";
|
private static MariaDBContainer container = new MariaDb10Container();
|
||||||
|
|
||||||
@ClassRule
|
@BeforeClass
|
||||||
public static MariaDBContainer mariaDBContainer = new MariaDBContainer(DOCKER_IMAGE);
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class Config extends BaseConfig {
|
static class Config extends BaseConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() throws SQLException {
|
public DataSource dataSource() throws SQLException {
|
||||||
MariaDbDataSource dataSource = new MariaDbDataSource(
|
MariaDbDataSource dataSource = new MariaDbDataSource(container.getJdbcUrl());
|
||||||
mariaDBContainer.getJdbcUrl());
|
dataSource.setUserName(container.getUsername());
|
||||||
dataSource.setUserName(mariaDBContainer.getUsername());
|
dataSource.setPassword(container.getPassword());
|
||||||
dataSource.setPassword(mariaDBContainer.getPassword());
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,4 +83,19 @@ public class MariaDB10JdbcOperationsSessionRepositoryITests
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class MariaDb10Container extends MariaDBContainer {
|
||||||
|
|
||||||
|
MariaDb10Container() {
|
||||||
|
super("mariadb:10.2.14");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
super.configure();
|
||||||
|
setCommand("mysqld", "--character-set-server=utf8mb4",
|
||||||
|
"--collation-server=utf8mb4_unicode_ci");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,8 @@ import java.sql.SQLException;
|
|||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mariadb.jdbc.MariaDbDataSource;
|
import org.mariadb.jdbc.MariaDbDataSource;
|
||||||
import org.testcontainers.containers.MariaDBContainer;
|
import org.testcontainers.containers.MariaDBContainer;
|
||||||
@@ -43,23 +44,29 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class MariaDB5JdbcOperationsSessionRepositoryITests
|
public class MariaDb5JdbcOperationsSessionRepositoryITests
|
||||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "mariadb:5.5.59";
|
private static MariaDBContainer container = new MariaDb5Container();
|
||||||
|
|
||||||
@ClassRule
|
@BeforeClass
|
||||||
public static MariaDBContainer mariaDBContainer = new MariaDBContainer(DOCKER_IMAGE);
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class Config extends BaseConfig {
|
static class Config extends BaseConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() throws SQLException {
|
public DataSource dataSource() throws SQLException {
|
||||||
MariaDbDataSource dataSource = new MariaDbDataSource(
|
MariaDbDataSource dataSource = new MariaDbDataSource(container.getJdbcUrl());
|
||||||
mariaDBContainer.getJdbcUrl());
|
dataSource.setUserName(container.getUsername());
|
||||||
dataSource.setUserName(mariaDBContainer.getUsername());
|
dataSource.setPassword(container.getPassword());
|
||||||
dataSource.setPassword(mariaDBContainer.getPassword());
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,4 +83,20 @@ public class MariaDB5JdbcOperationsSessionRepositoryITests
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class MariaDb5Container extends MariaDBContainer {
|
||||||
|
|
||||||
|
MariaDb5Container() {
|
||||||
|
super("mariadb:5.5.59");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
super.configure();
|
||||||
|
setCommand("mysqld", "--character-set-server=utf8mb4",
|
||||||
|
"--collation-server=utf8mb4_unicode_ci", "--innodb_large_prefix",
|
||||||
|
"--innodb_file_format=barracuda", "--innodb-file-per-table");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,8 @@ package org.springframework.session.jdbc;
|
|||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
|
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
|
||||||
import org.junit.ClassRule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.testcontainers.containers.MySQLContainer;
|
import org.testcontainers.containers.MySQLContainer;
|
||||||
|
|
||||||
@@ -40,13 +41,20 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class MySQL5JdbcOperationsSessionRepositoryITests
|
public class MySql5JdbcOperationsSessionRepositoryITests
|
||||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "mysql:5.7.21";
|
private static MySQLContainer container = new MySql5Container();
|
||||||
|
|
||||||
@ClassRule
|
@BeforeClass
|
||||||
public static MySQLContainer mySQLContainer = new MySQLContainer(DOCKER_IMAGE);
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class Config extends BaseConfig {
|
static class Config extends BaseConfig {
|
||||||
@@ -54,9 +62,9 @@ public class MySQL5JdbcOperationsSessionRepositoryITests
|
|||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
MysqlDataSource dataSource = new MysqlDataSource();
|
MysqlDataSource dataSource = new MysqlDataSource();
|
||||||
dataSource.setUrl(mySQLContainer.getJdbcUrl());
|
dataSource.setUrl(container.getJdbcUrl());
|
||||||
dataSource.setUser(mySQLContainer.getUsername());
|
dataSource.setUser(container.getUsername());
|
||||||
dataSource.setPassword(mySQLContainer.getPassword());
|
dataSource.setPassword(container.getPassword());
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,4 +81,19 @@ public class MySQL5JdbcOperationsSessionRepositoryITests
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class MySql5Container extends MySQLContainer {
|
||||||
|
|
||||||
|
MySql5Container() {
|
||||||
|
super("mysql:5.7.22");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
super.configure();
|
||||||
|
setCommand("mysqld", "--character-set-server=utf8mb4",
|
||||||
|
"--collation-server=utf8mb4_unicode_ci");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014-2018 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.session.jdbc;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.testcontainers.containers.MySQLContainer;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.ResourceLoader;
|
||||||
|
import org.springframework.jdbc.datasource.init.DataSourceInitializer;
|
||||||
|
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration tests for {@link JdbcOperationsSessionRepository} using MySQL 8.x database.
|
||||||
|
*
|
||||||
|
* @author Vedran Pavic
|
||||||
|
*/
|
||||||
|
@Ignore
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@WebAppConfiguration
|
||||||
|
@ContextConfiguration
|
||||||
|
public class MySql8JdbcOperationsSessionRepositoryITests
|
||||||
|
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||||
|
|
||||||
|
private static MySQLContainer container = new MySql8Container();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
static class Config extends BaseConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DataSource dataSource() {
|
||||||
|
MysqlDataSource dataSource = new MysqlDataSource();
|
||||||
|
dataSource.setUrl(container.getJdbcUrl());
|
||||||
|
dataSource.setUser(container.getUsername());
|
||||||
|
dataSource.setPassword(container.getPassword());
|
||||||
|
return dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DataSourceInitializer initializer(DataSource dataSource,
|
||||||
|
ResourceLoader resourceLoader) {
|
||||||
|
DataSourceInitializer initializer = new DataSourceInitializer();
|
||||||
|
initializer.setDataSource(dataSource);
|
||||||
|
initializer.setDatabasePopulator(
|
||||||
|
new ResourceDatabasePopulator(resourceLoader.getResource(
|
||||||
|
"classpath:org/springframework/session/jdbc/schema-mysql.sql")));
|
||||||
|
return initializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class MySql8Container extends MySQLContainer {
|
||||||
|
|
||||||
|
MySql8Container() {
|
||||||
|
super("mysql:8.0.11");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
super.configure();
|
||||||
|
setCommand("mysqld", "--character-set-server=utf8mb4",
|
||||||
|
"--collation-server=utf8mb4_unicode_ci");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,7 +18,8 @@ package org.springframework.session.jdbc;
|
|||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.postgresql.ds.PGSimpleDataSource;
|
import org.postgresql.ds.PGSimpleDataSource;
|
||||||
import org.testcontainers.containers.PostgreSQLContainer;
|
import org.testcontainers.containers.PostgreSQLContainer;
|
||||||
@@ -41,14 +42,20 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class PostgreSQL10JdbcOperationsSessionRepositoryITests
|
public class PostgreSql10JdbcOperationsSessionRepositoryITests
|
||||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "postgres:10.2";
|
private static PostgreSQLContainer container = new PostgreSql10Container();
|
||||||
|
|
||||||
@ClassRule
|
@BeforeClass
|
||||||
public static PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer(
|
public static void setUpClass() {
|
||||||
DOCKER_IMAGE);
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class Config extends BaseConfig {
|
static class Config extends BaseConfig {
|
||||||
@@ -56,9 +63,9 @@ public class PostgreSQL10JdbcOperationsSessionRepositoryITests
|
|||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
PGSimpleDataSource dataSource = new PGSimpleDataSource();
|
PGSimpleDataSource dataSource = new PGSimpleDataSource();
|
||||||
dataSource.setUrl(postgreSQLContainer.getJdbcUrl());
|
dataSource.setUrl(container.getJdbcUrl());
|
||||||
dataSource.setUser(postgreSQLContainer.getUsername());
|
dataSource.setUser(container.getUsername());
|
||||||
dataSource.setPassword(postgreSQLContainer.getPassword());
|
dataSource.setPassword(container.getPassword());
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,4 +82,12 @@ public class PostgreSQL10JdbcOperationsSessionRepositoryITests
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class PostgreSql10Container extends PostgreSQLContainer {
|
||||||
|
|
||||||
|
PostgreSql10Container() {
|
||||||
|
super("postgres:10.3");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,8 @@ package org.springframework.session.jdbc;
|
|||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.postgresql.ds.PGSimpleDataSource;
|
import org.postgresql.ds.PGSimpleDataSource;
|
||||||
import org.testcontainers.containers.PostgreSQLContainer;
|
import org.testcontainers.containers.PostgreSQLContainer;
|
||||||
@@ -41,14 +42,20 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class PostgreSQL9JdbcOperationsSessionRepositoryITests
|
public class PostgreSql9JdbcOperationsSessionRepositoryITests
|
||||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "postgres:9.6.7";
|
private static PostgreSQLContainer container = new PostgreSql9Container();
|
||||||
|
|
||||||
@ClassRule
|
@BeforeClass
|
||||||
public static PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer(
|
public static void setUpClass() {
|
||||||
DOCKER_IMAGE);
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class Config extends BaseConfig {
|
static class Config extends BaseConfig {
|
||||||
@@ -56,9 +63,9 @@ public class PostgreSQL9JdbcOperationsSessionRepositoryITests
|
|||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
PGSimpleDataSource dataSource = new PGSimpleDataSource();
|
PGSimpleDataSource dataSource = new PGSimpleDataSource();
|
||||||
dataSource.setUrl(postgreSQLContainer.getJdbcUrl());
|
dataSource.setUrl(container.getJdbcUrl());
|
||||||
dataSource.setUser(postgreSQLContainer.getUsername());
|
dataSource.setUser(container.getUsername());
|
||||||
dataSource.setPassword(postgreSQLContainer.getPassword());
|
dataSource.setPassword(container.getPassword());
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,4 +82,12 @@ public class PostgreSQL9JdbcOperationsSessionRepositoryITests
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class PostgreSql9Container extends PostgreSQLContainer {
|
||||||
|
|
||||||
|
PostgreSql9Container() {
|
||||||
|
super("postgres:9.6.8");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,8 @@ package org.springframework.session.jdbc;
|
|||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
|
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
|
||||||
import org.junit.ClassRule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.testcontainers.containers.MSSQLServerContainer;
|
import org.testcontainers.containers.MSSQLServerContainer;
|
||||||
@@ -43,13 +44,20 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class SQLServerJdbcOperationsSessionRepositoryITests
|
public class SqlServerJdbcOperationsSessionRepositoryITests
|
||||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||||
|
|
||||||
private static final String DOCKER_IMAGE = "microsoft/mssql-server-linux:2017-CU3";
|
private static MSSQLServerContainer container = new SqlServer2007Container();
|
||||||
|
|
||||||
@ClassRule
|
@BeforeClass
|
||||||
public static MSSQLServerContainer container = new MSSQLServerContainer(DOCKER_IMAGE);
|
public static void setUpClass() {
|
||||||
|
container.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class Config extends BaseConfig {
|
static class Config extends BaseConfig {
|
||||||
@@ -76,4 +84,12 @@ public class SQLServerJdbcOperationsSessionRepositoryITests
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SqlServer2007Container extends MSSQLServerContainer {
|
||||||
|
|
||||||
|
SqlServer2007Container() {
|
||||||
|
super("microsoft/mssql-server-linux:2017-CU6");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ CREATE TABLE SPRING_SESSION (
|
|||||||
EXPIRY_TIME BIGINT NOT NULL,
|
EXPIRY_TIME BIGINT NOT NULL,
|
||||||
PRINCIPAL_NAME VARCHAR(100),
|
PRINCIPAL_NAME VARCHAR(100),
|
||||||
CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID)
|
CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
|
||||||
|
|
||||||
CREATE UNIQUE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (SESSION_ID);
|
CREATE UNIQUE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (SESSION_ID);
|
||||||
CREATE INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME);
|
CREATE INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME);
|
||||||
@@ -19,6 +19,6 @@ CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
|||||||
ATTRIBUTE_BYTES BLOB NOT NULL,
|
ATTRIBUTE_BYTES BLOB NOT NULL,
|
||||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME),
|
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME),
|
||||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID) REFERENCES SPRING_SESSION(PRIMARY_ID) ON DELETE CASCADE
|
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID) REFERENCES SPRING_SESSION(PRIMARY_ID) ON DELETE CASCADE
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
|
||||||
|
|
||||||
CREATE INDEX SPRING_SESSION_ATTRIBUTES_IX1 ON SPRING_SESSION_ATTRIBUTES (SESSION_PRIMARY_ID);
|
CREATE INDEX SPRING_SESSION_ATTRIBUTES_IX1 ON SPRING_SESSION_ATTRIBUTES (SESSION_PRIMARY_ID);
|
||||||
|
|||||||
Reference in New Issue
Block a user