Align SQL Server-related class names with existing precedents

Closes gh-35181
pull/35185/head
Andy Wilkinson 2 years ago
parent 1e785e81f8
commit 5e73047164

@ -26,13 +26,13 @@ import org.springframework.util.StringUtils;
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
class MsSqlServerEnvironment { class SqlServerEnvironment {
private final String username = "SA"; private final String username = "SA";
private final String password; private final String password;
MsSqlServerEnvironment(Map<String, String> env) { SqlServerEnvironment(Map<String, String> env) {
this.password = extractPassword(env); this.password = extractPassword(env);
} }

@ -28,34 +28,34 @@ import org.springframework.boot.docker.compose.service.connection.jdbc.JdbcUrlBu
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
class MsSqlServerJdbcDockerComposeConnectionDetailsFactory class SqlServerJdbcDockerComposeConnectionDetailsFactory
extends DockerComposeConnectionDetailsFactory<JdbcConnectionDetails> { extends DockerComposeConnectionDetailsFactory<JdbcConnectionDetails> {
protected MsSqlServerJdbcDockerComposeConnectionDetailsFactory() { protected SqlServerJdbcDockerComposeConnectionDetailsFactory() {
super("mssql/server"); super("mssql/server");
} }
@Override @Override
protected JdbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) { protected JdbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
return new MsSqlJdbcDockerComposeConnectionDetails(source.getRunningService()); return new SqlServerJdbcDockerComposeConnectionDetails(source.getRunningService());
} }
/** /**
* {@link JdbcConnectionDetails} backed by a {@code mssql/server} * {@link JdbcConnectionDetails} backed by a {@code mssql/server}
* {@link RunningService}. * {@link RunningService}.
*/ */
static class MsSqlJdbcDockerComposeConnectionDetails extends DockerComposeConnectionDetails static class SqlServerJdbcDockerComposeConnectionDetails extends DockerComposeConnectionDetails
implements JdbcConnectionDetails { implements JdbcConnectionDetails {
private static final JdbcUrlBuilder jdbcUrlBuilder = new JdbcUrlBuilder("sqlserver", 1433); private static final JdbcUrlBuilder jdbcUrlBuilder = new JdbcUrlBuilder("sqlserver", 1433);
private final MsSqlServerEnvironment environment; private final SqlServerEnvironment environment;
private final String jdbcUrl; private final String jdbcUrl;
MsSqlJdbcDockerComposeConnectionDetails(RunningService service) { SqlServerJdbcDockerComposeConnectionDetails(RunningService service) {
super(service); super(service);
this.environment = new MsSqlServerEnvironment(service.env()); this.environment = new SqlServerEnvironment(service.env());
this.jdbcUrl = disableEncryptionIfNecessary(jdbcUrlBuilder.build(service, "")); this.jdbcUrl = disableEncryptionIfNecessary(jdbcUrlBuilder.build(service, ""));
} }

@ -32,22 +32,22 @@ import org.springframework.boot.docker.compose.service.connection.r2dbc.Connecti
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Phillip Webb * @author Phillip Webb
*/ */
class MsSqlServerR2dbcDockerComposeConnectionDetailsFactory class SqlServerR2dbcDockerComposeConnectionDetailsFactory
extends DockerComposeConnectionDetailsFactory<R2dbcConnectionDetails> { extends DockerComposeConnectionDetailsFactory<R2dbcConnectionDetails> {
MsSqlServerR2dbcDockerComposeConnectionDetailsFactory() { SqlServerR2dbcDockerComposeConnectionDetailsFactory() {
super("mssql/server", "io.r2dbc.spi.ConnectionFactoryOptions"); super("mssql/server", "io.r2dbc.spi.ConnectionFactoryOptions");
} }
@Override @Override
protected R2dbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) { protected R2dbcConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
return new MsSqlR2dbcDockerComposeConnectionDetails(source.getRunningService()); return new SqlServerR2dbcDockerComposeConnectionDetails(source.getRunningService());
} }
/** /**
* {@link R2dbcConnectionDetails} backed by a {@code mssql} {@link RunningService}. * {@link R2dbcConnectionDetails} backed by a {@code mssql} {@link RunningService}.
*/ */
static class MsSqlR2dbcDockerComposeConnectionDetails extends DockerComposeConnectionDetails static class SqlServerR2dbcDockerComposeConnectionDetails extends DockerComposeConnectionDetails
implements R2dbcConnectionDetails { implements R2dbcConnectionDetails {
private static final ConnectionFactoryOptionsBuilder connectionFactoryOptionsBuilder = new ConnectionFactoryOptionsBuilder( private static final ConnectionFactoryOptionsBuilder connectionFactoryOptionsBuilder = new ConnectionFactoryOptionsBuilder(
@ -55,9 +55,9 @@ class MsSqlServerR2dbcDockerComposeConnectionDetailsFactory
private final ConnectionFactoryOptions connectionFactoryOptions; private final ConnectionFactoryOptions connectionFactoryOptions;
MsSqlR2dbcDockerComposeConnectionDetails(RunningService service) { SqlServerR2dbcDockerComposeConnectionDetails(RunningService service) {
super(service); super(service);
MsSqlServerEnvironment environment = new MsSqlServerEnvironment(service.env()); SqlServerEnvironment environment = new SqlServerEnvironment(service.env());
this.connectionFactoryOptions = connectionFactoryOptionsBuilder.build(service, "", this.connectionFactoryOptions = connectionFactoryOptionsBuilder.build(service, "",
environment.getUsername(), environment.getPassword()); environment.getUsername(), environment.getPassword());
} }

@ -17,6 +17,6 @@ org.springframework.boot.docker.compose.service.connection.postgres.PostgresJdbc
org.springframework.boot.docker.compose.service.connection.postgres.PostgresR2dbcDockerComposeConnectionDetailsFactory,\ org.springframework.boot.docker.compose.service.connection.postgres.PostgresR2dbcDockerComposeConnectionDetailsFactory,\
org.springframework.boot.docker.compose.service.connection.rabbit.RabbitDockerComposeConnectionDetailsFactory,\ org.springframework.boot.docker.compose.service.connection.rabbit.RabbitDockerComposeConnectionDetailsFactory,\
org.springframework.boot.docker.compose.service.connection.redis.RedisDockerComposeConnectionDetailsFactory,\ org.springframework.boot.docker.compose.service.connection.redis.RedisDockerComposeConnectionDetailsFactory,\
org.springframework.boot.docker.compose.service.connection.sqlserver.MsSqlServerJdbcDockerComposeConnectionDetailsFactory,\ org.springframework.boot.docker.compose.service.connection.sqlserver.SqlServerJdbcDockerComposeConnectionDetailsFactory,\
org.springframework.boot.docker.compose.service.connection.sqlserver.MsSqlServerR2dbcDockerComposeConnectionDetailsFactory,\ org.springframework.boot.docker.compose.service.connection.sqlserver.SqlServerR2dbcDockerComposeConnectionDetailsFactory,\
org.springframework.boot.docker.compose.service.connection.zipkin.ZipkinDockerComposeConnectionDetailsFactory org.springframework.boot.docker.compose.service.connection.zipkin.ZipkinDockerComposeConnectionDetailsFactory

@ -25,39 +25,39 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/** /**
* Tests for {@link MsSqlServerEnvironment}. * Tests for {@link SqlServerEnvironment}.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
class MsSqlServerEnvironmentTests { class SqlServerEnvironmentTests {
@Test @Test
void createWhenHasNoPasswordThrowsException() { void createWhenHasNoPasswordThrowsException() {
assertThatIllegalStateException().isThrownBy(() -> new MsSqlServerEnvironment(Collections.emptyMap())) assertThatIllegalStateException().isThrownBy(() -> new SqlServerEnvironment(Collections.emptyMap()))
.withMessage("No MSSQL password found"); .withMessage("No MSSQL password found");
} }
@Test @Test
void getUsernameWhenHasNoMsSqlUser() { void getUsernameWhenHasNoMsSqlUser() {
MsSqlServerEnvironment environment = new MsSqlServerEnvironment(Map.of("MSSQL_SA_PASSWORD", "secret")); SqlServerEnvironment environment = new SqlServerEnvironment(Map.of("MSSQL_SA_PASSWORD", "secret"));
assertThat(environment.getUsername()).isEqualTo("SA"); assertThat(environment.getUsername()).isEqualTo("SA");
} }
@Test @Test
void getPasswordWhenHasMsSqlSaPassword() { void getPasswordWhenHasMsSqlSaPassword() {
MsSqlServerEnvironment environment = new MsSqlServerEnvironment(Map.of("MSSQL_SA_PASSWORD", "secret")); SqlServerEnvironment environment = new SqlServerEnvironment(Map.of("MSSQL_SA_PASSWORD", "secret"));
assertThat(environment.getPassword()).isEqualTo("secret"); assertThat(environment.getPassword()).isEqualTo("secret");
} }
@Test @Test
void getPasswordWhenHasSaPassword() { void getPasswordWhenHasSaPassword() {
MsSqlServerEnvironment environment = new MsSqlServerEnvironment(Map.of("SA_PASSWORD", "secret")); SqlServerEnvironment environment = new SqlServerEnvironment(Map.of("SA_PASSWORD", "secret"));
assertThat(environment.getPassword()).isEqualTo("secret"); assertThat(environment.getPassword()).isEqualTo("secret");
} }
@Test @Test
void getPasswordWhenHasMsSqlSaPasswordAndSaPasswordPrefersMsSqlSaPassword() { void getPasswordWhenHasMsSqlSaPasswordAndSaPasswordPrefersMsSqlSaPassword() {
MsSqlServerEnvironment environment = new MsSqlServerEnvironment( SqlServerEnvironment environment = new SqlServerEnvironment(
Map.of("MSSQL_SA_PASSWORD", "secret", "SA_PASSWORD", "not used")); Map.of("MSSQL_SA_PASSWORD", "secret", "SA_PASSWORD", "not used"));
assertThat(environment.getPassword()).isEqualTo("secret"); assertThat(environment.getPassword()).isEqualTo("secret");
} }

@ -30,14 +30,13 @@ 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 MsSqlServerJdbcDockerComposeConnectionDetailsFactory} * Integration tests for {@link SqlServerJdbcDockerComposeConnectionDetailsFactory}
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
class MsSqlServerJdbcDockerComposeConnectionDetailsFactoryIntegrationTests class SqlServerJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
extends AbstractDockerComposeIntegrationTests {
MsSqlServerJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() { SqlServerJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("mssqlserver-compose.yaml"); super("mssqlserver-compose.yaml");
} }

@ -28,14 +28,14 @@ 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 MsSqlServerR2dbcDockerComposeConnectionDetailsFactory} * Integration tests for {@link SqlServerR2dbcDockerComposeConnectionDetailsFactory}
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
class MsSqlServerR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests class SqlServerR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests
extends AbstractDockerComposeIntegrationTests { extends AbstractDockerComposeIntegrationTests {
MsSqlServerR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() { SqlServerR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("mssqlserver-compose.yaml"); super("mssqlserver-compose.yaml");
} }

@ -33,10 +33,10 @@ import org.springframework.boot.testcontainers.service.connection.ServiceConnect
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Phillip Webb * @author Phillip Webb
*/ */
class MsSqlServerR2dbcContainerConnectionDetailsFactory class SqlServerR2dbcContainerConnectionDetailsFactory
extends ContainerConnectionDetailsFactory<R2dbcConnectionDetails, MSSQLServerContainer<?>> { extends ContainerConnectionDetailsFactory<R2dbcConnectionDetails, MSSQLServerContainer<?>> {
MsSqlServerR2dbcContainerConnectionDetailsFactory() { SqlServerR2dbcContainerConnectionDetailsFactory() {
super(ANY_CONNECTION_NAME, "io.r2dbc.spi.ConnectionFactoryOptions"); super(ANY_CONNECTION_NAME, "io.r2dbc.spi.ConnectionFactoryOptions");
} }

@ -20,7 +20,7 @@ org.springframework.boot.testcontainers.service.connection.liquibase.LiquibaseCo
org.springframework.boot.testcontainers.service.connection.mongo.MongoContainerConnectionDetailsFactory,\ org.springframework.boot.testcontainers.service.connection.mongo.MongoContainerConnectionDetailsFactory,\
org.springframework.boot.testcontainers.service.connection.neo4j.Neo4jContainerConnectionDetailsFactory,\ org.springframework.boot.testcontainers.service.connection.neo4j.Neo4jContainerConnectionDetailsFactory,\
org.springframework.boot.testcontainers.service.connection.r2dbc.MariaDbR2dbcContainerConnectionDetailsFactory,\ org.springframework.boot.testcontainers.service.connection.r2dbc.MariaDbR2dbcContainerConnectionDetailsFactory,\
org.springframework.boot.testcontainers.service.connection.r2dbc.MsSqlServerR2dbcContainerConnectionDetailsFactory,\ org.springframework.boot.testcontainers.service.connection.r2dbc.SqlServerR2dbcContainerConnectionDetailsFactory,\
org.springframework.boot.testcontainers.service.connection.r2dbc.MySqlR2dbcContainerConnectionDetailsFactory,\ org.springframework.boot.testcontainers.service.connection.r2dbc.MySqlR2dbcContainerConnectionDetailsFactory,\
org.springframework.boot.testcontainers.service.connection.r2dbc.OracleR2dbcContainerConnectionDetailsFactory,\ org.springframework.boot.testcontainers.service.connection.r2dbc.OracleR2dbcContainerConnectionDetailsFactory,\
org.springframework.boot.testcontainers.service.connection.r2dbc.PostgresR2dbcContainerConnectionDetailsFactory,\ org.springframework.boot.testcontainers.service.connection.r2dbc.PostgresR2dbcContainerConnectionDetailsFactory,\

Loading…
Cancel
Save