DATAJDBC-256 - First step toward running integration tests with Oracle.
Original pull request: #223, #232.
This commit is contained in:
18
pom.xml
18
pom.xml
@@ -190,6 +190,24 @@
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>oracle-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>orcacle</spring.profiles.active>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--<execution>-->
|
||||
<!--<id>mssql-test</id>-->
|
||||
<!--<phase>test</phase>-->
|
||||
|
||||
@@ -200,6 +200,14 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.jdbc</groupId>
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
<version>19.6.0.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>de.schauderhaft.degraph</groupId>
|
||||
<artifactId>degraph-check</artifactId>
|
||||
@@ -243,6 +251,13 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>oracle-xe</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -22,12 +22,10 @@ import javax.annotation.PostConstruct;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.mariadb.jdbc.MariaDbDataSource;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.jdbc.datasource.init.ScriptUtils;
|
||||
|
||||
import org.testcontainers.containers.MariaDBContainer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.jdbc.datasource.init.ScriptUtils;
|
||||
|
||||
import org.testcontainers.containers.MySQLContainer;
|
||||
|
||||
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
|
||||
@@ -42,7 +41,6 @@ import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
|
||||
@Configuration
|
||||
@Profile("mysql")
|
||||
class MySqlDataSourceConfiguration extends DataSourceConfiguration {
|
||||
|
||||
private static MySQLContainer<?> MYSQL_CONTAINER;
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2017-2020 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
|
||||
*
|
||||
* https://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 javax.sql.DataSource;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.testcontainers.containers.OracleContainer;
|
||||
|
||||
/**
|
||||
* {@link DataSource} setup for Oracle Database XE. Starts a docker container with a Oracle database.
|
||||
*
|
||||
* @see <a href=
|
||||
* "https://blogs.oracle.com/oraclemagazine/deliver-oracle-database-18c-express-edition-in-containers">Oracle
|
||||
* Docker Image</a>
|
||||
* @see <a href="https://www.testcontainers.org/modules/databases/oraclexe/">Testcontainers Oracle</a>
|
||||
* @author Thomas Lang
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@Configuration
|
||||
@Profile("oracle")
|
||||
public class OracleDataSourceConfiguration extends DataSourceConfiguration {
|
||||
|
||||
private static OracleContainer ORACLE_CONTAINER;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.jdbc.testing.DataSourceConfiguration#createDataSource()
|
||||
*/
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
if (ORACLE_CONTAINER == null) {
|
||||
|
||||
OracleContainer container = new OracleContainer("name_of_your_oracle_xe_image");
|
||||
container.start();
|
||||
|
||||
ORACLE_CONTAINER = container;
|
||||
}
|
||||
|
||||
return new DriverManagerDataSource(ORACLE_CONTAINER.getJdbcUrl(), ORACLE_CONTAINER.getUsername(),
|
||||
ORACLE_CONTAINER.getPassword());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user