mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Use different default database names for Oracle XE and Oracle Free
Closes gh-38476
This commit is contained in:
parent
2323c7a838
commit
a7571cf667
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2023 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.boot.docker.compose.service.connection.oracle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration of supported Oracle containers.
|
||||||
|
*
|
||||||
|
* @author Andy Wilkinson
|
||||||
|
*/
|
||||||
|
enum OracleContainer {
|
||||||
|
|
||||||
|
FREE("gvenzl/oracle-free", "freepdb1"),
|
||||||
|
|
||||||
|
XE("gvenzl/oracle-xe", "xepdb1");
|
||||||
|
|
||||||
|
private final String imageName;
|
||||||
|
|
||||||
|
private final String defaultDatabase;
|
||||||
|
|
||||||
|
OracleContainer(String imageName, String defaultDatabase) {
|
||||||
|
this.imageName = imageName;
|
||||||
|
this.defaultDatabase = defaultDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getImageName() {
|
||||||
|
return this.imageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getDefaultDatabase() {
|
||||||
|
return this.defaultDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,18 +28,16 @@ import org.springframework.util.StringUtils;
|
|||||||
*/
|
*/
|
||||||
class OracleEnvironment {
|
class OracleEnvironment {
|
||||||
|
|
||||||
static final String[] CONTAINER_NAMES = { "gvenzl/oracle-xe", "gvenzl/oracle-free" };
|
|
||||||
|
|
||||||
private final String username;
|
private final String username;
|
||||||
|
|
||||||
private final String password;
|
private final String password;
|
||||||
|
|
||||||
private final String database;
|
private final String database;
|
||||||
|
|
||||||
OracleEnvironment(Map<String, String> env) {
|
OracleEnvironment(Map<String, String> env, String defaultDatabase) {
|
||||||
this.username = env.getOrDefault("APP_USER", "system");
|
this.username = env.getOrDefault("APP_USER", "system");
|
||||||
this.password = extractPassword(env);
|
this.password = extractPassword(env);
|
||||||
this.database = env.getOrDefault("ORACLE_DATABASE", "xepdb1");
|
this.database = env.getOrDefault("ORACLE_DATABASE", defaultDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String extractPassword(Map<String, String> env) {
|
private String extractPassword(Map<String, String> env) {
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2023 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.boot.docker.compose.service.connection.oracle;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
|
||||||
|
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DockerComposeConnectionDetailsFactory} to create {@link JdbcConnectionDetails}
|
||||||
|
* for an {@link OracleContainer#FREE} service.
|
||||||
|
*
|
||||||
|
* @author Andy Wilkinson
|
||||||
|
*/
|
||||||
|
class OracleFreeJdbcDockerComposeConnectionDetailsFactory extends OracleJdbcDockerComposeConnectionDetailsFactory {
|
||||||
|
|
||||||
|
protected OracleFreeJdbcDockerComposeConnectionDetailsFactory() {
|
||||||
|
super(OracleContainer.FREE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2023 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.boot.docker.compose.service.connection.oracle;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
|
||||||
|
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DockerComposeConnectionDetailsFactory} to create {@link R2dbcConnectionDetails}
|
||||||
|
* for an {@link OracleContainer#FREE} service.
|
||||||
|
*
|
||||||
|
* @author Andy Wilkinson
|
||||||
|
*/
|
||||||
|
class OracleFreeR2dbcDockerComposeConnectionDetailsFactory extends OracleR2dbcDockerComposeConnectionDetailsFactory {
|
||||||
|
|
||||||
|
protected OracleFreeR2dbcDockerComposeConnectionDetailsFactory() {
|
||||||
|
super(OracleContainer.FREE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,27 +23,30 @@ import org.springframework.boot.docker.compose.service.connection.DockerComposeC
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link DockerComposeConnectionDetailsFactory} to create {@link JdbcConnectionDetails}
|
* Base class for a {@link DockerComposeConnectionDetailsFactory} to create
|
||||||
* for an {@code oracle-xe} service.
|
* {@link JdbcConnectionDetails} for an {@code oracle-free} or {@code oracle-xe} service.
|
||||||
*
|
*
|
||||||
* @author Moritz Halbritter
|
* @author Moritz Halbritter
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
*/
|
*/
|
||||||
class OracleJdbcDockerComposeConnectionDetailsFactory
|
abstract class OracleJdbcDockerComposeConnectionDetailsFactory
|
||||||
extends DockerComposeConnectionDetailsFactory<JdbcConnectionDetails> {
|
extends DockerComposeConnectionDetailsFactory<JdbcConnectionDetails> {
|
||||||
|
|
||||||
protected OracleJdbcDockerComposeConnectionDetailsFactory() {
|
private final String defaultDatabase;
|
||||||
super(OracleEnvironment.CONTAINER_NAMES);
|
|
||||||
|
protected OracleJdbcDockerComposeConnectionDetailsFactory(OracleContainer container) {
|
||||||
|
super(container.getImageName());
|
||||||
|
this.defaultDatabase = container.getDefaultDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JdbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
|
protected JdbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
|
||||||
return new OracleJdbcDockerComposeConnectionDetails(source.getRunningService());
|
return new OracleJdbcDockerComposeConnectionDetails(source.getRunningService(), this.defaultDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link JdbcConnectionDetails} backed by an {@code oracle-xe}
|
* {@link JdbcConnectionDetails} backed by an {@code oracle-xe} or {@code oracle-free}
|
||||||
* {@link RunningService}.
|
* {@link RunningService}.
|
||||||
*/
|
*/
|
||||||
static class OracleJdbcDockerComposeConnectionDetails extends DockerComposeConnectionDetails
|
static class OracleJdbcDockerComposeConnectionDetails extends DockerComposeConnectionDetails
|
||||||
@ -55,9 +58,9 @@ class OracleJdbcDockerComposeConnectionDetailsFactory
|
|||||||
|
|
||||||
private final String jdbcUrl;
|
private final String jdbcUrl;
|
||||||
|
|
||||||
OracleJdbcDockerComposeConnectionDetails(RunningService service) {
|
OracleJdbcDockerComposeConnectionDetails(RunningService service, String defaultDatabase) {
|
||||||
super(service);
|
super(service);
|
||||||
this.environment = new OracleEnvironment(service.env());
|
this.environment = new OracleEnvironment(service.env(), defaultDatabase);
|
||||||
this.jdbcUrl = "jdbc:oracle:thin:@" + service.host() + ":" + service.ports().get(1521) + "/"
|
this.jdbcUrl = "jdbc:oracle:thin:@" + service.host() + ":" + service.ports().get(1521) + "/"
|
||||||
+ this.environment.getDatabase() + getParameters(service);
|
+ this.environment.getDatabase() + getParameters(service);
|
||||||
}
|
}
|
||||||
|
@ -25,23 +25,26 @@ import org.springframework.boot.docker.compose.service.connection.DockerComposeC
|
|||||||
import org.springframework.boot.docker.compose.service.connection.r2dbc.ConnectionFactoryOptionsBuilder;
|
import org.springframework.boot.docker.compose.service.connection.r2dbc.ConnectionFactoryOptionsBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link DockerComposeConnectionDetailsFactory} to create {@link R2dbcConnectionDetails}
|
* Base class for a {@link DockerComposeConnectionDetailsFactory} to create
|
||||||
* for an {@code oracle-xe} service.
|
* {@link R2dbcConnectionDetails} for an {@code oracle-free} or {@code oracle-xe} service.
|
||||||
*
|
*
|
||||||
* @author Moritz Halbritter
|
* @author Moritz Halbritter
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
*/
|
*/
|
||||||
class OracleR2dbcDockerComposeConnectionDetailsFactory
|
abstract class OracleR2dbcDockerComposeConnectionDetailsFactory
|
||||||
extends DockerComposeConnectionDetailsFactory<R2dbcConnectionDetails> {
|
extends DockerComposeConnectionDetailsFactory<R2dbcConnectionDetails> {
|
||||||
|
|
||||||
OracleR2dbcDockerComposeConnectionDetailsFactory() {
|
private final String defaultDatabase;
|
||||||
super(OracleEnvironment.CONTAINER_NAMES, "io.r2dbc.spi.ConnectionFactoryOptions");
|
|
||||||
|
OracleR2dbcDockerComposeConnectionDetailsFactory(OracleContainer container) {
|
||||||
|
super(container.getImageName(), "io.r2dbc.spi.ConnectionFactoryOptions");
|
||||||
|
this.defaultDatabase = container.getDefaultDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected R2dbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
|
protected R2dbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
|
||||||
return new OracleDbR2dbcDockerComposeConnectionDetails(source.getRunningService());
|
return new OracleDbR2dbcDockerComposeConnectionDetails(source.getRunningService(), this.defaultDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,9 +59,9 @@ class OracleR2dbcDockerComposeConnectionDetailsFactory
|
|||||||
|
|
||||||
private final ConnectionFactoryOptions connectionFactoryOptions;
|
private final ConnectionFactoryOptions connectionFactoryOptions;
|
||||||
|
|
||||||
OracleDbR2dbcDockerComposeConnectionDetails(RunningService service) {
|
OracleDbR2dbcDockerComposeConnectionDetails(RunningService service, String defaultDatabase) {
|
||||||
super(service);
|
super(service);
|
||||||
OracleEnvironment environment = new OracleEnvironment(service.env());
|
OracleEnvironment environment = new OracleEnvironment(service.env(), defaultDatabase);
|
||||||
this.connectionFactoryOptions = connectionFactoryOptionsBuilder.build(service, environment.getDatabase(),
|
this.connectionFactoryOptions = connectionFactoryOptionsBuilder.build(service, environment.getDatabase(),
|
||||||
environment.getUsername(), environment.getPassword());
|
environment.getUsername(), environment.getPassword());
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2023 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.boot.docker.compose.service.connection.oracle;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
|
||||||
|
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DockerComposeConnectionDetailsFactory} to create {@link JdbcConnectionDetails}
|
||||||
|
* for an {@link OracleContainer#XE} service.
|
||||||
|
*
|
||||||
|
* @author Andy Wilkinson
|
||||||
|
*/
|
||||||
|
class OracleXeJdbcDockerComposeConnectionDetailsFactory extends OracleJdbcDockerComposeConnectionDetailsFactory {
|
||||||
|
|
||||||
|
protected OracleXeJdbcDockerComposeConnectionDetailsFactory() {
|
||||||
|
super(OracleContainer.XE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2023 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.boot.docker.compose.service.connection.oracle;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
|
||||||
|
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DockerComposeConnectionDetailsFactory} to create {@link R2dbcConnectionDetails}
|
||||||
|
* for an {@link OracleContainer#XE} service.
|
||||||
|
*
|
||||||
|
* @author Andy Wilkinson
|
||||||
|
*/
|
||||||
|
class OracleXeR2dbcDockerComposeConnectionDetailsFactory extends OracleR2dbcDockerComposeConnectionDetailsFactory {
|
||||||
|
|
||||||
|
protected OracleXeR2dbcDockerComposeConnectionDetailsFactory() {
|
||||||
|
super(OracleContainer.XE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -16,8 +16,10 @@ org.springframework.boot.docker.compose.service.connection.mongo.MongoDockerComp
|
|||||||
org.springframework.boot.docker.compose.service.connection.mysql.MySqlJdbcDockerComposeConnectionDetailsFactory,\
|
org.springframework.boot.docker.compose.service.connection.mysql.MySqlJdbcDockerComposeConnectionDetailsFactory,\
|
||||||
org.springframework.boot.docker.compose.service.connection.mysql.MySqlR2dbcDockerComposeConnectionDetailsFactory,\
|
org.springframework.boot.docker.compose.service.connection.mysql.MySqlR2dbcDockerComposeConnectionDetailsFactory,\
|
||||||
org.springframework.boot.docker.compose.service.connection.neo4j.Neo4jDockerComposeConnectionDetailsFactory,\
|
org.springframework.boot.docker.compose.service.connection.neo4j.Neo4jDockerComposeConnectionDetailsFactory,\
|
||||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleJdbcDockerComposeConnectionDetailsFactory,\
|
org.springframework.boot.docker.compose.service.connection.oracle.OracleFreeJdbcDockerComposeConnectionDetailsFactory,\
|
||||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleR2dbcDockerComposeConnectionDetailsFactory,\
|
org.springframework.boot.docker.compose.service.connection.oracle.OracleXeJdbcDockerComposeConnectionDetailsFactory,\
|
||||||
|
org.springframework.boot.docker.compose.service.connection.oracle.OracleFreeR2dbcDockerComposeConnectionDetailsFactory,\
|
||||||
|
org.springframework.boot.docker.compose.service.connection.oracle.OracleXeR2dbcDockerComposeConnectionDetailsFactory,\
|
||||||
org.springframework.boot.docker.compose.service.connection.otlp.OpenTelemetryMetricsDockerComposeConnectionDetailsFactory,\
|
org.springframework.boot.docker.compose.service.connection.otlp.OpenTelemetryMetricsDockerComposeConnectionDetailsFactory,\
|
||||||
org.springframework.boot.docker.compose.service.connection.otlp.OpenTelemetryTracingDockerComposeConnectionDetailsFactory,\
|
org.springframework.boot.docker.compose.service.connection.otlp.OpenTelemetryTracingDockerComposeConnectionDetailsFactory,\
|
||||||
org.springframework.boot.docker.compose.service.connection.postgres.PostgresJdbcDockerComposeConnectionDetailsFactory,\
|
org.springframework.boot.docker.compose.service.connection.postgres.PostgresJdbcDockerComposeConnectionDetailsFactory,\
|
||||||
|
@ -35,77 +35,80 @@ class OracleEnvironmentTests {
|
|||||||
@Test
|
@Test
|
||||||
void getUsernameWhenHasAppUser() {
|
void getUsernameWhenHasAppUser() {
|
||||||
OracleEnvironment environment = new OracleEnvironment(
|
OracleEnvironment environment = new OracleEnvironment(
|
||||||
Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret"));
|
Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret"), "defaultDb");
|
||||||
assertThat(environment.getUsername()).isEqualTo("alice");
|
assertThat(environment.getUsername()).isEqualTo("alice");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getUsernameWhenHasNoAppUser() {
|
void getUsernameWhenHasNoAppUser() {
|
||||||
OracleEnvironment environment = new OracleEnvironment(Map.of("ORACLE_PASSWORD", "secret"));
|
OracleEnvironment environment = new OracleEnvironment(Map.of("ORACLE_PASSWORD", "secret"), "defaultDb");
|
||||||
assertThat(environment.getUsername()).isEqualTo("system");
|
assertThat(environment.getUsername()).isEqualTo("system");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getPasswordWhenHasAppPassword() {
|
void getPasswordWhenHasAppPassword() {
|
||||||
OracleEnvironment environment = new OracleEnvironment(
|
OracleEnvironment environment = new OracleEnvironment(
|
||||||
Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret"));
|
Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret"), "defaultDb");
|
||||||
assertThat(environment.getPassword()).isEqualTo("secret");
|
assertThat(environment.getPassword()).isEqualTo("secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getPasswordWhenHasOraclePassword() {
|
void getPasswordWhenHasOraclePassword() {
|
||||||
OracleEnvironment environment = new OracleEnvironment(Map.of("ORACLE_PASSWORD", "secret"));
|
OracleEnvironment environment = new OracleEnvironment(Map.of("ORACLE_PASSWORD", "secret"), "defaultDb");
|
||||||
assertThat(environment.getPassword()).isEqualTo("secret");
|
assertThat(environment.getPassword()).isEqualTo("secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createWhenRandomPasswordAndAppPasswordDoesNotThrow() {
|
void createWhenRandomPasswordAndAppPasswordDoesNotThrow() {
|
||||||
assertThatNoException().isThrownBy(() -> new OracleEnvironment(
|
assertThatNoException().isThrownBy(() -> new OracleEnvironment(
|
||||||
Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret", "ORACLE_RANDOM_PASSWORD", "true")));
|
Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "secret", "ORACLE_RANDOM_PASSWORD", "true"),
|
||||||
|
"defaultDb"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createWhenRandomPasswordThrowsException() {
|
void createWhenRandomPasswordThrowsException() {
|
||||||
assertThatIllegalStateException()
|
assertThatIllegalStateException()
|
||||||
.isThrownBy(() -> new OracleEnvironment(Map.of("ORACLE_RANDOM_PASSWORD", "true")))
|
.isThrownBy(() -> new OracleEnvironment(Map.of("ORACLE_RANDOM_PASSWORD", "true"), "defaultDb"))
|
||||||
.withMessage("ORACLE_RANDOM_PASSWORD is not supported without APP_USER and APP_USER_PASSWORD");
|
.withMessage("ORACLE_RANDOM_PASSWORD is not supported without APP_USER and APP_USER_PASSWORD");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createWhenAppUserAndNoAppPasswordThrowsException() {
|
void createWhenAppUserAndNoAppPasswordThrowsException() {
|
||||||
assertThatIllegalStateException().isThrownBy(() -> new OracleEnvironment(Map.of("APP_USER", "alice")))
|
assertThatIllegalStateException()
|
||||||
|
.isThrownBy(() -> new OracleEnvironment(Map.of("APP_USER", "alice"), "defaultDb"))
|
||||||
.withMessage("No Oracle app password found");
|
.withMessage("No Oracle app password found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createWhenAppUserAndEmptyAppPasswordThrowsException() {
|
void createWhenAppUserAndEmptyAppPasswordThrowsException() {
|
||||||
assertThatIllegalStateException()
|
assertThatIllegalStateException()
|
||||||
.isThrownBy(() -> new OracleEnvironment(Map.of("APP_USER", "alice", "APP_USER_PASSWORD", "")))
|
.isThrownBy(() -> new OracleEnvironment(Map.of("APP_USER", "alice", "APP_USER_PASSWORD", ""), "defaultDb"))
|
||||||
.withMessage("No Oracle app password found");
|
.withMessage("No Oracle app password found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createWhenHasNoPasswordThrowsException() {
|
void createWhenHasNoPasswordThrowsException() {
|
||||||
assertThatIllegalStateException().isThrownBy(() -> new OracleEnvironment(Collections.emptyMap()))
|
assertThatIllegalStateException().isThrownBy(() -> new OracleEnvironment(Collections.emptyMap(), "defaultDb"))
|
||||||
.withMessage("No Oracle password found");
|
.withMessage("No Oracle password found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createWhenHasEmptyPasswordThrowsException() {
|
void createWhenHasEmptyPasswordThrowsException() {
|
||||||
assertThatIllegalStateException().isThrownBy(() -> new OracleEnvironment(Map.of("ORACLE_PASSWORD", "")))
|
assertThatIllegalStateException()
|
||||||
|
.isThrownBy(() -> new OracleEnvironment(Map.of("ORACLE_PASSWORD", ""), "defaultDb"))
|
||||||
.withMessage("No Oracle password found");
|
.withMessage("No Oracle password found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getDatabaseWhenHasNoOracleDatabase() {
|
void getDatabaseWhenHasNoOracleDatabase() {
|
||||||
OracleEnvironment environment = new OracleEnvironment(Map.of("ORACLE_PASSWORD", "secret"));
|
OracleEnvironment environment = new OracleEnvironment(Map.of("ORACLE_PASSWORD", "secret"), "defaultDb");
|
||||||
assertThat(environment.getDatabase()).isEqualTo("xepdb1");
|
assertThat(environment.getDatabase()).isEqualTo("defaultDb");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getDatabaseWhenHasOracleDatabase() {
|
void getDatabaseWhenHasOracleDatabase() {
|
||||||
OracleEnvironment environment = new OracleEnvironment(
|
OracleEnvironment environment = new OracleEnvironment(
|
||||||
Map.of("ORACLE_PASSWORD", "secret", "ORACLE_DATABASE", "db"));
|
Map.of("ORACLE_PASSWORD", "secret", "ORACLE_DATABASE", "db"), "defaultDb");
|
||||||
assertThat(environment.getDatabase()).isEqualTo("db");
|
assertThat(environment.getDatabase()).isEqualTo("db");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ import org.springframework.util.ClassUtils;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for {@link OracleJdbcDockerComposeConnectionDetailsFactory}
|
* Integration tests for {@link OracleFreeJdbcDockerComposeConnectionDetailsFactory}
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
@ -54,7 +54,7 @@ class OracleFreeJdbcDockerComposeConnectionDetailsFactoryIntegrationTests
|
|||||||
JdbcConnectionDetails connectionDetails = run(JdbcConnectionDetails.class);
|
JdbcConnectionDetails connectionDetails = run(JdbcConnectionDetails.class);
|
||||||
assertThat(connectionDetails.getUsername()).isEqualTo("app_user");
|
assertThat(connectionDetails.getUsername()).isEqualTo("app_user");
|
||||||
assertThat(connectionDetails.getPassword()).isEqualTo("app_user_secret");
|
assertThat(connectionDetails.getPassword()).isEqualTo("app_user_secret");
|
||||||
assertThat(connectionDetails.getJdbcUrl()).startsWith("jdbc:oracle:thin:@").endsWith("/xepdb1");
|
assertThat(connectionDetails.getJdbcUrl()).startsWith("jdbc:oracle:thin:@").endsWith("/freepdb1");
|
||||||
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
|
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
|
||||||
dataSource.setUrl(connectionDetails.getJdbcUrl());
|
dataSource.setUrl(connectionDetails.getJdbcUrl());
|
||||||
dataSource.setUsername(connectionDetails.getUsername());
|
dataSource.setUsername(connectionDetails.getUsername());
|
||||||
|
@ -34,7 +34,7 @@ import org.springframework.r2dbc.core.DatabaseClient;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for {@link OracleR2dbcDockerComposeConnectionDetailsFactory}
|
* Integration tests for {@link OracleFreeR2dbcDockerComposeConnectionDetailsFactory}
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
@ -51,7 +51,7 @@ class OracleFreeR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests
|
|||||||
void runCreatesConnectionDetailsThatCanBeUsedToAccessDatabase() {
|
void runCreatesConnectionDetailsThatCanBeUsedToAccessDatabase() {
|
||||||
R2dbcConnectionDetails connectionDetails = run(R2dbcConnectionDetails.class);
|
R2dbcConnectionDetails connectionDetails = run(R2dbcConnectionDetails.class);
|
||||||
ConnectionFactoryOptions connectionFactoryOptions = connectionDetails.getConnectionFactoryOptions();
|
ConnectionFactoryOptions connectionFactoryOptions = connectionDetails.getConnectionFactoryOptions();
|
||||||
assertThat(connectionFactoryOptions.toString()).contains("database=xepdb1", "driver=oracle",
|
assertThat(connectionFactoryOptions.toString()).contains("database=freepdb1", "driver=oracle",
|
||||||
"password=REDACTED", "user=app_user");
|
"password=REDACTED", "user=app_user");
|
||||||
assertThat(connectionFactoryOptions.getRequiredValue(ConnectionFactoryOptions.PASSWORD))
|
assertThat(connectionFactoryOptions.getRequiredValue(ConnectionFactoryOptions.PASSWORD))
|
||||||
.isEqualTo("app_user_secret");
|
.isEqualTo("app_user_secret");
|
||||||
|
@ -35,7 +35,7 @@ import org.springframework.util.ClassUtils;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for {@link OracleJdbcDockerComposeConnectionDetailsFactory}
|
* Integration tests for {@link OracleXeJdbcDockerComposeConnectionDetailsFactory}
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
|
@ -34,7 +34,7 @@ import org.springframework.r2dbc.core.DatabaseClient;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for {@link OracleR2dbcDockerComposeConnectionDetailsFactory}
|
* Integration tests for {@link OracleXeR2dbcDockerComposeConnectionDetailsFactory}
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user