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:
@@ -20,7 +20,8 @@ import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mariadb.jdbc.MariaDbDataSource;
|
||||
import org.testcontainers.containers.MariaDBContainer;
|
||||
@@ -43,23 +44,29 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration
|
||||
public class MariaDB10JdbcOperationsSessionRepositoryITests
|
||||
public class MariaDb10JdbcOperationsSessionRepositoryITests
|
||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||
|
||||
private static final String DOCKER_IMAGE = "mariadb:10.2.13";
|
||||
private static MariaDBContainer container = new MariaDb10Container();
|
||||
|
||||
@ClassRule
|
||||
public static MariaDBContainer mariaDBContainer = new MariaDBContainer(DOCKER_IMAGE);
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
container.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class Config extends BaseConfig {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() throws SQLException {
|
||||
MariaDbDataSource dataSource = new MariaDbDataSource(
|
||||
mariaDBContainer.getJdbcUrl());
|
||||
dataSource.setUserName(mariaDBContainer.getUsername());
|
||||
dataSource.setPassword(mariaDBContainer.getPassword());
|
||||
MariaDbDataSource dataSource = new MariaDbDataSource(container.getJdbcUrl());
|
||||
dataSource.setUserName(container.getUsername());
|
||||
dataSource.setPassword(container.getPassword());
|
||||
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 org.junit.ClassRule;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mariadb.jdbc.MariaDbDataSource;
|
||||
import org.testcontainers.containers.MariaDBContainer;
|
||||
@@ -43,23 +44,29 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration
|
||||
public class MariaDB5JdbcOperationsSessionRepositoryITests
|
||||
public class MariaDb5JdbcOperationsSessionRepositoryITests
|
||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||
|
||||
private static final String DOCKER_IMAGE = "mariadb:5.5.59";
|
||||
private static MariaDBContainer container = new MariaDb5Container();
|
||||
|
||||
@ClassRule
|
||||
public static MariaDBContainer mariaDBContainer = new MariaDBContainer(DOCKER_IMAGE);
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
container.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class Config extends BaseConfig {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() throws SQLException {
|
||||
MariaDbDataSource dataSource = new MariaDbDataSource(
|
||||
mariaDBContainer.getJdbcUrl());
|
||||
dataSource.setUserName(mariaDBContainer.getUsername());
|
||||
dataSource.setPassword(mariaDBContainer.getPassword());
|
||||
MariaDbDataSource dataSource = new MariaDbDataSource(container.getJdbcUrl());
|
||||
dataSource.setUserName(container.getUsername());
|
||||
dataSource.setPassword(container.getPassword());
|
||||
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 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.testcontainers.containers.MySQLContainer;
|
||||
|
||||
@@ -40,13 +41,20 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration
|
||||
public class MySQL5JdbcOperationsSessionRepositoryITests
|
||||
public class MySql5JdbcOperationsSessionRepositoryITests
|
||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||
|
||||
private static final String DOCKER_IMAGE = "mysql:5.7.21";
|
||||
private static MySQLContainer container = new MySql5Container();
|
||||
|
||||
@ClassRule
|
||||
public static MySQLContainer mySQLContainer = new MySQLContainer(DOCKER_IMAGE);
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
container.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class Config extends BaseConfig {
|
||||
@@ -54,9 +62,9 @@ public class MySQL5JdbcOperationsSessionRepositoryITests
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
MysqlDataSource dataSource = new MysqlDataSource();
|
||||
dataSource.setUrl(mySQLContainer.getJdbcUrl());
|
||||
dataSource.setUser(mySQLContainer.getUsername());
|
||||
dataSource.setPassword(mySQLContainer.getPassword());
|
||||
dataSource.setUrl(container.getJdbcUrl());
|
||||
dataSource.setUser(container.getUsername());
|
||||
dataSource.setPassword(container.getPassword());
|
||||
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 org.junit.ClassRule;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.postgresql.ds.PGSimpleDataSource;
|
||||
import org.testcontainers.containers.PostgreSQLContainer;
|
||||
@@ -41,14 +42,20 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration
|
||||
public class PostgreSQL10JdbcOperationsSessionRepositoryITests
|
||||
public class PostgreSql10JdbcOperationsSessionRepositoryITests
|
||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||
|
||||
private static final String DOCKER_IMAGE = "postgres:10.2";
|
||||
private static PostgreSQLContainer container = new PostgreSql10Container();
|
||||
|
||||
@ClassRule
|
||||
public static PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer(
|
||||
DOCKER_IMAGE);
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
container.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class Config extends BaseConfig {
|
||||
@@ -56,9 +63,9 @@ public class PostgreSQL10JdbcOperationsSessionRepositoryITests
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
PGSimpleDataSource dataSource = new PGSimpleDataSource();
|
||||
dataSource.setUrl(postgreSQLContainer.getJdbcUrl());
|
||||
dataSource.setUser(postgreSQLContainer.getUsername());
|
||||
dataSource.setPassword(postgreSQLContainer.getPassword());
|
||||
dataSource.setUrl(container.getJdbcUrl());
|
||||
dataSource.setUser(container.getUsername());
|
||||
dataSource.setPassword(container.getPassword());
|
||||
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 org.junit.ClassRule;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.postgresql.ds.PGSimpleDataSource;
|
||||
import org.testcontainers.containers.PostgreSQLContainer;
|
||||
@@ -41,14 +42,20 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration
|
||||
public class PostgreSQL9JdbcOperationsSessionRepositoryITests
|
||||
public class PostgreSql9JdbcOperationsSessionRepositoryITests
|
||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||
|
||||
private static final String DOCKER_IMAGE = "postgres:9.6.7";
|
||||
private static PostgreSQLContainer container = new PostgreSql9Container();
|
||||
|
||||
@ClassRule
|
||||
public static PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer(
|
||||
DOCKER_IMAGE);
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
container.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class Config extends BaseConfig {
|
||||
@@ -56,9 +63,9 @@ public class PostgreSQL9JdbcOperationsSessionRepositoryITests
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
PGSimpleDataSource dataSource = new PGSimpleDataSource();
|
||||
dataSource.setUrl(postgreSQLContainer.getJdbcUrl());
|
||||
dataSource.setUser(postgreSQLContainer.getUsername());
|
||||
dataSource.setPassword(postgreSQLContainer.getPassword());
|
||||
dataSource.setUrl(container.getJdbcUrl());
|
||||
dataSource.setUser(container.getUsername());
|
||||
dataSource.setPassword(container.getPassword());
|
||||
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 com.microsoft.sqlserver.jdbc.SQLServerDataSource;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.testcontainers.containers.MSSQLServerContainer;
|
||||
@@ -43,13 +44,20 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration
|
||||
public class SQLServerJdbcOperationsSessionRepositoryITests
|
||||
public class SqlServerJdbcOperationsSessionRepositoryITests
|
||||
extends AbstractJdbcOperationsSessionRepositoryITests {
|
||||
|
||||
private static final String DOCKER_IMAGE = "microsoft/mssql-server-linux:2017-CU3";
|
||||
private static MSSQLServerContainer container = new SqlServer2007Container();
|
||||
|
||||
@ClassRule
|
||||
public static MSSQLServerContainer container = new MSSQLServerContainer(DOCKER_IMAGE);
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
container.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
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,
|
||||
PRINCIPAL_NAME VARCHAR(100),
|
||||
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 INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME);
|
||||
@@ -19,6 +19,6 @@ CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
ATTRIBUTE_BYTES BLOB NOT NULL,
|
||||
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
|
||||
) ENGINE=InnoDB;
|
||||
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
|
||||
|
||||
CREATE INDEX SPRING_SESSION_ATTRIBUTES_IX1 ON SPRING_SESSION_ATTRIBUTES (SESSION_PRIMARY_ID);
|
||||
|
||||
Reference in New Issue
Block a user