DATAJDBC-196 - Integration-test-support for MariaDB.
Original pull request: #57.
This commit is contained in:
@@ -353,6 +353,7 @@ Currently the following _databasetypes_ are available:
|
||||
* hsql (default, does not require a running database)
|
||||
* mysql
|
||||
* postgres
|
||||
* mariadb
|
||||
|
||||
=== Run tests with all databases
|
||||
|
||||
@@ -361,7 +362,7 @@ Currently the following _databasetypes_ are available:
|
||||
mvn test -Pall-dbs
|
||||
----
|
||||
|
||||
This will execute the unit tests, and all the integration tests with all the databases we currently support for testing. The databases must be running.
|
||||
This will execute the unit tests, and all the integration tests with all the databases we currently support for testing. Running the integration-tests depends on Docker.
|
||||
|
||||
== Contributing to Spring Data JDBC
|
||||
|
||||
|
||||
33
pom.xml
33
pom.xml
@@ -32,6 +32,7 @@
|
||||
<mybatis-spring.version>1.3.2</mybatis-spring.version>
|
||||
<mysql-connector-java.version>5.1.41</mysql-connector-java.version>
|
||||
<postgresql.version>42.0.0</postgresql.version>
|
||||
<mariadb-java-client.version>2.2.3</mariadb-java-client.version>
|
||||
<testcontainers.version>1.6.0</testcontainers.version>
|
||||
|
||||
</properties>
|
||||
@@ -121,6 +122,24 @@
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>mariadb-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>mariadb</spring.profiles.active>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
@@ -209,6 +228,13 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<version>${mariadb-java-client.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.schauderhaft.degraph</groupId>
|
||||
<artifactId>degraph-check</artifactId>
|
||||
@@ -230,6 +256,13 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>mariadb</artifactId>
|
||||
<version>${testcontainers.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2017-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.data.jdbc.testing;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.script.ScriptException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.mariadb.jdbc.MariaDbDataSource;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.testcontainers.containers.MariaDBContainer;
|
||||
import org.testcontainers.jdbc.ext.ScriptUtils;
|
||||
|
||||
/**
|
||||
* {@link DataSource} setup for MariaDB.
|
||||
*
|
||||
* Starts a Docker-container with a MariaDB database, and sets up database "test".
|
||||
|
||||
* @author Christoph Preißner
|
||||
*/
|
||||
@Configuration
|
||||
@Profile("mariadb")
|
||||
class MariaDBDataSourceConfiguration extends DataSourceConfiguration {
|
||||
|
||||
private static final MariaDBContainer MARIADB_CONTAINER = new MariaDBContainer().withConfigurationOverride("");
|
||||
|
||||
static {
|
||||
MARIADB_CONTAINER.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.jdbc.testing.DataSourceConfiguration#createDataSource()
|
||||
*/
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
try {
|
||||
MariaDbDataSource dataSource = new MariaDbDataSource();
|
||||
dataSource.setUrl(MARIADB_CONTAINER.getJdbcUrl());
|
||||
dataSource.setUser(MARIADB_CONTAINER.getUsername());
|
||||
dataSource.setPassword(MARIADB_CONTAINER.getPassword());
|
||||
return dataSource;
|
||||
} catch(SQLException sqlex) {
|
||||
throw new RuntimeException(sqlex);
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void initDatabase() throws SQLException, ScriptException {
|
||||
ScriptUtils.executeSqlScript(createDataSource().getConnection(), null, "DROP DATABASE test;CREATE DATABASE test;");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE LEGOSET ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(30));
|
||||
CREATE TABLE MANUAL ( id BIGINT AUTO_INCREMENT PRIMARY KEY, LEGOSET BIGINT, CONTENT VARCHAR(2000));
|
||||
|
||||
ALTER TABLE MANUAL ADD FOREIGN KEY (LEGOSET)
|
||||
REFERENCES LEGOSET(id);
|
||||
@@ -0,0 +1 @@
|
||||
CREATE TABLE DummyEntity ( id BIGINT AUTO_INCREMENT PRIMARY KEY)
|
||||
@@ -0,0 +1,2 @@
|
||||
CREATE TABLE ReadOnlyIdEntity (ID BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100));
|
||||
CREATE TABLE PrimitiveIdEntity (ID BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100));
|
||||
@@ -0,0 +1 @@
|
||||
CREATE TABLE dummyentity (idProp BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100));
|
||||
@@ -0,0 +1,2 @@
|
||||
CREATE TABLE dummyentity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100), DELETED CHAR(1), log BIGINT);
|
||||
CREATE TABLE log ( id BIGINT, TEXT VARCHAR(100));
|
||||
@@ -0,0 +1 @@
|
||||
CREATE TABLE ENTITYWITHCOLUMNSREQUIRINGCONVERSIONS ( idTimestamp DATETIME PRIMARY KEY, bool boolean, SOMEENUM VARCHAR(100), bigDecimal DECIMAL(65), bigInteger DECIMAL(20), date DATETIME, localDateTime DATETIME, zonedDateTime VARCHAR(30))
|
||||
@@ -0,0 +1,2 @@
|
||||
CREATE TABLE dummyentity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100));
|
||||
CREATE TABLE element (id BIGINT AUTO_INCREMENT PRIMARY KEY, content VARCHAR(100), dummyentity BIGINT);
|
||||
@@ -0,0 +1,2 @@
|
||||
CREATE TABLE dummyentity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100));
|
||||
CREATE TABLE element (id BIGINT AUTO_INCREMENT PRIMARY KEY, content VARCHAR(100), DummyEntity_key BIGINT,dummyentity BIGINT);
|
||||
@@ -0,0 +1,2 @@
|
||||
CREATE TABLE dummyentity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(100));
|
||||
CREATE TABLE element (id BIGINT AUTO_INCREMENT PRIMARY KEY, content VARCHAR(100), DummyEntity_key VARCHAR(100),dummyentity BIGINT);
|
||||
Reference in New Issue
Block a user