diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleEnvironmentTests.java b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleEnvironmentTests.java index 6e5b7b974a..4b9f37fca7 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleEnvironmentTests.java +++ b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleEnvironmentTests.java @@ -34,7 +34,8 @@ class OracleEnvironmentTests { @Test void getUsernameWhenHasAppUser() { - OracleEnvironment environment = new OracleEnvironment(Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret")); + OracleEnvironment environment = new OracleEnvironment( + Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret")); assertThat(environment.getUsername()).isEqualTo("alice"); } @@ -46,7 +47,8 @@ class OracleEnvironmentTests { @Test void getPasswordWhenHasAppPassword() { - OracleEnvironment environment = new OracleEnvironment(Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret")); + OracleEnvironment environment = new OracleEnvironment( + Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret")); assertThat(environment.getPassword()).isEqualTo("secret"); } diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests.java b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests.java index b5dbe658b7..0d3c71cdc5 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests.java +++ b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests.java @@ -20,7 +20,6 @@ import java.sql.Driver; import java.time.Duration; import org.awaitility.Awaitility; -import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.OS; @@ -42,59 +41,30 @@ import static org.assertj.core.api.Assertions.assertThat; */ @DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64", disabledReason = "The Oracle image has no ARM support") -class OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests { +class OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { - @Nested - class OracleJdbcDockerComposeConnectionDetailsFactoryDefaultSettingsIntegrationTests extends AbstractDockerComposeIntegrationTests { - OracleJdbcDockerComposeConnectionDetailsFactoryDefaultSettingsIntegrationTests() { - super("oracle-compose.yaml", DockerImageNames.oracleXe()); - } - - @Test - @SuppressWarnings("unchecked") - void runCreatesConnectionDetailsThatCanBeUsedToAccessDatabase() throws Exception { - JdbcConnectionDetails connectionDetails = run(JdbcConnectionDetails.class); - assertThat(connectionDetails.getUsername()).isEqualTo("system"); - assertThat(connectionDetails.getPassword()).isEqualTo("secret"); - assertThat(connectionDetails.getJdbcUrl()).startsWith("jdbc:oracle:thin:@").endsWith("/xepdb1"); - SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); - dataSource.setUrl(connectionDetails.getJdbcUrl()); - dataSource.setUsername(connectionDetails.getUsername()); - dataSource.setPassword(connectionDetails.getPassword()); - dataSource.setDriverClass((Class) ClassUtils.forName(connectionDetails.getDriverClassName(), - getClass().getClassLoader())); - Awaitility.await().atMost(Duration.ofMinutes(1)).ignoreExceptions().untilAsserted(() -> { - JdbcTemplate template = new JdbcTemplate(dataSource); - assertThat(template.queryForObject(DatabaseDriver.ORACLE.getValidationQuery(), String.class)) - .isEqualTo("Hello"); - }); - } + OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() { + super("oracle-compose.yaml", DockerImageNames.oracleXe()); } - @Nested - class OracleJdbcDockerComposeConnectionDetailsFactoryNonDefaultSettingsIntegrationTests extends AbstractDockerComposeIntegrationTests { - protected OracleJdbcDockerComposeConnectionDetailsFactoryNonDefaultSettingsIntegrationTests() { - super("oracle-non-default-compose.yaml", DockerImageNames.oracleXe()); - } - - @Test - @SuppressWarnings("unchecked") - void runCreatesConnectionDetailsWithNonDefaultUsernameAndPasswordThatCanBeUsedToAccessDatabase() throws Exception { - JdbcConnectionDetails connectionDetails = run(JdbcConnectionDetails.class); - assertThat(connectionDetails.getUsername()).isEqualTo("app_user"); - assertThat(connectionDetails.getPassword()).isEqualTo("app_user_secret"); - assertThat(connectionDetails.getJdbcUrl()).startsWith("jdbc:oracle:thin:@").endsWith("/xepdb1"); - SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); - dataSource.setUrl(connectionDetails.getJdbcUrl()); - dataSource.setUsername(connectionDetails.getUsername()); - dataSource.setPassword(connectionDetails.getPassword()); - dataSource.setDriverClass((Class) ClassUtils.forName(connectionDetails.getDriverClassName(), - getClass().getClassLoader())); - Awaitility.await().atMost(Duration.ofMinutes(1)).ignoreExceptions().untilAsserted(() -> { - JdbcTemplate template = new JdbcTemplate(dataSource); - assertThat(template.queryForObject(DatabaseDriver.ORACLE.getValidationQuery(), String.class)) - .isEqualTo("Hello"); - }); - } + @Test + @SuppressWarnings("unchecked") + void runCreatesConnectionDetailsThatCanBeUsedToAccessDatabase() throws Exception { + JdbcConnectionDetails connectionDetails = run(JdbcConnectionDetails.class); + assertThat(connectionDetails.getUsername()).isEqualTo("app_user"); + assertThat(connectionDetails.getPassword()).isEqualTo("app_user_secret"); + assertThat(connectionDetails.getJdbcUrl()).startsWith("jdbc:oracle:thin:@").endsWith("/xepdb1"); + SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); + dataSource.setUrl(connectionDetails.getJdbcUrl()); + dataSource.setUsername(connectionDetails.getUsername()); + dataSource.setPassword(connectionDetails.getPassword()); + dataSource.setDriverClass((Class) ClassUtils.forName(connectionDetails.getDriverClassName(), + getClass().getClassLoader())); + Awaitility.await().atMost(Duration.ofMinutes(1)).ignoreExceptions().untilAsserted(() -> { + JdbcTemplate template = new JdbcTemplate(dataSource); + assertThat(template.queryForObject(DatabaseDriver.ORACLE.getValidationQuery(), String.class)) + .isEqualTo("Hello"); + }); } + } diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/oracle/oracle-compose.yaml b/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/oracle/oracle-compose.yaml index fd467f44d4..1cfa3ca87a 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/oracle/oracle-compose.yaml +++ b/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/oracle/oracle-compose.yaml @@ -4,6 +4,8 @@ services: ports: - '1521' environment: + - 'APP_USER=app_user' + - 'APP_USER_PASSWORD=app_user_secret' - 'ORACLE_PASSWORD=secret' healthcheck: test: ["CMD-SHELL", "healthcheck.sh"] diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/oracle/oracle-non-default-compose.yaml b/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/oracle/oracle-non-default-compose.yaml deleted file mode 100644 index 1cfa3ca87a..0000000000 --- a/spring-boot-project/spring-boot-docker-compose/src/test/resources/org/springframework/boot/docker/compose/service/connection/oracle/oracle-non-default-compose.yaml +++ /dev/null @@ -1,15 +0,0 @@ -services: - database: - image: '{imageName}' - ports: - - '1521' - environment: - - 'APP_USER=app_user' - - 'APP_USER_PASSWORD=app_user_secret' - - 'ORACLE_PASSWORD=secret' - healthcheck: - test: ["CMD-SHELL", "healthcheck.sh"] - interval: 10s - timeout: 5s - retries: 10 -