Skip to content

Commit

Permalink
test: fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Mar 21, 2024
1 parent b2e8a7b commit a030fdb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package ca.bc.gov.api.oracle.legacy;

import com.github.dockerjava.api.DockerClient;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.UUID;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.OracleContainer;
import org.testcontainers.containers.startupcheck.StartupCheckStrategy;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
Expand All @@ -16,13 +22,19 @@
@ContextConfiguration
public abstract class AbstractTestContainerIntegrationTest {

static final OracleContainer database;
static final GenericContainer database;

static {
database = new OracleContainer("gvenzl/oracle-xe:18.4.0-slim-faststart")
.withDatabaseName("legacyfsa")
.withUsername("THE")
.withPassword(UUID.randomUUID().toString().substring(24));
database = new GenericContainer("gvenzl/oracle-free:23.3-slim-faststart")
.withEnv("ORACLE_RANDOM_PASSWORD","yes")
.withEnv("APP_USER","THE")
.withEnv("APP_USER_PASSWORD",UUID.randomUUID().toString().substring(24))
.withExposedPorts(1521)
.waitingFor(
new LogMessageWaitStrategy()
.withRegEx(".*DATABASE IS READY TO USE.*")
.withStartupTimeout(Duration.of(15, ChronoUnit.MINUTES))
);
database.start();
}

Expand All @@ -32,12 +44,13 @@ static void registerDynamicProperties(DynamicPropertyRegistry registry) {
registry
.add(
"ca.bc.gov.nrs.oracle.database",
database::getDatabaseName);
() -> "THE");

registry
.add(
"ca.bc.gov.nrs.oracle.service",
database::getDatabaseName);
() -> "FREEPDB1"
);

registry
.add(
Expand All @@ -52,17 +65,17 @@ static void registerDynamicProperties(DynamicPropertyRegistry registry) {
registry
.add(
"ca.bc.gov.nrs.oracle.username",
database::getUsername);
() -> database.getEnvMap().get("APP_USER"));

registry
.add(
"ca.bc.gov.nrs.oracle.schema",
database::getUsername
() -> database.getEnvMap().get("APP_USER")
);

registry
.add(
"ca.bc.gov.nrs.oracle.password",
database::getPassword);
() -> database.getEnvMap().get("APP_USER_PASSWORD"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spring:
banner-mode: "off"
allow-bean-definition-overriding: true
r2dbc:
url: r2dbc:oracle://${ca.bc.gov.nrs.oracle.host}:${ca.bc.gov.nrs.oracle.port}/${ca.bc.gov.nrs.oracle.database}
url: r2dbc:oracle://${ca.bc.gov.nrs.oracle.host}:${ca.bc.gov.nrs.oracle.port}/${ca.bc.gov.nrs.oracle.service}
username: ${ca.bc.gov.nrs.oracle.username}
password: ${ca.bc.gov.nrs.oracle.password}
pool:
Expand Down

0 comments on commit a030fdb

Please sign in to comment.