I want to change my integration tests (use oracle 19c database) by using testcontainers.
So installed docker in local and run the Docker Desktop.
after i used the image gvenzl/oracle-xe:18.4.0-slim and i run it locally.
After in my code (java & spring boot), i have the external database connexion declared in application-integrationTests.properties
app.datasource.url=jdbc:oracle:thin:@//IT-host:1529/DEV_APP
app.datasource.driverClassName=oracle.jdbc.OracleDriver
app.datasource.username=DEMO
app.datasource.password=DEMO
and in my ServerConfigIntegrationTest, i had this code before
public DataSource specificDatasource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(driverClassName);
dataSource.setUrl(url);
dataSource.setUsername(username);
dataSource.setPassword(password);
return dataSource;
}
So, i modified this configuration by
@Testcontainers
public class ServerConfigIntegrationTest{
... code
@Container
private final OracleContainer oracleContainer = new OracleContainer("gvenzl/oracle-xe:18.4.0-slim")
.withReuse(true)
.withPassword("DEMO")
.withUsername("DEMO")
.withDatabaseName("DEV_APP")
.withLogConsumer(new Slf4jLogConsumer(LOGGER));
@Bean
@Primary
public DataSource specificDatasource() {
oracleContainer.start();
LOGGER.info("The JDBC URL of the container is: "+ oracleContainer.getJdbcUrl());
dataSource.setDriverClassName(oracleContainer.getDriverClassName());
dataSource.setUrl(oracleContainer.getJdbcUrl());
dataSource.setUsername(oracleContainer.getUsername());
dataSource.setPassword(oracleContainer.getPassword());
return dataSource;
}
when i'm logging the jdbcUrl, i have localhost as server and the bad port.
How can i do to connect my container to the database (with a specific host "IT-host") ? Can you help me ?