Skip to content

Commit

Permalink
Add Microsoft SQL Server integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vpavic committed Jan 2, 2018
1 parent c4daeff commit 3252b38
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gradle/dependency-management.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ dependencyManagement {

dependencySet(group: 'org.testcontainers', version: '1.4.3') {
entry 'mariadb'
entry 'mssqlserver'
}

dependency 'com.h2database:h2:1.4.196'
dependency 'com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8'
dependency 'edu.umd.cs.mtc:multithreadedtc:1.01'
dependency 'io.lettuce:lettuce-core:5.0.1.RELEASE'
dependency 'javax.servlet:javax.servlet-api:3.1.0'
Expand Down
2 changes: 2 additions & 0 deletions spring-session-jdbc/spring-session-jdbc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ dependencies {
testCompile "org.springframework.security:spring-security-core"

integrationTestCompile "com.h2database:h2"
integrationTestCompile "com.microsoft.sqlserver:mssql-jdbc"
integrationTestCompile "mysql:mysql-connector-java"
integrationTestCompile "org.apache.derby:derby"
integrationTestCompile "org.hsqldb:hsqldb"
integrationTestCompile "org.mariadb.jdbc:mariadb-java-client"
integrationTestCompile "org.postgresql:postgresql"
integrationTestCompile "org.testcontainers:mariadb"
integrationTestCompile "org.testcontainers:mssqlserver"
integrationTestCompile "org.testcontainers:mysql"
integrationTestCompile "org.testcontainers:postgresql"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.microsoft.sqlserver.jdbc.SQLServerDataSource;
import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.testcontainers.containers.MSSQLServerContainer;

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 Microsoft SQL
* Server 2017 database.
*
* @author Vedran Pavic
*/
@RunWith(SpringRunner.class)
@WebAppConfiguration
@ContextConfiguration
public class SQLServerJdbcOperationsSessionRepositoryITests
extends AbstractJdbcOperationsSessionRepositoryITests {

private static final String DOCKER_IMAGE = "microsoft/mssql-server-linux:2017-CU2";

@ClassRule
public static MSSQLServerContainer container = new MSSQLServerContainer(DOCKER_IMAGE);

@Configuration
static class Config extends BaseConfig {

@Bean
public DataSource dataSource() {
SQLServerDataSource dataSource = new SQLServerDataSource();
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-sqlserver.sql")));
return initializer;
}

}

}

0 comments on commit 3252b38

Please sign in to comment.