From b3ce2c1756bd126612d625c2f80f79a464c51386 Mon Sep 17 00:00:00 2001 From: liubao68 Date: Thu, 20 Mar 2025 10:19:16 +0800 Subject: [PATCH] refactor some core class part2 --- .../io/r2dbc/gaussdb/ConnectionResources.java | 6 +- .../gaussdb/ConnectionStrategyFactory.java | 6 +- ...PostgresqlBatch.java => GaussDBBatch.java} | 8 +- ...tadata.java => GaussDBColumnMetadata.java} | 14 +- .../io/r2dbc/gaussdb/GaussDBConnection.java | 6 +- ...va => GaussDBConnectionConfiguration.java} | 41 ++--- .../gaussdb/GaussDBConnectionFactory.java | 12 +- ... => GaussDBConnectionFactoryMetadata.java} | 12 +- ... => GaussDBConnectionFactoryProvider.java} | 35 ++-- .../gaussdb/MultiHostConnectionStrategy.java | 6 +- .../r2dbc/gaussdb/PostgresqlRowMetadata.java | 30 ++-- .../gaussdb/SingleHostConnectionFunction.java | 6 +- ...PostgresqlBatch.java => GaussDBBatch.java} | 6 +- ...tadata.java => GaussDBColumnMetadata.java} | 4 +- .../r2dbc/gaussdb/api/GaussDBConnection.java | 2 +- .../gaussdb/client/ConnectionSettings.java | 6 +- .../client/MultiHostConfiguration.java | 2 +- .../client/SingleHostConfiguration.java | 4 +- .../gaussdb/extension/CodecRegistrar.java | 3 +- .../io/r2dbc/gaussdb/extension/Extension.java | 8 +- .../io.r2dbc.spi.ConnectionFactoryProvider | 2 +- .../AbstractCodecIntegrationTests.java | 2 +- .../gaussdb/AbstractIntegrationTests.java | 12 +- ...AbstractTemporalCodecIntegrationTests.java | 2 +- .../CodecBinaryFormatIntegrationTests.java | 2 +- .../gaussdb/FetchSizeIntegrationTests.java | 2 +- ...tTests.java => GaussDBBatchUnitTests.java} | 16 +- ...va => GaussDBColumnMetadataUnitTests.java} | 6 +- ...ssDBConnectionConfigurationUnitTests.java} | 58 +++---- ...DBConnectionFactoryMetadataUnitTests.java} | 6 +- ...DBConnectionFactoryProviderUnitTests.java} | 163 ++++++++---------- .../java/io/r2dbc/gaussdb/MockContext.java | 2 +- .../gaussdb/PgBouncerIntegrationTests.java | 6 +- ...AuthenticationFailureIntegrationTests.java | 8 +- .../PostgresqlConnectionFactoryUnitTests.java | 10 +- ...nectionRuntimeOptionsIntegrationTests.java | 6 +- .../PostgresqlConnectionUnitTests.java | 4 +- .../PostgresqlCopyInIntegrationTests.java | 2 +- .../PostgresqlRowMetadataUnitTests.java | 26 +-- .../r2dbc/gaussdb/PostgresqlRowUnitTests.java | 2 +- .../PostgresqlStatementIntegrationTests.java | 2 +- .../io/r2dbc/gaussdb/PostgresqlTestKit.java | 8 +- .../TemporalCodecBinaryIntegrationTests.java | 2 +- .../r2dbc/gaussdb/VectorIntegrationTests.java | 2 +- .../gaussdb/api/MockGaussDBConnection.java | 2 +- .../client/DowntimeIntegrationTests.java | 4 +- ...ghAvailabilityClusterIntegrationTests.java | 8 +- .../ReactorNettyClientIntegrationTests.java | 20 +-- .../codec/EnumCodecIntegrationTests.java | 8 +- .../LogicalDecodeIntegrationTests.java | 8 +- .../util/ClosingPgTestExecutionListener.java | 8 +- ...nsion.java => GaussDBServerExtension.java} | 28 +-- .../java/io/r2dbc/gaussdb/util/PgBouncer.java | 4 +- .../java/io/r2dbc/gaussdb/util/PgPool.java | 4 +- ...resqlHighAvailabilityClusterExtension.java | 6 +- 55 files changed, 324 insertions(+), 344 deletions(-) rename src/main/java/io/r2dbc/gaussdb/{PostgresqlBatch.java => GaussDBBatch.java} (88%) rename src/main/java/io/r2dbc/gaussdb/{PostgresqlColumnMetadata.java => GaussDBColumnMetadata.java} (88%) rename src/main/java/io/r2dbc/gaussdb/{PostgresqlConnectionConfiguration.java => GaussDBConnectionConfiguration.java} (95%) rename src/main/java/io/r2dbc/gaussdb/{PostgresqlConnectionFactoryMetadata.java => GaussDBConnectionFactoryMetadata.java} (69%) rename src/main/java/io/r2dbc/gaussdb/{PostgresqlConnectionFactoryProvider.java => GaussDBConnectionFactoryProvider.java} (91%) rename src/main/java/io/r2dbc/gaussdb/api/{PostgresqlBatch.java => GaussDBBatch.java} (88%) rename src/main/java/io/r2dbc/gaussdb/api/{PostgresqlColumnMetadata.java => GaussDBColumnMetadata.java} (85%) rename src/test/java/io/r2dbc/gaussdb/{PostgresqlBatchUnitTests.java => GaussDBBatchUnitTests.java} (88%) rename src/test/java/io/r2dbc/gaussdb/{PostgresqlColumnMetadataUnitTests.java => GaussDBColumnMetadataUnitTests.java} (83%) rename src/test/java/io/r2dbc/gaussdb/{PostgresqlConnectionConfigurationUnitTests.java => GaussDBConnectionConfigurationUnitTests.java} (77%) rename src/test/java/io/r2dbc/gaussdb/{PostgresqlConnectionFactoryMetadataUnitTests.java => GaussDBConnectionFactoryMetadataUnitTests.java} (75%) rename src/test/java/io/r2dbc/gaussdb/{PostgresqlConnectionFactoryProviderUnitTests.java => GaussDBConnectionFactoryProviderUnitTests.java} (81%) rename src/test/java/io/r2dbc/gaussdb/util/{PostgresqlServerExtension.java => GaussDBServerExtension.java} (89%) diff --git a/src/main/java/io/r2dbc/gaussdb/ConnectionResources.java b/src/main/java/io/r2dbc/gaussdb/ConnectionResources.java index 6873fd5c..c4d3ecf1 100644 --- a/src/main/java/io/r2dbc/gaussdb/ConnectionResources.java +++ b/src/main/java/io/r2dbc/gaussdb/ConnectionResources.java @@ -33,13 +33,13 @@ final class ConnectionResources { private final GaussDBConnection connection; - private final PostgresqlConnectionConfiguration configuration; + private final GaussDBConnectionConfiguration configuration; private final StatementCache statementCache; private final PortalNameSupplier portalNameSupplier; - ConnectionResources(Client client, Codecs codecs, GaussDBConnection connection, PostgresqlConnectionConfiguration configuration, PortalNameSupplier portalNameSupplier, + ConnectionResources(Client client, Codecs codecs, GaussDBConnection connection, GaussDBConnectionConfiguration configuration, PortalNameSupplier portalNameSupplier, StatementCache statementCache) { this.client = client; this.codecs = codecs; @@ -61,7 +61,7 @@ public GaussDBConnection getConnection() { return this.connection; } - public PostgresqlConnectionConfiguration getConfiguration() { + public GaussDBConnectionConfiguration getConfiguration() { return this.configuration; } diff --git a/src/main/java/io/r2dbc/gaussdb/ConnectionStrategyFactory.java b/src/main/java/io/r2dbc/gaussdb/ConnectionStrategyFactory.java index d248a907..ff256195 100644 --- a/src/main/java/io/r2dbc/gaussdb/ConnectionStrategyFactory.java +++ b/src/main/java/io/r2dbc/gaussdb/ConnectionStrategyFactory.java @@ -37,17 +37,17 @@ final class ConnectionStrategyFactory { /** - * Create a {@link ConnectionStrategy} that is able to connect to the specified {@link PostgresqlConnectionConfiguration configuration}. + * Create a {@link ConnectionStrategy} that is able to connect to the specified {@link GaussDBConnectionConfiguration configuration}. * * @param connectionFunction the raw connection function to use to create a {@link Client}. The connection function is enhanced during the connect phase to perform a handshake with the database. * @param configuration the configuration object * @return the connection strategy to use. */ - public static ConnectionStrategy getConnectionStrategy(ConnectionFunction connectionFunction, PostgresqlConnectionConfiguration configuration, ConnectionSettings connectionSettings) { + public static ConnectionStrategy getConnectionStrategy(ConnectionFunction connectionFunction, GaussDBConnectionConfiguration configuration, ConnectionSettings connectionSettings) { return doGetConnectionStrategy(new SingleHostConnectionFunction(connectionFunction, configuration), configuration, connectionSettings); } - private static ConnectionStrategy doGetConnectionStrategy(ConnectionFunction connectionFunction, PostgresqlConnectionConfiguration configuration, ConnectionSettings connectionSettings) { + private static ConnectionStrategy doGetConnectionStrategy(ConnectionFunction connectionFunction, GaussDBConnectionConfiguration configuration, ConnectionSettings connectionSettings) { SSLConfig sslConfig = configuration.getSslConfig(); if (!SSLMode.DISABLE.equals(sslConfig.getSslMode())) { diff --git a/src/main/java/io/r2dbc/gaussdb/PostgresqlBatch.java b/src/main/java/io/r2dbc/gaussdb/GaussDBBatch.java similarity index 88% rename from src/main/java/io/r2dbc/gaussdb/PostgresqlBatch.java rename to src/main/java/io/r2dbc/gaussdb/GaussDBBatch.java index 1e0915b2..9ae8ab63 100644 --- a/src/main/java/io/r2dbc/gaussdb/PostgresqlBatch.java +++ b/src/main/java/io/r2dbc/gaussdb/GaussDBBatch.java @@ -24,20 +24,20 @@ import java.util.List; /** - * An implementation of {@link Batch} for executing a collection of statements in a batch against a PostgreSQL database. + * An implementation of {@link Batch} for executing a collection of statements in a batch against a GaussDB database. */ -final class PostgresqlBatch implements io.r2dbc.gaussdb.api.PostgresqlBatch { +final class GaussDBBatch implements io.r2dbc.gaussdb.api.GaussDBBatch { private final ConnectionResources context; private final List statements = new ArrayList<>(); - PostgresqlBatch(ConnectionResources context) { + GaussDBBatch(ConnectionResources context) { this.context = Assert.requireNonNull(context, "context must not be null"); } @Override - public PostgresqlBatch add(String sql) { + public GaussDBBatch add(String sql) { Assert.requireNonNull(sql, "sql must not be null"); if (!(PostgresqlSqlParser.parse(sql).getParameterCount() == 0)) { diff --git a/src/main/java/io/r2dbc/gaussdb/PostgresqlColumnMetadata.java b/src/main/java/io/r2dbc/gaussdb/GaussDBColumnMetadata.java similarity index 88% rename from src/main/java/io/r2dbc/gaussdb/PostgresqlColumnMetadata.java rename to src/main/java/io/r2dbc/gaussdb/GaussDBColumnMetadata.java index 3a71a062..df9b2d16 100644 --- a/src/main/java/io/r2dbc/gaussdb/PostgresqlColumnMetadata.java +++ b/src/main/java/io/r2dbc/gaussdb/GaussDBColumnMetadata.java @@ -29,7 +29,7 @@ /** * An implementation of {@link ColumnMetadata} for a PostgreSQL database. */ -final class PostgresqlColumnMetadata implements io.r2dbc.gaussdb.api.PostgresqlColumnMetadata { +final class GaussDBColumnMetadata implements io.r2dbc.gaussdb.api.GaussDBColumnMetadata { private final Codecs codecs; @@ -41,7 +41,7 @@ final class PostgresqlColumnMetadata implements io.r2dbc.gaussdb.api.PostgresqlC private final short precision; - PostgresqlColumnMetadata(Codecs codecs, String name, int nativeType, short precision) { + GaussDBColumnMetadata(Codecs codecs, String name, int nativeType, short precision) { this.codecs = codecs; this.format = Format.FORMAT_TEXT; this.name = name; @@ -49,7 +49,7 @@ final class PostgresqlColumnMetadata implements io.r2dbc.gaussdb.api.PostgresqlC this.precision = precision; } - PostgresqlColumnMetadata(Codecs codecs, Field field) { + GaussDBColumnMetadata(Codecs codecs, Field field) { this.codecs = Assert.requireNonNull(codecs, "codecs must not be null"); Assert.requireNonNull(field, "field must not be null"); this.format = field.getFormat(); @@ -63,10 +63,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof PostgresqlColumnMetadata)) { + if (!(o instanceof GaussDBColumnMetadata)) { return false; } - PostgresqlColumnMetadata that = (PostgresqlColumnMetadata) o; + GaussDBColumnMetadata that = (GaussDBColumnMetadata) o; return this.name.equals(that.name) && this.nativeType == that.nativeType && @@ -117,8 +117,8 @@ public String toString() { '}'; } - static PostgresqlColumnMetadata toColumnMetadata(Codecs codecs, Field field) { - return new PostgresqlColumnMetadata(codecs, field); + static GaussDBColumnMetadata toColumnMetadata(Codecs codecs, Field field) { + return new GaussDBColumnMetadata(codecs, field); } static class OidType implements Type { diff --git a/src/main/java/io/r2dbc/gaussdb/GaussDBConnection.java b/src/main/java/io/r2dbc/gaussdb/GaussDBConnection.java index b9dccbe3..13b5299f 100644 --- a/src/main/java/io/r2dbc/gaussdb/GaussDBConnection.java +++ b/src/main/java/io/r2dbc/gaussdb/GaussDBConnection.java @@ -85,7 +85,7 @@ final class GaussDBConnection implements io.r2dbc.gaussdb.api.GaussDBConnection, private volatile IsolationLevel previousIsolationLevel; GaussDBConnection(Client client, Codecs codecs, PortalNameSupplier portalNameSupplier, StatementCache statementCache, IsolationLevel isolationLevel, - PostgresqlConnectionConfiguration configuration) { + GaussDBConnectionConfiguration configuration) { this.client = Assert.requireNonNull(client, "client must not be null"); this.resources = new ConnectionResources(client, codecs, this, configuration, portalNameSupplier, statementCache); this.connectionContext = client.getContext(); @@ -228,8 +228,8 @@ public CopyInBuilder copyIn(String sql) { } @Override - public PostgresqlBatch createBatch() { - return new PostgresqlBatch(this.resources); + public GaussDBBatch createBatch() { + return new GaussDBBatch(this.resources); } @Override diff --git a/src/main/java/io/r2dbc/gaussdb/PostgresqlConnectionConfiguration.java b/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionConfiguration.java similarity index 95% rename from src/main/java/io/r2dbc/gaussdb/PostgresqlConnectionConfiguration.java rename to src/main/java/io/r2dbc/gaussdb/GaussDBConnectionConfiguration.java index e978fe25..89bf6ce3 100644 --- a/src/main/java/io/r2dbc/gaussdb/PostgresqlConnectionConfiguration.java +++ b/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionConfiguration.java @@ -70,14 +70,14 @@ import static io.r2dbc.gaussdb.message.frontend.Execute.NO_LIMIT; /** - * Connection configuration information for connecting to a PostgreSQL database. + * Connection configuration information for connecting to a GaussDB database. */ -public final class PostgresqlConnectionConfiguration { +public final class GaussDBConnectionConfiguration { /** - * Default PostgreSQL port. + * Default GaussDB port. */ - public static final int DEFAULT_PORT = 5432; + public static final int DEFAULT_PORT = 8000; private final String applicationName; @@ -134,12 +134,12 @@ public final class PostgresqlConnectionConfiguration { private final Publisher username; - private PostgresqlConnectionConfiguration(String applicationName, boolean autodetectExtensions, @Nullable boolean compatibilityMode, @Nullable Duration connectTimeout, @Nullable String database + private GaussDBConnectionConfiguration(String applicationName, boolean autodetectExtensions, @Nullable boolean compatibilityMode, @Nullable Duration connectTimeout, @Nullable String database , LogLevel errorResponseLogLevel, List extensions, ToIntFunction fetchSize, boolean forceBinary, @Nullable Duration lockWaitTimeout, - @Nullable LoopResources loopResources, @Nullable MultiHostConfiguration multiHostConfiguration, LogLevel noticeLogLevel, - @Nullable Map options, @Nullable Publisher password, boolean preferAttachedBuffers, int preparedStatementCacheQueries, - @Nullable String schema, @Nullable SingleHostConfiguration singleHostConfiguration, SSLConfig sslConfig, @Nullable Duration statementTimeout, - boolean tcpKeepAlive, boolean tcpNoDelay, TimeZone timeZone, Publisher username) { + @Nullable LoopResources loopResources, @Nullable MultiHostConfiguration multiHostConfiguration, LogLevel noticeLogLevel, + @Nullable Map options, @Nullable Publisher password, boolean preferAttachedBuffers, int preparedStatementCacheQueries, + @Nullable String schema, @Nullable SingleHostConfiguration singleHostConfiguration, SSLConfig sslConfig, @Nullable Duration statementTimeout, + boolean tcpKeepAlive, boolean tcpNoDelay, TimeZone timeZone, Publisher username) { this.applicationName = Assert.requireNonNull(applicationName, "applicationName must not be null"); this.autodetectExtensions = autodetectExtensions; this.compatibilityMode = compatibilityMode; @@ -190,7 +190,7 @@ public static Builder builder() { @Override public String toString() { - return "PostgresqlConnectionConfiguration{" + + return "GaussDBConnectionConfiguration{" + "applicationName='" + this.applicationName + '\'' + ", autodetectExtensions='" + this.autodetectExtensions + '\'' + ", compatibilityMode=" + this.compatibilityMode + @@ -347,7 +347,7 @@ private static String obfuscate(int length) { } /** - * A builder for {@link PostgresqlConnectionConfiguration} instances. + * A builder for {@link GaussDBConnectionConfiguration} instances. *

* This class is not threadsafe */ @@ -462,11 +462,11 @@ public Builder autodetectExtensions(boolean autodetectExtensions) { } /** - * Returns a configured {@link PostgresqlConnectionConfiguration}. + * Returns a configured {@link GaussDBConnectionConfiguration}. * - * @return a configured {@link PostgresqlConnectionConfiguration} + * @return a configured {@link GaussDBConnectionConfiguration} */ - public PostgresqlConnectionConfiguration build() { + public GaussDBConnectionConfiguration build() { SingleHostConfiguration singleHostConfiguration = this.singleHostConfiguration != null ? this.singleHostConfiguration.build() @@ -484,7 +484,7 @@ public PostgresqlConnectionConfiguration build() { throw new IllegalArgumentException("username must not be null"); } - return new PostgresqlConnectionConfiguration(this.applicationName, this.autodetectExtensions, this.compatibilityMode, this.connectTimeout, this.database, this.errorResponseLogLevel, + return new GaussDBConnectionConfiguration(this.applicationName, this.autodetectExtensions, this.compatibilityMode, this.connectTimeout, this.database, this.errorResponseLogLevel, this.extensions, this.fetchSize, this.forceBinary, this.lockWaitTimeout, this.loopResources, multiHostConfiguration, this.noticeLogLevel, this.options, this.password, this.preferAttachedBuffers, this.preparedStatementCacheQueries, this.schema, singleHostConfiguration, @@ -598,7 +598,7 @@ public Builder fetchSize(ToIntFunction fetchSizeFunction) { } /** - * Force binary results (Binary Transfer). Defaults to false. + * Force binary results. Defaults to false. * * @param forceBinary whether to force binary transfer * @return this {@link Builder} @@ -688,8 +688,6 @@ public Builder loadBalanceHosts(boolean loadBalanceHosts) { *

* This parameter is applied once after creating a new connection. * If lockTimeout is already set using {@link #options(Map)}, it will be overridden. - * Lock Timeout - * * @param lockWaitTimeout the lock timeout * @return this {@link Builder} * @since 0.8.9 @@ -716,7 +714,6 @@ public Builder loopResources(LoopResources loopResources) { * * @param noticeLogLevel the log level to use. * @return this {@link Builder} - * @since 0.9 */ public Builder noticeLogLevel(LogLevel noticeLogLevel) { this.noticeLogLevel = Assert.requireNonNull(noticeLogLevel, "noticeLogLevel must not be null"); @@ -727,7 +724,6 @@ public Builder noticeLogLevel(LogLevel noticeLogLevel) { * Configure connection initialization parameters. *

* These parameters are applied once after creating a new connection. This is useful for setting up client-specific - * runtime parameters * like statement timeouts, time zones etc. * * @param options the options @@ -782,7 +778,7 @@ public Builder password(Supplier password) { } /** - * Configure the port. Defaults to {@code 5432}. Calling this method prepares single-node configuration. This method can be only used if the builder was not configured with a multi-host + * Configure the port. Defaults to {@code 8000}. Calling this method prepares single-node configuration. This method can be only used if the builder was not configured with a multi-host * configuration. * * @param port the port @@ -1009,11 +1005,8 @@ public Builder sslRootCert(URL sslRootCert) { *

* This parameter is applied once after creating a new connection. * If statementTimeout is already set using {@link #options(Map)}, it will be overridden. - * Statement Timeout - * * @param statementTimeout the statement timeout * @return this {@link Builder} - * @since 0.8.9 */ public Builder statementTimeout(Duration statementTimeout) { this.statementTimeout = Assert.requireNonNull(statementTimeout, "Statement timeout"); diff --git a/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactory.java b/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactory.java index eb0dd2cc..f929301b 100644 --- a/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactory.java +++ b/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactory.java @@ -58,7 +58,7 @@ public final class GaussDBConnectionFactory implements ConnectionFactory { private final ConnectionFunction connectionFunction; - private final PostgresqlConnectionConfiguration configuration; + private final GaussDBConnectionConfiguration configuration; private final Extensions extensions; @@ -68,7 +68,7 @@ public final class GaussDBConnectionFactory implements ConnectionFactory { * @param configuration the configuration to use * @throws IllegalArgumentException if {@code configuration} is {@code null} */ - public GaussDBConnectionFactory(PostgresqlConnectionConfiguration configuration) { + public GaussDBConnectionFactory(GaussDBConnectionConfiguration configuration) { this(DEFAULT_CONNECTION_FUNCTION, configuration); } @@ -79,13 +79,13 @@ public GaussDBConnectionFactory(PostgresqlConnectionConfiguration configuration) * @param configuration the configuration to use * @throws IllegalArgumentException if {@code configuration} is {@code null} */ - GaussDBConnectionFactory(ConnectionFunction connectionFunction, PostgresqlConnectionConfiguration configuration) { + GaussDBConnectionFactory(ConnectionFunction connectionFunction, GaussDBConnectionConfiguration configuration) { this.connectionFunction = Assert.requireNonNull(connectionFunction, "connectionFunction must not be null"); this.configuration = Assert.requireNonNull(configuration, "configuration must not be null"); this.extensions = getExtensions(configuration); } - private static Extensions getExtensions(PostgresqlConnectionConfiguration configuration) { + private static Extensions getExtensions(GaussDBConnectionConfiguration configuration) { Extensions extensions = Extensions.from(configuration.getExtensions()); if (configuration.isAutodetectExtensions()) { @@ -190,10 +190,10 @@ private Throwable cannotConnect(Throwable throwable, ConnectionStrategy strategy @Override public ConnectionFactoryMetadata getMetadata() { - return PostgresqlConnectionFactoryMetadata.INSTANCE; + return GaussDBConnectionFactoryMetadata.INSTANCE; } - PostgresqlConnectionConfiguration getConfiguration() { + GaussDBConnectionConfiguration getConfiguration() { return this.configuration; } diff --git a/src/main/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryMetadata.java b/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryMetadata.java similarity index 69% rename from src/main/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryMetadata.java rename to src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryMetadata.java index 42ef02b2..5761a9f3 100644 --- a/src/main/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryMetadata.java +++ b/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryMetadata.java @@ -19,18 +19,18 @@ import io.r2dbc.spi.ConnectionFactoryMetadata; /** - * An implementation of {@link ConnectionFactoryMetadata} for a PostgreSQL database. + * An implementation of {@link ConnectionFactoryMetadata} for a GaussDB database. */ -final class PostgresqlConnectionFactoryMetadata implements ConnectionFactoryMetadata { +final class GaussDBConnectionFactoryMetadata implements ConnectionFactoryMetadata { /** - * The name of the PostgreSQL database product. + * The name of the GaussDB database product. */ - public static final String NAME = "PostgreSQL"; + public static final String NAME = "GaussDB"; - static final PostgresqlConnectionFactoryMetadata INSTANCE = new PostgresqlConnectionFactoryMetadata(); + static final GaussDBConnectionFactoryMetadata INSTANCE = new GaussDBConnectionFactoryMetadata(); - private PostgresqlConnectionFactoryMetadata() { + private GaussDBConnectionFactoryMetadata() { } @Override diff --git a/src/main/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryProvider.java b/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryProvider.java similarity index 91% rename from src/main/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryProvider.java rename to src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryProvider.java index f23fd2db..757a6b70 100644 --- a/src/main/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryProvider.java +++ b/src/main/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryProvider.java @@ -53,7 +53,7 @@ /** * An implementation of {@link ConnectionFactoryProvider} for creating {@link GaussDBConnectionFactory}s. */ -public final class PostgresqlConnectionFactoryProvider implements ConnectionFactoryProvider { +public final class GaussDBConnectionFactoryProvider implements ConnectionFactoryProvider { /** * Application name. @@ -135,12 +135,7 @@ public final class PostgresqlConnectionFactoryProvider implements ConnectionFact /** * Driver option value. */ - public static final String POSTGRESQL_DRIVER = "gaussdb"; - - /** - * Legacy driver option value. - */ - public static final String LEGACY_POSTGRESQL_DRIVER = "postgres"; + public static final String GAUSSDB_DRIVER = "gaussdb"; /** * Failover driver protocol. @@ -264,13 +259,13 @@ public final class PostgresqlConnectionFactoryProvider implements ConnectionFact public static final Option TIME_ZONE = Option.valueOf("timeZone"); /** - * Returns a new {@link PostgresqlConnectionConfiguration.Builder} configured with the given {@link ConnectionFactoryOptions}. + * Returns a new {@link GaussDBConnectionConfiguration.Builder} configured with the given {@link ConnectionFactoryOptions}. * - * @param connectionFactoryOptions {@link ConnectionFactoryOptions} used to initialize the {@link PostgresqlConnectionConfiguration.Builder}. - * @return a {@link PostgresqlConnectionConfiguration.Builder} + * @param connectionFactoryOptions {@link ConnectionFactoryOptions} used to initialize the {@link GaussDBConnectionConfiguration.Builder}. + * @return a {@link GaussDBConnectionConfiguration.Builder} * @since 0.9 */ - public static PostgresqlConnectionConfiguration.Builder builder(ConnectionFactoryOptions connectionFactoryOptions) { + public static GaussDBConnectionConfiguration.Builder builder(ConnectionFactoryOptions connectionFactoryOptions) { return fromConnectionFactoryOptions(connectionFactoryOptions); } @@ -281,7 +276,7 @@ public GaussDBConnectionFactory create(ConnectionFactoryOptions connectionFactor @Override public String getDriver() { - return POSTGRESQL_DRIVER; + return GAUSSDB_DRIVER; } @Override @@ -289,22 +284,22 @@ public boolean supports(ConnectionFactoryOptions connectionFactoryOptions) { Assert.requireNonNull(connectionFactoryOptions, "connectionFactoryOptions must not be null"); String driver = "" + connectionFactoryOptions.getValue(DRIVER); - return driver != null && (driver.equals(POSTGRESQL_DRIVER) || driver.equals(LEGACY_POSTGRESQL_DRIVER)); + return driver != null && (driver.equals(GAUSSDB_DRIVER)); } /** * Configure the builder with the given {@link ConnectionFactoryOptions}. * * @param options {@link ConnectionFactoryOptions} - * @return this {@link PostgresqlConnectionConfiguration.Builder} + * @return this {@link GaussDBConnectionConfiguration.Builder} * @throws IllegalArgumentException if {@code options} is {@code null} */ @SuppressWarnings("unchecked") - private static PostgresqlConnectionConfiguration.Builder fromConnectionFactoryOptions(ConnectionFactoryOptions options) { + private static GaussDBConnectionConfiguration.Builder fromConnectionFactoryOptions(ConnectionFactoryOptions options) { Assert.requireNonNull(options, "connectionFactoryOptions must not be null"); - PostgresqlConnectionConfiguration.Builder builder = PostgresqlConnectionConfiguration.builder(); + GaussDBConnectionConfiguration.Builder builder = GaussDBConnectionConfiguration.builder(); OptionMapper mapper = OptionMapper.create(options); @@ -353,7 +348,7 @@ private static PostgresqlConnectionConfiguration.Builder fromConnectionFactoryOp mapper.from(LOCK_WAIT_TIMEOUT).map(OptionMapper::toDuration).to(builder::lockWaitTimeout); mapper.fromTyped(LOOP_RESOURCES).to(builder::loopResources); mapper.from(NOTICE_LOG_LEVEL).map(it -> OptionMapper.toEnum(it, LogLevel.class)).to(builder::noticeLogLevel); - mapper.from(OPTIONS).map(PostgresqlConnectionFactoryProvider::convertToMap).to(builder::options); + mapper.from(OPTIONS).map(GaussDBConnectionFactoryProvider::convertToMap).to(builder::options); mapper.from(PORT).map(OptionMapper::toInteger).to(builder::port); mapper.from(PREFER_ATTACHED_BUFFERS).map(OptionMapper::toBoolean).to(builder::preferAttachedBuffers); mapper.from(PREPARED_STATEMENT_CACHE_QUERIES).map(OptionMapper::toInteger).to(builder::preparedStatementCacheQueries); @@ -396,7 +391,7 @@ private static PostgresqlConnectionConfiguration.Builder fromConnectionFactoryOp return builder; } - private static void setupSsl(PostgresqlConnectionConfiguration.Builder builder, OptionMapper mapper) { + private static void setupSsl(GaussDBConnectionConfiguration.Builder builder, OptionMapper mapper) { mapper.from(SSL).map(OptionMapper::toBoolean).to(enableSsl -> { if (enableSsl) { @@ -404,8 +399,8 @@ private static void setupSsl(PostgresqlConnectionConfiguration.Builder builder, } }); - mapper.from(SSL_MODE).map(PostgresqlConnectionFactoryProvider::toSSLMode).to(builder::sslMode).otherwise(() -> { - mapper.from(SSL_MODE_ALIAS).map(PostgresqlConnectionFactoryProvider::toSSLMode).to(builder::sslMode); + mapper.from(SSL_MODE).map(GaussDBConnectionFactoryProvider::toSSLMode).to(builder::sslMode).otherwise(() -> { + mapper.from(SSL_MODE_ALIAS).map(GaussDBConnectionFactoryProvider::toSSLMode).to(builder::sslMode); }); mapper.fromTyped(SSL_CERT).to(builder::sslCert); diff --git a/src/main/java/io/r2dbc/gaussdb/MultiHostConnectionStrategy.java b/src/main/java/io/r2dbc/gaussdb/MultiHostConnectionStrategy.java index b6ca6956..ef1c693f 100644 --- a/src/main/java/io/r2dbc/gaussdb/MultiHostConnectionStrategy.java +++ b/src/main/java/io/r2dbc/gaussdb/MultiHostConnectionStrategy.java @@ -51,7 +51,7 @@ public final class MultiHostConnectionStrategy implements ConnectionStrategy { private final Collection addresses; - private final PostgresqlConnectionConfiguration configuration; + private final GaussDBConnectionConfiguration configuration; private final MultiHostConfiguration multiHostConfiguration; @@ -59,7 +59,7 @@ public final class MultiHostConnectionStrategy implements ConnectionStrategy { private final Map statusMap; - MultiHostConnectionStrategy(ConnectionFunction connectionFunction, Collection addresses, PostgresqlConnectionConfiguration configuration, ConnectionSettings settings) { + MultiHostConnectionStrategy(ConnectionFunction connectionFunction, Collection addresses, GaussDBConnectionConfiguration configuration, ConnectionSettings settings) { Assert.isTrue(!addresses.isEmpty(), "Collection of SocketAddress must not be empty"); @@ -156,7 +156,7 @@ private static HostConnectOutcome evaluateStatus(SocketAddress candidate, @Nulla ? HostConnectOutcome.ok(candidate) : oldStatus; } - private static Mono isPrimaryServer(Client client, PostgresqlConnectionConfiguration configuration) { + private static Mono isPrimaryServer(Client client, GaussDBConnectionConfiguration configuration) { GaussDBConnection connection = new GaussDBConnection(client, new DefaultCodecs(client.getByteBufAllocator()), DefaultPortalNameSupplier.INSTANCE, DisabledStatementCache.INSTANCE, IsolationLevel.READ_UNCOMMITTED, configuration); diff --git a/src/main/java/io/r2dbc/gaussdb/PostgresqlRowMetadata.java b/src/main/java/io/r2dbc/gaussdb/PostgresqlRowMetadata.java index d36976f6..da4fa006 100644 --- a/src/main/java/io/r2dbc/gaussdb/PostgresqlRowMetadata.java +++ b/src/main/java/io/r2dbc/gaussdb/PostgresqlRowMetadata.java @@ -40,26 +40,26 @@ */ final class PostgresqlRowMetadata extends AbstractCollection implements io.r2dbc.gaussdb.api.PostgresqlRowMetadata { - private final List columnMetadatas; + private final List columnMetadatas; - private final Map nameKeyedColumns; + private final Map nameKeyedColumns; private final Map columnNameIndexMap; - PostgresqlRowMetadata(List columnMetadatas) { + PostgresqlRowMetadata(List columnMetadatas) { this.columnMetadatas = Assert.requireNonNull(columnMetadatas, "columnMetadatas must not be null"); this.nameKeyedColumns = new LinkedHashMap<>(columnMetadatas.size(), 1); this.columnNameIndexMap = new HashMap<>(columnMetadatas.size(), 1); int i = 0; - for (PostgresqlColumnMetadata columnMetadata : columnMetadatas) { + for (GaussDBColumnMetadata columnMetadata : columnMetadatas) { this.nameKeyedColumns.putIfAbsent(columnMetadata.getName(), columnMetadata); this.columnNameIndexMap.putIfAbsent(columnMetadata.getName().toLowerCase(Locale.ROOT), i++); } } @Override - public PostgresqlColumnMetadata getColumnMetadata(int index) { + public GaussDBColumnMetadata getColumnMetadata(int index) { if (index >= this.columnMetadatas.size()) { throw new IndexOutOfBoundsException(String.format("Column index %d is larger than the number of columns %d", index, this.columnMetadatas.size())); } @@ -68,10 +68,10 @@ public PostgresqlColumnMetadata getColumnMetadata(int index) { } @Override - public PostgresqlColumnMetadata getColumnMetadata(String name) { + public GaussDBColumnMetadata getColumnMetadata(String name) { Assert.requireNonNull(name, "name must not be null"); - for (PostgresqlColumnMetadata metadata : this.columnMetadatas) { + for (GaussDBColumnMetadata metadata : this.columnMetadatas) { if (metadata.getName().equalsIgnoreCase(name)) { return metadata; @@ -94,7 +94,7 @@ public boolean equals(Object o) { } @Override - public List getColumnMetadatas() { + public List getColumnMetadatas() { return Collections.unmodifiableList(this.columnMetadatas); } @@ -168,15 +168,15 @@ public void clear() { } /** - * Lookup {@link PostgresqlColumnMetadata} by its {@code name}. + * Lookup {@link GaussDBColumnMetadata} by its {@code name}. * * @param name the column name. - * @return the {@link PostgresqlColumnMetadata}. + * @return the {@link GaussDBColumnMetadata}. */ @Nullable - PostgresqlColumnMetadata findColumn(String name) { + GaussDBColumnMetadata findColumn(String name) { - PostgresqlColumnMetadata column = this.nameKeyedColumns.get(name); + GaussDBColumnMetadata column = this.nameKeyedColumns.get(name); if (column == null) { name = EscapeAwareColumnMatcher.findColumn(name, this.nameKeyedColumns.keySet()); @@ -199,11 +199,11 @@ static PostgresqlRowMetadata toRowMetadata(Codecs codecs, RowDescription rowDesc return new PostgresqlRowMetadata(getColumnMetadatas(codecs, rowDescription)); } - private static List getColumnMetadatas(Codecs codecs, RowDescription rowDescription) { - List columnMetadatas = new ArrayList<>(rowDescription.getFields().size()); + private static List getColumnMetadatas(Codecs codecs, RowDescription rowDescription) { + List columnMetadatas = new ArrayList<>(rowDescription.getFields().size()); for (RowDescription.Field field : rowDescription.getFields()) { - columnMetadatas.add(PostgresqlColumnMetadata.toColumnMetadata(codecs, field)); + columnMetadatas.add(GaussDBColumnMetadata.toColumnMetadata(codecs, field)); } return columnMetadatas; diff --git a/src/main/java/io/r2dbc/gaussdb/SingleHostConnectionFunction.java b/src/main/java/io/r2dbc/gaussdb/SingleHostConnectionFunction.java index 68ea9241..fe74be48 100644 --- a/src/main/java/io/r2dbc/gaussdb/SingleHostConnectionFunction.java +++ b/src/main/java/io/r2dbc/gaussdb/SingleHostConnectionFunction.java @@ -35,9 +35,9 @@ final class SingleHostConnectionFunction implements ConnectionFunction { private final ConnectionFunction upstreamFunction; - private final PostgresqlConnectionConfiguration configuration; + private final GaussDBConnectionConfiguration configuration; - SingleHostConnectionFunction(ConnectionFunction upstreamFunction, PostgresqlConnectionConfiguration configuration) { + SingleHostConnectionFunction(ConnectionFunction upstreamFunction, GaussDBConnectionConfiguration configuration) { this.upstreamFunction = upstreamFunction; this.configuration = configuration; } @@ -52,7 +52,7 @@ public Mono connect(SocketAddress endpoint, ConnectionSettings settings) .handle(ExceptionFactory.INSTANCE::handleErrorResponse)); } - private static PostgresStartupParameterProvider getParameterProvider(PostgresqlConnectionConfiguration configuration, ConnectionSettings settings) { + private static PostgresStartupParameterProvider getParameterProvider(GaussDBConnectionConfiguration configuration, ConnectionSettings settings) { return new PostgresStartupParameterProvider(configuration.getApplicationName(), configuration.getTimeZone(), settings); } diff --git a/src/main/java/io/r2dbc/gaussdb/api/PostgresqlBatch.java b/src/main/java/io/r2dbc/gaussdb/api/GaussDBBatch.java similarity index 88% rename from src/main/java/io/r2dbc/gaussdb/api/PostgresqlBatch.java rename to src/main/java/io/r2dbc/gaussdb/api/GaussDBBatch.java index 0cb0c34a..99f32b7f 100644 --- a/src/main/java/io/r2dbc/gaussdb/api/PostgresqlBatch.java +++ b/src/main/java/io/r2dbc/gaussdb/api/GaussDBBatch.java @@ -20,15 +20,15 @@ import reactor.core.publisher.Flux; /** - * {@link Batch} for executing a collection of statements in a batch against a PostgreSQL database. + * {@link Batch} for executing a collection of statements in a batch against a GaussDB atabase. */ -public interface PostgresqlBatch extends Batch { +public interface GaussDBBatch extends Batch { /** * {@inheritDoc} */ @Override - PostgresqlBatch add(String sql); + GaussDBBatch add(String sql); /** * {@inheritDoc} diff --git a/src/main/java/io/r2dbc/gaussdb/api/PostgresqlColumnMetadata.java b/src/main/java/io/r2dbc/gaussdb/api/GaussDBColumnMetadata.java similarity index 85% rename from src/main/java/io/r2dbc/gaussdb/api/PostgresqlColumnMetadata.java rename to src/main/java/io/r2dbc/gaussdb/api/GaussDBColumnMetadata.java index 9706a287..814580e1 100644 --- a/src/main/java/io/r2dbc/gaussdb/api/PostgresqlColumnMetadata.java +++ b/src/main/java/io/r2dbc/gaussdb/api/GaussDBColumnMetadata.java @@ -19,8 +19,8 @@ import io.r2dbc.spi.ColumnMetadata; /** - * {@link ColumnMetadata} for a PostgreSQL database. + * {@link ColumnMetadata} for a GaussDB database. */ -public interface PostgresqlColumnMetadata extends ColumnMetadata { +public interface GaussDBColumnMetadata extends ColumnMetadata { } diff --git a/src/main/java/io/r2dbc/gaussdb/api/GaussDBConnection.java b/src/main/java/io/r2dbc/gaussdb/api/GaussDBConnection.java index d17e4ab2..13faa614 100644 --- a/src/main/java/io/r2dbc/gaussdb/api/GaussDBConnection.java +++ b/src/main/java/io/r2dbc/gaussdb/api/GaussDBConnection.java @@ -87,7 +87,7 @@ default Mono copyIn(String sql, Publisher stdin) { * {@inheritDoc} */ @Override - PostgresqlBatch createBatch(); + GaussDBBatch createBatch(); /** * {@inheritDoc} diff --git a/src/main/java/io/r2dbc/gaussdb/client/ConnectionSettings.java b/src/main/java/io/r2dbc/gaussdb/client/ConnectionSettings.java index 362a64ae..5730d810 100644 --- a/src/main/java/io/r2dbc/gaussdb/client/ConnectionSettings.java +++ b/src/main/java/io/r2dbc/gaussdb/client/ConnectionSettings.java @@ -16,7 +16,7 @@ package io.r2dbc.gaussdb.client; -import io.r2dbc.gaussdb.PostgresqlConnectionConfiguration; +import io.r2dbc.gaussdb.GaussDBConnectionConfiguration; import io.r2dbc.gaussdb.message.backend.ErrorResponse; import io.r2dbc.gaussdb.message.backend.NoticeResponse; import io.r2dbc.gaussdb.util.Assert; @@ -281,7 +281,7 @@ public Builder startupOptions(Map startupOptions) { * Configure TCP KeepAlive. * * @param enabled whether to enable TCP KeepAlive - * @return this {@link PostgresqlConnectionConfiguration.Builder} + * @return this {@link GaussDBConnectionConfiguration.Builder} * @see Socket#setKeepAlive(boolean) */ public Builder tcpKeepAlive(boolean enabled) { @@ -293,7 +293,7 @@ public Builder tcpKeepAlive(boolean enabled) { * Configure TCP NoDelay. * * @param enabled whether to enable TCP NoDelay - * @return this {@link PostgresqlConnectionConfiguration.Builder} + * @return this {@link GaussDBConnectionConfiguration.Builder} * @see Socket#setTcpNoDelay(boolean) */ public Builder tcpNoDelay(boolean enabled) { diff --git a/src/main/java/io/r2dbc/gaussdb/client/MultiHostConfiguration.java b/src/main/java/io/r2dbc/gaussdb/client/MultiHostConfiguration.java index 67dbbd4f..5b8fae41 100644 --- a/src/main/java/io/r2dbc/gaussdb/client/MultiHostConfiguration.java +++ b/src/main/java/io/r2dbc/gaussdb/client/MultiHostConfiguration.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Objects; -import static io.r2dbc.gaussdb.PostgresqlConnectionConfiguration.DEFAULT_PORT; +import static io.r2dbc.gaussdb.GaussDBConnectionConfiguration.DEFAULT_PORT; /** * Connection configuration information for connecting to a cluster of Postgres servers. diff --git a/src/main/java/io/r2dbc/gaussdb/client/SingleHostConfiguration.java b/src/main/java/io/r2dbc/gaussdb/client/SingleHostConfiguration.java index 240d2015..58b844ad 100644 --- a/src/main/java/io/r2dbc/gaussdb/client/SingleHostConfiguration.java +++ b/src/main/java/io/r2dbc/gaussdb/client/SingleHostConfiguration.java @@ -19,7 +19,7 @@ import io.r2dbc.gaussdb.util.Assert; import reactor.util.annotation.Nullable; -import static io.r2dbc.gaussdb.PostgresqlConnectionConfiguration.DEFAULT_PORT; +import static io.r2dbc.gaussdb.GaussDBConnectionConfiguration.DEFAULT_PORT; /** * Connection configuration information for connecting to a single Postgres server. @@ -128,7 +128,7 @@ public Builder host(String host) { } /** - * Configure the port. Defaults to {@code 5432}. + * Configure the port. Defaults to {@code 8000}. * * @param port the port * @return this {@link Builder} diff --git a/src/main/java/io/r2dbc/gaussdb/extension/CodecRegistrar.java b/src/main/java/io/r2dbc/gaussdb/extension/CodecRegistrar.java index a1cf0278..0e96f3a2 100644 --- a/src/main/java/io/r2dbc/gaussdb/extension/CodecRegistrar.java +++ b/src/main/java/io/r2dbc/gaussdb/extension/CodecRegistrar.java @@ -17,6 +17,7 @@ package io.r2dbc.gaussdb.extension; import io.netty.buffer.ByteBufAllocator; +import io.r2dbc.gaussdb.GaussDBConnectionConfiguration; import io.r2dbc.gaussdb.api.GaussDBConnection; import io.r2dbc.gaussdb.codec.Codec; import io.r2dbc.gaussdb.codec.CodecRegistry; @@ -29,7 +30,7 @@ * * Constructor Requirements *

Extension implementations must have a default constructor if registered via the {@code ServiceLoader}. When registered through - * {@link io.r2dbc.gaussdb.PostgresqlConnectionConfiguration} the default constructor is not required to be {@code public}. + * {@link GaussDBConnectionConfiguration} the default constructor is not required to be {@code public}. * When registered via the {@code ServiceLoader} the default constructor must be {@code public}. * * @see Extension diff --git a/src/main/java/io/r2dbc/gaussdb/extension/Extension.java b/src/main/java/io/r2dbc/gaussdb/extension/Extension.java index 2348aa3d..b4fbe5a5 100644 --- a/src/main/java/io/r2dbc/gaussdb/extension/Extension.java +++ b/src/main/java/io/r2dbc/gaussdb/extension/Extension.java @@ -16,11 +16,13 @@ package io.r2dbc.gaussdb.extension; +import io.r2dbc.gaussdb.GaussDBConnectionConfiguration; + /** * Marker interface for all extensions. * *

An {@link Extension} can be registered programmatically through - * {@link io.r2dbc.gaussdb.PostgresqlConnectionConfiguration} or automatically using + * {@link GaussDBConnectionConfiguration} or automatically using * the {@link java.util.ServiceLoader} mechanism. *

* The global extension registration through Java's {@link java.util.ServiceLoader} mechanism, allows third-party extensions to be auto-detected and automatically registered based on @@ -30,12 +32,12 @@ * {@code /META-INF/services} directory in its enclosing JAR file.

* * Configuring Automatic Extension Detection - *

Auto-detection is enabled by default. To disable it, simply set the {@link io.r2dbc.gaussdb.PostgresqlConnectionConfiguration.Builder#autodetectExtensions(boolean)} parameter to + *

Auto-detection is enabled by default. To disable it, simply set the {@link GaussDBConnectionConfiguration.Builder#autodetectExtensions(boolean)} parameter to * {@code false}.

* * Constructor Requirements *

Extension implementations must have a default constructor if registered via the {@code ServiceLoader}. When registered through - * {@link io.r2dbc.gaussdb.PostgresqlConnectionConfiguration} the default constructor is not required to be {@code public}. + * {@link GaussDBConnectionConfiguration} the default constructor is not required to be {@code public}. * When registered via the {@code ServiceLoader} the default constructor must be {@code public}. */ public interface Extension { diff --git a/src/main/resources/META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider b/src/main/resources/META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider index c86138f6..59adb504 100644 --- a/src/main/resources/META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider +++ b/src/main/resources/META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider @@ -1 +1 @@ -io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider \ No newline at end of file +io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider \ No newline at end of file diff --git a/src/test/java/io/r2dbc/gaussdb/AbstractCodecIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/AbstractCodecIntegrationTests.java index c1d3d421..a51b7429 100644 --- a/src/test/java/io/r2dbc/gaussdb/AbstractCodecIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/AbstractCodecIntegrationTests.java @@ -92,7 +92,7 @@ abstract class AbstractCodecIntegrationTests extends AbstractIntegrationTests { @Override - protected void customize(PostgresqlConnectionConfiguration.Builder builder) { + protected void customize(GaussDBConnectionConfiguration.Builder builder) { try { SERVER.getJdbcOperations().execute("CREATE TYPE my_enum AS ENUM ('HELLO', 'WORLD')"); } catch (DataAccessException e) { diff --git a/src/test/java/io/r2dbc/gaussdb/AbstractIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/AbstractIntegrationTests.java index c88cccb8..875382e7 100644 --- a/src/test/java/io/r2dbc/gaussdb/AbstractIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/AbstractIntegrationTests.java @@ -17,7 +17,7 @@ package io.r2dbc.gaussdb; import io.r2dbc.gaussdb.api.GaussDBConnection; -import io.r2dbc.gaussdb.util.PostgresqlServerExtension; +import io.r2dbc.gaussdb.util.GaussDBServerExtension; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.RegisterExtension; @@ -31,7 +31,7 @@ public abstract class AbstractIntegrationTests { @RegisterExtension - public static final PostgresqlServerExtension SERVER = new PostgresqlServerExtension(); + public static final GaussDBServerExtension SERVER = new GaussDBServerExtension(); public GaussDBConnectionFactory connectionFactory; @@ -51,9 +51,9 @@ protected GaussDBConnectionFactory getConnectionFactory() { * * @return a {@link GaussDBConnectionFactory}. */ - protected GaussDBConnectionFactory getConnectionFactory(Consumer customizer) { + protected GaussDBConnectionFactory getConnectionFactory(Consumer customizer) { - PostgresqlConnectionConfiguration.Builder builder = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration.Builder builder = GaussDBConnectionConfiguration.builder() .database(SERVER.getDatabase()) .host(SERVER.getHost()) .port(SERVER.getPort()) @@ -65,11 +65,11 @@ protected GaussDBConnectionFactory getConnectionFactory(Consumer new PostgresqlBatch(MockContext.empty()).add(null)) + assertThatIllegalArgumentException().isThrownBy(() -> new GaussDBBatch(MockContext.empty()).add(null)) .withMessage("sql must not be null"); } @Test void addWithParameter() { - assertThatIllegalArgumentException().isThrownBy(() -> new PostgresqlBatch(MockContext.empty()).add("test-query-$1")) + assertThatIllegalArgumentException().isThrownBy(() -> new GaussDBBatch(MockContext.empty()).add("test-query-$1")) .withMessage("Statement 'test-query-$1' is not supported. This is often due to the presence of parameters."); } @Test void constructorNoContext() { - assertThatIllegalArgumentException().isThrownBy(() -> new PostgresqlBatch(null)) + assertThatIllegalArgumentException().isThrownBy(() -> new GaussDBBatch(null)) .withMessage("context must not be null"); } @@ -75,7 +75,7 @@ void executeCommandComplete() { .expectRequest(new Query("test-query")).thenRespond(new CommandComplete("test", null, null)) .build(); - new PostgresqlBatch(MockContext.builder().client(client).build()) + new GaussDBBatch(MockContext.builder().client(client).build()) .add("test-query") .execute() .as(StepVerifier::create) @@ -89,7 +89,7 @@ void executeEmptyQueryResponse() { .expectRequest(new Query("test-query")).thenRespond(EmptyQueryResponse.INSTANCE) .build(); - new PostgresqlBatch(MockContext.builder().client(client).build()) + new GaussDBBatch(MockContext.builder().client(client).build()) .add("test-query") .execute() .as(StepVerifier::create) @@ -103,7 +103,7 @@ void executeErrorResponse() { .expectRequest(new Query("test-query")).thenRespond(new ErrorResponse(Collections.emptyList())) .build(); - new PostgresqlBatch(MockContext.builder().client(client).build()) + new GaussDBBatch(MockContext.builder().client(client).build()) .add("test-query") .execute() .flatMap(result -> result.map((row, rowMetadata) -> row)) diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlColumnMetadataUnitTests.java b/src/test/java/io/r2dbc/gaussdb/GaussDBColumnMetadataUnitTests.java similarity index 83% rename from src/test/java/io/r2dbc/gaussdb/PostgresqlColumnMetadataUnitTests.java rename to src/test/java/io/r2dbc/gaussdb/GaussDBColumnMetadataUnitTests.java index 62e6ed76..2bfd709a 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlColumnMetadataUnitTests.java +++ b/src/test/java/io/r2dbc/gaussdb/GaussDBColumnMetadataUnitTests.java @@ -24,9 +24,9 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Unit tests for {@link PostgresqlColumnMetadata}. + * Unit tests for {@link GaussDBColumnMetadata}. */ -final class PostgresqlColumnMetadataUnitTests { +final class GaussDBColumnMetadataUnitTests { @Test void toColumnMetadata() { @@ -34,7 +34,7 @@ void toColumnMetadata() { .preferredType(200, FORMAT_TEXT, String.class) .build(); - PostgresqlColumnMetadata columnMetadata = PostgresqlColumnMetadata.toColumnMetadata(codecs, new Field((short) 100, 200, 300, (short) 400, FORMAT_TEXT, "test-name", 500)); + GaussDBColumnMetadata columnMetadata = GaussDBColumnMetadata.toColumnMetadata(codecs, new Field((short) 100, 200, 300, (short) 400, FORMAT_TEXT, "test-name", 500)); assertThat(columnMetadata.getJavaType()).isEqualTo(String.class); assertThat(columnMetadata.getName()).isEqualTo("test-name"); diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionConfigurationUnitTests.java b/src/test/java/io/r2dbc/gaussdb/GaussDBConnectionConfigurationUnitTests.java similarity index 77% rename from src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionConfigurationUnitTests.java rename to src/test/java/io/r2dbc/gaussdb/GaussDBConnectionConfigurationUnitTests.java index 1b951799..0b40ddeb 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionConfigurationUnitTests.java +++ b/src/test/java/io/r2dbc/gaussdb/GaussDBConnectionConfigurationUnitTests.java @@ -29,43 +29,43 @@ import static org.mockito.Mockito.mock; /** - * Unit tests for {@link PostgresqlConnectionConfiguration}. + * Unit tests for {@link GaussDBConnectionConfiguration}. */ -final class PostgresqlConnectionConfigurationUnitTests { +final class GaussDBConnectionConfigurationUnitTests { @Test void builderNoApplicationName() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder().applicationName(null)) + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder().applicationName(null)) .withMessage("applicationName must not be null"); } @Test void builderNoHostConfiguration() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder().build()) + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder().build()) .withMessage("Connection must be configured for either multi-host or single host connectivity"); } @Test void builderHostAndSocket() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder().host("host").socket("socket").build()) + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder().host("host").socket("socket").build()) .withMessageContaining("Connection must be configured for either host/port or socket usage but not both"); } @Test void builderNoUsername() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder().username((String) null)) + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder().username((String) null)) .withMessage("username must not be null"); } @Test void builderNegativeFetchSize() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder().fetchSize(-1)) + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder().fetchSize(-1)) .withMessage("fetch size must be greater or equal zero"); } @Test void builderNoTcpLoopResources() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder().loopResources(null)) + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder().loopResources(null)) .withMessage("loopResources must not be null"); } @@ -76,7 +76,7 @@ void configuration() { options.put("statement_timeout", "60000"); // [ms] LoopResources loopResources = mock(LoopResources.class); - PostgresqlConnectionConfiguration configuration = getPostgresqlConnectionConfiguration(options, loopResources).build(); + GaussDBConnectionConfiguration configuration = getPostgresqlConnectionConfiguration(options, loopResources).build(); assertThat(configuration) .hasFieldOrPropertyWithValue("applicationName", "test-application-name") @@ -103,7 +103,7 @@ void configureStatementAndLockTimeouts() { options.put("statement_timeout", "60000"); // [ms] LoopResources loopResources = mock(LoopResources.class); - PostgresqlConnectionConfiguration configuration = getPostgresqlConnectionConfiguration(options, loopResources) + GaussDBConnectionConfiguration configuration = getPostgresqlConnectionConfiguration(options, loopResources) .statementTimeout(Duration.ofMillis(5000)) .lockWaitTimeout(Duration.ofSeconds(50)) .build(); @@ -126,8 +126,8 @@ void configureStatementAndLockTimeouts() { .containsEntry("search_path", "test-schema"); } - private PostgresqlConnectionConfiguration.Builder getPostgresqlConnectionConfiguration(Map options, LoopResources loopResources) { - return PostgresqlConnectionConfiguration.builder() + private GaussDBConnectionConfiguration.Builder getPostgresqlConnectionConfiguration(Map options, LoopResources loopResources) { + return GaussDBConnectionConfiguration.builder() .applicationName("test-application-name") .connectTimeout(Duration.ofMillis(1000)) .database("test-database") @@ -144,7 +144,7 @@ private PostgresqlConnectionConfiguration.Builder getPostgresqlConnectionConfigu @Test void configurationDefaults() { - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .database("test-database") .host("test-host") .password("test-password") @@ -156,7 +156,7 @@ void configurationDefaults() { .hasFieldOrPropertyWithValue("applicationName", "r2dbc-gaussdb") .hasFieldOrPropertyWithValue("database", "test-database") .hasFieldOrPropertyWithValue("singleHostConfiguration.host", "test-host") - .hasFieldOrPropertyWithValue("singleHostConfiguration.port", 5432) + .hasFieldOrPropertyWithValue("singleHostConfiguration.port", 8000) .hasFieldOrProperty("options") .hasFieldOrProperty("sslConfig") .hasFieldOrPropertyWithValue("tcpKeepAlive", false) @@ -169,7 +169,7 @@ void configurationDefaults() { @Test void constructorNoUsername() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder() + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder() .host("test-host") .password("test-password") .build()) @@ -178,7 +178,7 @@ void constructorNoUsername() { @Test void constructorNoPassword() { - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .host("test-host") .username("foo") .build(); @@ -188,7 +188,7 @@ void constructorNoPassword() { @Test void constructorInvalidOptions() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder() + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder() .host("test-host") .username("test-username") .password("test-password") @@ -199,7 +199,7 @@ void constructorInvalidOptions() { assertThatIllegalArgumentException().isThrownBy(() -> { final Map options = new HashMap<>(); options.put(null, "test-value"); - PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration.builder() .host("test-host") .username("test-username") .password("test-password") @@ -211,7 +211,7 @@ void constructorInvalidOptions() { assertThatIllegalArgumentException().isThrownBy(() -> { final Map options = new HashMap<>(); options.put("test-option", null); - PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration.builder() .host("test-host") .username("test-username") .password("test-password") @@ -223,7 +223,7 @@ void constructorInvalidOptions() { @Test void constructorNoSslCustomizer() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder() + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder() .sslContextBuilderCustomizer(null) .build()) .withMessage("sslContextBuilderCustomizer must not be null"); @@ -231,7 +231,7 @@ void constructorNoSslCustomizer() { @Test void constructorNoSslCert() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder() + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder() .host("test-host") .password("test-password") .sslCert((String) null) @@ -241,7 +241,7 @@ void constructorNoSslCert() { @Test void constructorNotExistSslCert() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder() + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder() .host("test-host") .username("test-username") .password("test-password") @@ -252,7 +252,7 @@ void constructorNotExistSslCert() { @Test void constructorSslCert() { - PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration.builder() .host("test-host") .username("test-username") .password("test-password") @@ -262,7 +262,7 @@ void constructorSslCert() { @Test void constructorNoSslKey() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder() + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder() .host("test-host") .password("test-password") .sslKey((String) null) @@ -272,7 +272,7 @@ void constructorNoSslKey() { @Test void constructorNotExistSslKey() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder() + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder() .host("test-host") .username("test-username") .password("test-password") @@ -283,7 +283,7 @@ void constructorNotExistSslKey() { @Test void constructorSslKey() { - PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration.builder() .host("test-host") .username("test-username") .password("test-password") @@ -293,7 +293,7 @@ void constructorSslKey() { @Test void constructorNullSslRootCert() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder() + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder() .host("test-host") .password("test-password") .sslRootCert((String) null) @@ -303,7 +303,7 @@ void constructorNullSslRootCert() { @Test void constructorNotExistSslRootCert() { - assertThatIllegalArgumentException().isThrownBy(() -> PostgresqlConnectionConfiguration.builder() + assertThatIllegalArgumentException().isThrownBy(() -> GaussDBConnectionConfiguration.builder() .host("test-host") .password("test-password") .sslRootCert("no-server.crt") @@ -313,7 +313,7 @@ void constructorNotExistSslRootCert() { @Test void constructorSslRootCert() { - PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration.builder() .host("test-host") .username("test-username") .password("test-password") diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryMetadataUnitTests.java b/src/test/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryMetadataUnitTests.java similarity index 75% rename from src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryMetadataUnitTests.java rename to src/test/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryMetadataUnitTests.java index 37fb5ee2..148e5cfe 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryMetadataUnitTests.java +++ b/src/test/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryMetadataUnitTests.java @@ -21,13 +21,13 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Unit tests for {@link PostgresqlConnectionFactoryMetadata}. + * Unit tests for {@link GaussDBConnectionFactoryMetadata}. */ -final class PostgresqlConnectionFactoryMetadataUnitTests { +final class GaussDBConnectionFactoryMetadataUnitTests { @Test void name() { - assertThat(PostgresqlConnectionFactoryMetadata.INSTANCE.getName()).isEqualTo(PostgresqlConnectionFactoryMetadata.NAME); + assertThat(GaussDBConnectionFactoryMetadata.INSTANCE.getName()).isEqualTo(GaussDBConnectionFactoryMetadata.NAME); } } diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryProviderUnitTests.java b/src/test/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryProviderUnitTests.java similarity index 81% rename from src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryProviderUnitTests.java rename to src/test/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryProviderUnitTests.java index 08531cd3..a6aff013 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryProviderUnitTests.java +++ b/src/test/java/io/r2dbc/gaussdb/GaussDBConnectionFactoryProviderUnitTests.java @@ -39,33 +39,32 @@ import java.util.TimeZone; import java.util.function.Supplier; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.AUTODETECT_EXTENSIONS; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.COMPATIBILITY_MODE; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.ERROR_RESPONSE_LOG_LEVEL; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.EXTENSIONS; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.FAILOVER_PROTOCOL; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.FETCH_SIZE; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.FORCE_BINARY; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.HOST_RECHECK_TIME; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.LEGACY_POSTGRESQL_DRIVER; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.LOAD_BALANCE_HOSTS; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.LOCK_WAIT_TIMEOUT; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.OPTIONS; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.POSTGRESQL_DRIVER; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.PREFER_ATTACHED_BUFFERS; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.PREPARED_STATEMENT_CACHE_QUERIES; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.SOCKET; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.SSL_CERT; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.SSL_CONTEXT_BUILDER_CUSTOMIZER; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.SSL_KEY; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.SSL_MODE; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.SSL_ROOT_CERT; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.SSL_SNI; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.STATEMENT_TIMEOUT; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.TARGET_SERVER_TYPE; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.TCP_KEEPALIVE; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.TCP_NODELAY; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.TIME_ZONE; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.AUTODETECT_EXTENSIONS; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.COMPATIBILITY_MODE; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.ERROR_RESPONSE_LOG_LEVEL; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.EXTENSIONS; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.FAILOVER_PROTOCOL; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.FETCH_SIZE; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.FORCE_BINARY; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.GAUSSDB_DRIVER; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.HOST_RECHECK_TIME; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.LOAD_BALANCE_HOSTS; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.LOCK_WAIT_TIMEOUT; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.OPTIONS; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.PREFER_ATTACHED_BUFFERS; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.PREPARED_STATEMENT_CACHE_QUERIES; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.SOCKET; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.SSL_CERT; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.SSL_CONTEXT_BUILDER_CUSTOMIZER; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.SSL_KEY; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.SSL_MODE; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.SSL_ROOT_CERT; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.SSL_SNI; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.STATEMENT_TIMEOUT; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.TARGET_SERVER_TYPE; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.TCP_KEEPALIVE; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.TCP_NODELAY; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.TIME_ZONE; import static io.r2dbc.spi.ConnectionFactoryOptions.DRIVER; import static io.r2dbc.spi.ConnectionFactoryOptions.HOST; import static io.r2dbc.spi.ConnectionFactoryOptions.PASSWORD; @@ -78,11 +77,11 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; /** - * Unit tests for {@link PostgresqlConnectionFactoryProvider}. + * Unit tests for {@link GaussDBConnectionFactoryProvider}. */ -final class PostgresqlConnectionFactoryProviderUnitTests { +final class GaussDBConnectionFactoryProviderUnitTests { - private final PostgresqlConnectionFactoryProvider provider = new PostgresqlConnectionFactoryProvider(); + private final GaussDBConnectionFactoryProvider provider = new GaussDBConnectionFactoryProvider(); @Test void doesNotSupportWithWrongDriver() { @@ -106,7 +105,7 @@ void doesNotSupportWithoutDriver() { @Test void createFailsWithoutHost() { assertThatThrownBy(() -> this.provider.create(ConnectionFactoryOptions.builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(PASSWORD, "test-password") .option(USER, "test-user") .build())).isInstanceOf(IllegalStateException.class); @@ -115,7 +114,7 @@ void createFailsWithoutHost() { @Test void supportsWithoutHost() { assertThat(this.provider.supports(ConnectionFactoryOptions.builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(PASSWORD, "test-password") .option(USER, "test-user") .build())).isTrue(); @@ -124,7 +123,7 @@ void supportsWithoutHost() { @Test void supportsWithoutPassword() { assertThat(this.provider.supports(ConnectionFactoryOptions.builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(USER, "test-user") .build())).isTrue(); @@ -132,23 +131,13 @@ void supportsWithoutPassword() { @Test void returnsDriverIdentifier() { - assertThat(this.provider.getDriver()).isEqualTo(POSTGRESQL_DRIVER); + assertThat(this.provider.getDriver()).isEqualTo(GAUSSDB_DRIVER); } @Test void supports() { assertThat(this.provider.supports(ConnectionFactoryOptions.builder() - .option(DRIVER, POSTGRESQL_DRIVER) - .option(HOST, "test-host") - .option(PASSWORD, "test-password") - .option(USER, "test-user") - .build())).isTrue(); - } - - @Test - void supportsPostgresDriver() { - assertThat(this.provider.supports(ConnectionFactoryOptions.builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -158,7 +147,7 @@ void supportsPostgresDriver() { @Test void supportsWithoutUser() { assertThat(this.provider.supports(ConnectionFactoryOptions.builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .build())).isTrue(); @@ -167,7 +156,7 @@ void supportsWithoutUser() { @Test void disableSsl() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -182,7 +171,7 @@ void disableSsl() { @Test void enableSsl() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -197,7 +186,7 @@ void enableSsl() { @Test void supportsSslCertificates() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -213,7 +202,7 @@ void supportsSslCertificates() { @Test void supportsSslCertificatesByClasspath() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -229,7 +218,7 @@ void supportsSslCertificatesByClasspath() { @Test void supportsSslMode() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -244,7 +233,7 @@ void supportsSslMode() { @Test void supportsSslModeAlias() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -259,7 +248,7 @@ void supportsSslModeAlias() { @Test void shouldCreateConnectionFactoryWithoutPassword() { assertThat(this.provider.create(ConnectionFactoryOptions.builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(USER, "test-user") .build())).isNotNull(); @@ -268,7 +257,7 @@ void shouldCreateConnectionFactoryWithoutPassword() { @Test void providerShouldConsiderFetchSize() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -281,7 +270,7 @@ void providerShouldConsiderFetchSize() { @Test void providerShouldConsiderFetchSizeAsString() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -294,7 +283,7 @@ void providerShouldConsiderFetchSizeAsString() { @Test void providerShouldConsiderBinaryTransfer() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -307,7 +296,7 @@ void providerShouldConsiderBinaryTransfer() { @Test void providerShouldConsiderBinaryTransferWhenProvidedAsString() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -320,7 +309,7 @@ void providerShouldConsiderBinaryTransferWhenProvidedAsString() { @Test void providerShouldConsiderCompatibilityMode() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -333,7 +322,7 @@ void providerShouldConsiderCompatibilityMode() { @Test void providerShouldConsiderPreparedStatementCacheQueries() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -346,7 +335,7 @@ void providerShouldConsiderPreparedStatementCacheQueries() { @Test void providerShouldConsiderPreparedStatementCacheQueriesWhenProvidedAsString() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -362,7 +351,7 @@ void providerShouldParseAndHandleConnectionParameters() { expectedOptions.put("lock_timeout", "5s"); expectedOptions.put("statement_timeout", "6000"); GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -381,7 +370,7 @@ void providerShouldParseAndHandleLockStatementTimeouts() { expectedOptions.put("lock_timeout", "5000"); expectedOptions.put("statement_timeout", "6000"); GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -398,7 +387,7 @@ void providerShouldParseAndHandleLockStatementTimeouts() { @Test void shouldConfigureAutodetectExtensions() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -408,7 +397,7 @@ void shouldConfigureAutodetectExtensions() { assertThat(factory.getConfiguration().isAutodetectExtensions()).isTrue(); factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -421,7 +410,7 @@ void shouldConfigureAutodetectExtensions() { @Test void shouldConfigureLogLevels() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -438,7 +427,7 @@ void shouldConfigureLogLevels() { void shouldApplySslContextBuilderCustomizer() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -459,7 +448,7 @@ void shouldApplySslContextBuilderCustomizer() { void shouldApplySslSni() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -476,7 +465,7 @@ void shouldApplySslSni() { void shouldConfigureTcpKeepAlive() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -490,7 +479,7 @@ void shouldConfigureTcpKeepAlive() { void shouldConfigureTcpNoDelay() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -504,7 +493,7 @@ void shouldConfigureTcpNoDelay() { void shouldConfigureTimeZone() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -518,7 +507,7 @@ void shouldConfigureTimeZone() { void shouldConfigureTimeZoneAsString() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -532,21 +521,21 @@ void shouldConfigureTimeZoneAsString() { void shouldConnectUsingUnixDomainSocket() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) - .option(SOCKET, "/tmp/.s.PGSQL.5432") + .option(DRIVER, GAUSSDB_DRIVER) + .option(SOCKET, "/tmp/.s.PGSQL.8000") .option(USER, "postgres") .build()); assertThat(factory.getConfiguration().getSingleHostConfiguration().isUseSocket()).isTrue(); - assertThat(factory.getConfiguration().getSingleHostConfiguration().getRequiredSocket()).isEqualTo("/tmp/.s.PGSQL.5432"); + assertThat(factory.getConfiguration().getSingleHostConfiguration().getRequiredSocket()).isEqualTo("/tmp/.s.PGSQL.8000"); } @Test void shouldConnectUsingMultiHostConfiguration() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(PROTOCOL, FAILOVER_PROTOCOL) - .option(HOST, "host1:5433,host2:5432,host3") + .option(HOST, "host1:8001,host2:8000,host3") .option(USER, "postgres") .option(LOAD_BALANCE_HOSTS, true) .option(HOST_RECHECK_TIME, Duration.ofMillis(20000)) @@ -559,14 +548,14 @@ void shouldConnectUsingMultiHostConfiguration() { assertThat(factory.getConfiguration().getMultiHostConfiguration().getTargetServerType()).isEqualTo(MultiHostConnectionStrategy.TargetServerType.SECONDARY); List hosts = factory.getConfiguration().getMultiHostConfiguration().getHosts(); assertThat(hosts).hasSize(3); - assertThat(hosts.get(0)).usingRecursiveComparison().isEqualTo(new ServerHost("host1", 5433)); - assertThat(hosts.get(1)).usingRecursiveComparison().isEqualTo(new ServerHost("host2", 5432)); - assertThat(hosts.get(2)).usingRecursiveComparison().isEqualTo(new ServerHost("host3", 5432)); + assertThat(hosts.get(0)).usingRecursiveComparison().isEqualTo(new ServerHost("host1", 8001)); + assertThat(hosts.get(1)).usingRecursiveComparison().isEqualTo(new ServerHost("host2", 8000)); + assertThat(hosts.get(2)).usingRecursiveComparison().isEqualTo(new ServerHost("host3", 8000)); } @Test void shouldConnectUsingMultiHostConfigurationFromUrl() { - GaussDBConnectionFactory factory = this.provider.create(ConnectionFactoryOptions.parse("r2dbc:gaussdb:failover://user:foo@host1:5433,host2:5432,host3" + + GaussDBConnectionFactory factory = this.provider.create(ConnectionFactoryOptions.parse("r2dbc:gaussdb:failover://user:foo@host1:8001,host2:8000,host3" + "?loadBalanceHosts=true&hostRecheckTime=20s&targetServerType=SECONdArY")); assertThat(factory.getConfiguration().getSingleHostConfiguration()).isNull(); @@ -577,14 +566,14 @@ void shouldConnectUsingMultiHostConfigurationFromUrl() { assertThat(config.getTargetServerType()).isEqualTo(MultiHostConnectionStrategy.TargetServerType.SECONDARY); List hosts = config.getHosts(); - assertThat(hosts).hasSize(3).containsExactly(new ServerHost("host1", 5433), new ServerHost("host2", 5432), new ServerHost("host3", 5432)); + assertThat(hosts).hasSize(3).containsExactly(new ServerHost("host1", 8001), new ServerHost("host2", 8000), new ServerHost("host3", 8000)); } @Test void shouldParseOptionsProvidedAsString() { Option options = Option.valueOf("options"); GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -604,7 +593,7 @@ void shouldParseOptionsProvidedAsMap() { optionsMap.put("default_tablespace", "unknown"); GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -619,7 +608,7 @@ void shouldParseOptionsProvidedAsMap() { void shouldConfigurePreferAttachedBuffers() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -634,7 +623,7 @@ void shouldConfigureExtensions() { TestExtension testExtension1 = new TestExtension("extension-1"); TestExtension testExtension2 = new TestExtension("extension-2"); GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(PASSWORD, "test-password") .option(USER, "test-user") @@ -647,7 +636,7 @@ void shouldConfigureExtensions() { @Test void supportsUsernameAndPasswordSupplier() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(Option.valueOf("password"), (Supplier) () -> "test-password") .option(Option.valueOf("user"), (Supplier) () -> "test-user") @@ -661,7 +650,7 @@ void supportsUsernameAndPasswordSupplier() { @Test void supportsUsernameAndPasswordPublisher() { GaussDBConnectionFactory factory = this.provider.create(builder() - .option(DRIVER, LEGACY_POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(HOST, "test-host") .option(Option.valueOf("password"), Mono.just("test-password")) .option(Option.valueOf("user"), Mono.just("test-user")) diff --git a/src/test/java/io/r2dbc/gaussdb/MockContext.java b/src/test/java/io/r2dbc/gaussdb/MockContext.java index 504997f4..5ad96f38 100644 --- a/src/test/java/io/r2dbc/gaussdb/MockContext.java +++ b/src/test/java/io/r2dbc/gaussdb/MockContext.java @@ -54,7 +54,7 @@ private Builder() { } public ConnectionResources build() { - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .host("localhost") .username("admin") .password("password") diff --git a/src/test/java/io/r2dbc/gaussdb/PgBouncerIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/PgBouncerIntegrationTests.java index e4e70819..b01fb711 100644 --- a/src/test/java/io/r2dbc/gaussdb/PgBouncerIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/PgBouncerIntegrationTests.java @@ -17,7 +17,7 @@ package io.r2dbc.gaussdb; import io.r2dbc.gaussdb.util.PgBouncer; -import io.r2dbc.gaussdb.util.PostgresqlServerExtension; +import io.r2dbc.gaussdb.util.GaussDBServerExtension; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -30,7 +30,7 @@ final class PgBouncerIntegrationTests { @RegisterExtension - static final PostgresqlServerExtension SERVER = new PostgresqlServerExtension(); + static final GaussDBServerExtension SERVER = new GaussDBServerExtension(); @ParameterizedTest @ValueSource(strings = {"transaction", "statement"}) @@ -71,7 +71,7 @@ void sessionModeWorksWithAllCaches(int statementCacheSize) { } private GaussDBConnectionFactory createConnectionFactory(PgBouncer pgBouncer, int statementCacheSize) { - return new GaussDBConnectionFactory(PostgresqlConnectionConfiguration.builder() + return new GaussDBConnectionFactory(GaussDBConnectionConfiguration.builder() .host(pgBouncer.getHost()) .port(pgBouncer.getPort()) .username(SERVER.getUsername()) diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlAuthenticationFailureIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/PostgresqlAuthenticationFailureIntegrationTests.java index 55e4d429..3f313f77 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlAuthenticationFailureIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/PostgresqlAuthenticationFailureIntegrationTests.java @@ -16,7 +16,7 @@ package io.r2dbc.gaussdb; -import io.r2dbc.gaussdb.util.PostgresqlServerExtension; +import io.r2dbc.gaussdb.util.GaussDBServerExtension; import io.r2dbc.spi.ConnectionFactories; import io.r2dbc.spi.ConnectionFactory; import io.r2dbc.spi.ConnectionFactoryOptions; @@ -25,7 +25,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import reactor.core.publisher.Mono; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.POSTGRESQL_DRIVER; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.GAUSSDB_DRIVER; import static io.r2dbc.spi.ConnectionFactoryOptions.DATABASE; import static io.r2dbc.spi.ConnectionFactoryOptions.DRIVER; import static io.r2dbc.spi.ConnectionFactoryOptions.HOST; @@ -40,12 +40,12 @@ final class PostgresqlAuthenticationFailureIntegrationTests { @RegisterExtension - static final PostgresqlServerExtension SERVER = new PostgresqlServerExtension(); + static final GaussDBServerExtension SERVER = new GaussDBServerExtension(); @Test void authExceptionCausedByWrongCredentials() { final ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(DATABASE, SERVER.getDatabase()) .option(HOST, SERVER.getHost()) .option(PORT, SERVER.getPort()) diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryUnitTests.java b/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryUnitTests.java index 41bd7e54..06a4519c 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryUnitTests.java +++ b/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionFactoryUnitTests.java @@ -64,7 +64,7 @@ void createAuthenticationMD5Password() { .build(); // @formatter:on - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .applicationName("test-application-name") .database("test-database") .host("test-host") @@ -96,7 +96,7 @@ void createAuthenticationSASL() { .build(); // @formatter:on - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .applicationName("test-application-name") .database("test-database") .host("test-host") @@ -115,7 +115,7 @@ void createError() { .build(); // @formatter:on - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .applicationName("test-application-name") .database("test-database") .host("test-host") @@ -139,7 +139,7 @@ void getMetadata() { .build(); // @formatter:on - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .applicationName("test-application-name") .database("test-database") .host("test-host") @@ -150,7 +150,7 @@ void getMetadata() { assertThat(new GaussDBConnectionFactory(testClientFactory(client, configuration), configuration).getMetadata()).isNotNull(); } - private ConnectionFunction testClientFactory(Client client, PostgresqlConnectionConfiguration configuration) { + private ConnectionFunction testClientFactory(Client client, GaussDBConnectionConfiguration configuration) { return new SingleHostConnectionFunction((endpoint, settings) -> Mono.just(client), configuration); } diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionRuntimeOptionsIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionRuntimeOptionsIntegrationTests.java index bd63d05d..87ccfa17 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionRuntimeOptionsIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionRuntimeOptionsIntegrationTests.java @@ -1,6 +1,6 @@ package io.r2dbc.gaussdb; -import io.r2dbc.gaussdb.util.PostgresqlServerExtension; +import io.r2dbc.gaussdb.util.GaussDBServerExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import reactor.test.StepVerifier; @@ -15,7 +15,7 @@ final class PostgresqlConnectionRuntimeOptionsIntegrationTests { @RegisterExtension - static final PostgresqlServerExtension SERVER = new PostgresqlServerExtension(); + static final GaussDBServerExtension SERVER = new GaussDBServerExtension(); private static final Map options = new HashMap<>(); @@ -24,7 +24,7 @@ final class PostgresqlConnectionRuntimeOptionsIntegrationTests { options.put("statement_timeout", "60s"); } - private final PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + private final GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .database(SERVER.getDatabase()) .host(SERVER.getHost()) .port(SERVER.getPort()) diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionUnitTests.java b/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionUnitTests.java index bdab7f87..567729a1 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionUnitTests.java +++ b/src/test/java/io/r2dbc/gaussdb/PostgresqlConnectionUnitTests.java @@ -200,7 +200,7 @@ void constructorNoStatementCache() { @Test void createBatch() { - assertThat(createConnection(NO_OP, MockCodecs.empty(), this.statementCache).createBatch()).isInstanceOf(PostgresqlBatch.class); + assertThat(createConnection(NO_OP, MockCodecs.empty(), this.statementCache).createBatch()).isInstanceOf(GaussDBBatch.class); } @Test @@ -559,7 +559,7 @@ void setLockTimeout() { } private GaussDBConnection createConnection(Client client, MockCodecs codecs, StatementCache cache) { - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .host("127.0.0.1") .username("admin") .password("password") diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlCopyInIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/PostgresqlCopyInIntegrationTests.java index 361382d1..2917c1ee 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlCopyInIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/PostgresqlCopyInIntegrationTests.java @@ -58,7 +58,7 @@ private JdbcOperations getJdbcOperations() { } @Override - protected void customize(PostgresqlConnectionConfiguration.Builder builder) { + protected void customize(GaussDBConnectionConfiguration.Builder builder) { builder.preparedStatementCacheQueries(2); } diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlRowMetadataUnitTests.java b/src/test/java/io/r2dbc/gaussdb/PostgresqlRowMetadataUnitTests.java index b4a621fc..07f28108 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlRowMetadataUnitTests.java +++ b/src/test/java/io/r2dbc/gaussdb/PostgresqlRowMetadataUnitTests.java @@ -37,9 +37,9 @@ */ final class PostgresqlRowMetadataUnitTests { - private final List columnMetadatas = Arrays.asList( - new PostgresqlColumnMetadata(MockCodecs.empty(), "test-name-2", 400, (short) 300), - new PostgresqlColumnMetadata(MockCodecs.empty(), "test-name-1", 200, (short) 100) + private final List columnMetadatas = Arrays.asList( + new GaussDBColumnMetadata(MockCodecs.empty(), "test-name-2", 400, (short) 300), + new GaussDBColumnMetadata(MockCodecs.empty(), "test-name-1", 200, (short) 100) ); @Test @@ -51,7 +51,7 @@ void constructorNoColumnMetadata() { @Test void getColumnMetadataIndex() { assertThat(new PostgresqlRowMetadata(this.columnMetadatas).getColumnMetadata(0)) - .isEqualTo(new PostgresqlColumnMetadata(MockCodecs.empty(), "test-name-2", 400, (short) 300)); + .isEqualTo(new GaussDBColumnMetadata(MockCodecs.empty(), "test-name-2", 400, (short) 300)); } @Test @@ -69,7 +69,7 @@ void getColumnMetadataInvalidName() { @Test void getColumnMetadataName() { assertThat(new PostgresqlRowMetadata(this.columnMetadatas).getColumnMetadata("test-name-2")) - .isEqualTo(new PostgresqlColumnMetadata(MockCodecs.empty(), "test-name-2", 400, (short) 300)); + .isEqualTo(new GaussDBColumnMetadata(MockCodecs.empty(), "test-name-2", 400, (short) 300)); } @Test @@ -94,10 +94,10 @@ void getColumnNames() { @Test void getColumnNamesRetainsOrdering() { - List columnMetadatas = Arrays.asList( - new PostgresqlColumnMetadata(MockCodecs.empty(), "id", 400, (short) 300), - new PostgresqlColumnMetadata(MockCodecs.empty(), "age", 200, (short) 100), - new PostgresqlColumnMetadata(MockCodecs.empty(), "name", 200, (short) 100) + List columnMetadatas = Arrays.asList( + new GaussDBColumnMetadata(MockCodecs.empty(), "id", 400, (short) 300), + new GaussDBColumnMetadata(MockCodecs.empty(), "age", 200, (short) 100), + new GaussDBColumnMetadata(MockCodecs.empty(), "name", 200, (short) 100) ); Collection columnNames = new PostgresqlRowMetadata(columnMetadatas); @@ -108,10 +108,10 @@ void getColumnNamesRetainsOrdering() { @Test void getColumnNamesRetainsMayContainDuplicates() { - List columnMetadatas = Arrays.asList( - new PostgresqlColumnMetadata(MockCodecs.empty(), "age", 200, (short) 100), - new PostgresqlColumnMetadata(MockCodecs.empty(), "name", 200, (short) 100), - new PostgresqlColumnMetadata(MockCodecs.empty(), "age", 200, (short) 100) + List columnMetadatas = Arrays.asList( + new GaussDBColumnMetadata(MockCodecs.empty(), "age", 200, (short) 100), + new GaussDBColumnMetadata(MockCodecs.empty(), "name", 200, (short) 100), + new GaussDBColumnMetadata(MockCodecs.empty(), "age", 200, (short) 100) ); Collection columnNames = new PostgresqlRowMetadata(columnMetadatas); diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlRowUnitTests.java b/src/test/java/io/r2dbc/gaussdb/PostgresqlRowUnitTests.java index 5aee6070..f348482f 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlRowUnitTests.java +++ b/src/test/java/io/r2dbc/gaussdb/PostgresqlRowUnitTests.java @@ -55,7 +55,7 @@ final class PostgresqlRowUnitTests { private final PostgresqlRowMetadata metadata = new PostgresqlRowMetadata(columns .stream() - .map(field -> PostgresqlColumnMetadata.toColumnMetadata(mock(Codecs.class), field)) + .map(field -> GaussDBColumnMetadata.toColumnMetadata(mock(Codecs.class), field)) .collect(Collectors.toList())); private final ByteBuf[] data = new ByteBuf[]{TEST.buffer(4).writeInt(100), TEST.buffer(4).writeInt(300), null}; diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlStatementIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/PostgresqlStatementIntegrationTests.java index 24f2bf5b..3bb71c32 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlStatementIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/PostgresqlStatementIntegrationTests.java @@ -50,7 +50,7 @@ private JdbcOperations getJdbcOperations() { } @Override - protected void customize(PostgresqlConnectionConfiguration.Builder builder) { + protected void customize(GaussDBConnectionConfiguration.Builder builder) { builder.preparedStatementCacheQueries(2); } diff --git a/src/test/java/io/r2dbc/gaussdb/PostgresqlTestKit.java b/src/test/java/io/r2dbc/gaussdb/PostgresqlTestKit.java index c4abfb98..a388cc86 100644 --- a/src/test/java/io/r2dbc/gaussdb/PostgresqlTestKit.java +++ b/src/test/java/io/r2dbc/gaussdb/PostgresqlTestKit.java @@ -16,7 +16,7 @@ package io.r2dbc.gaussdb; -import io.r2dbc.gaussdb.util.PostgresqlServerExtension; +import io.r2dbc.gaussdb.util.GaussDBServerExtension; import io.r2dbc.spi.ConnectionFactories; import io.r2dbc.spi.ConnectionFactory; import io.r2dbc.spi.ConnectionFactoryOptions; @@ -24,7 +24,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.jdbc.core.JdbcOperations; -import static io.r2dbc.gaussdb.PostgresqlConnectionFactoryProvider.POSTGRESQL_DRIVER; +import static io.r2dbc.gaussdb.GaussDBConnectionFactoryProvider.GAUSSDB_DRIVER; import static io.r2dbc.spi.ConnectionFactoryOptions.DATABASE; import static io.r2dbc.spi.ConnectionFactoryOptions.DRIVER; import static io.r2dbc.spi.ConnectionFactoryOptions.HOST; @@ -38,10 +38,10 @@ final class PostgresqlTestKit implements TestKit { @RegisterExtension - static final PostgresqlServerExtension SERVER = new PostgresqlServerExtension(); + static final GaussDBServerExtension SERVER = new GaussDBServerExtension(); private final ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder() - .option(DRIVER, POSTGRESQL_DRIVER) + .option(DRIVER, GAUSSDB_DRIVER) .option(DATABASE, SERVER.getDatabase()) .option(HOST, SERVER.getHost()) .option(PORT, SERVER.getPort()) diff --git a/src/test/java/io/r2dbc/gaussdb/TemporalCodecBinaryIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/TemporalCodecBinaryIntegrationTests.java index 2ea20d2b..3c151655 100644 --- a/src/test/java/io/r2dbc/gaussdb/TemporalCodecBinaryIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/TemporalCodecBinaryIntegrationTests.java @@ -22,7 +22,7 @@ public class TemporalCodecBinaryIntegrationTests extends AbstractTemporalCodecIntegrationTests { @Override - protected void customize(PostgresqlConnectionConfiguration.Builder builder) { + protected void customize(GaussDBConnectionConfiguration.Builder builder) { super.customize(builder); builder.forceBinary(true); } diff --git a/src/test/java/io/r2dbc/gaussdb/VectorIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/VectorIntegrationTests.java index 08ef95be..d0574ae8 100644 --- a/src/test/java/io/r2dbc/gaussdb/VectorIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/VectorIntegrationTests.java @@ -54,7 +54,7 @@ void setUp() { } @Override - protected void customize(PostgresqlConnectionConfiguration.Builder builder) { + protected void customize(GaussDBConnectionConfiguration.Builder builder) { builder.forceBinary(true); super.customize(builder); } diff --git a/src/test/java/io/r2dbc/gaussdb/api/MockGaussDBConnection.java b/src/test/java/io/r2dbc/gaussdb/api/MockGaussDBConnection.java index f62d4296..91d8fe1e 100644 --- a/src/test/java/io/r2dbc/gaussdb/api/MockGaussDBConnection.java +++ b/src/test/java/io/r2dbc/gaussdb/api/MockGaussDBConnection.java @@ -58,7 +58,7 @@ public CopyInBuilder copyIn(String sql) { } @Override - public PostgresqlBatch createBatch() { + public GaussDBBatch createBatch() { return null; } diff --git a/src/test/java/io/r2dbc/gaussdb/client/DowntimeIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/client/DowntimeIntegrationTests.java index 03993727..5201fae5 100644 --- a/src/test/java/io/r2dbc/gaussdb/client/DowntimeIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/client/DowntimeIntegrationTests.java @@ -16,7 +16,7 @@ package io.r2dbc.gaussdb.client; -import io.r2dbc.gaussdb.PostgresqlConnectionConfiguration; +import io.r2dbc.gaussdb.GaussDBConnectionConfiguration; import io.r2dbc.gaussdb.GaussDBConnectionFactory; import io.r2dbc.gaussdb.api.PostgresqlException; import org.junit.jupiter.api.Test; @@ -64,7 +64,7 @@ static DisposableServer newServer() { static GaussDBConnectionFactory newConnectionFactory(DisposableServer server, SSLMode sslMode) { return new GaussDBConnectionFactory( - PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration.builder() .host(server.host()) .port(server.port()) .username("test") diff --git a/src/test/java/io/r2dbc/gaussdb/client/HighAvailabilityClusterIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/client/HighAvailabilityClusterIntegrationTests.java index a2455079..c8746d4d 100644 --- a/src/test/java/io/r2dbc/gaussdb/client/HighAvailabilityClusterIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/client/HighAvailabilityClusterIntegrationTests.java @@ -17,7 +17,7 @@ package io.r2dbc.gaussdb.client; import io.r2dbc.gaussdb.MultiHostConnectionStrategy; -import io.r2dbc.gaussdb.PostgresqlConnectionConfiguration; +import io.r2dbc.gaussdb.GaussDBConnectionConfiguration; import io.r2dbc.gaussdb.GaussDBConnectionFactory; import io.r2dbc.gaussdb.api.GaussDBConnection; import io.r2dbc.gaussdb.util.PostgresqlHighAvailabilityClusterExtension; @@ -191,11 +191,11 @@ private Mono isPrimary(GaussDBConnection connection) { private GaussDBConnectionFactory multiHostConnectionFactory(MultiHostConnectionStrategy.TargetServerType targetServerType, PostgreSQLContainer... servers) { PostgreSQLContainer firstServer = servers[0]; - PostgresqlConnectionConfiguration.Builder builder = PostgresqlConnectionConfiguration.builder(); + GaussDBConnectionConfiguration.Builder builder = GaussDBConnectionConfiguration.builder(); for (PostgreSQLContainer server : servers) { - builder.addHost(server.getHost(), server.getMappedPort(5432)); + builder.addHost(server.getHost(), server.getMappedPort(8000)); } - PostgresqlConnectionConfiguration configuration = builder + GaussDBConnectionConfiguration configuration = builder .targetServerType(targetServerType) .username(firstServer.getUsername()) .password(firstServer.getPassword()) diff --git a/src/test/java/io/r2dbc/gaussdb/client/ReactorNettyClientIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/client/ReactorNettyClientIntegrationTests.java index 624b0e18..a8534c62 100644 --- a/src/test/java/io/r2dbc/gaussdb/client/ReactorNettyClientIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/client/ReactorNettyClientIntegrationTests.java @@ -19,7 +19,7 @@ import io.netty.channel.epoll.Epoll; import io.netty.channel.kqueue.KQueue; import io.netty.util.ReferenceCountUtil; -import io.r2dbc.gaussdb.PostgresqlConnectionConfiguration; +import io.r2dbc.gaussdb.GaussDBConnectionConfiguration; import io.r2dbc.gaussdb.GaussDBConnectionFactory; import io.r2dbc.gaussdb.api.GaussDBConnection; import io.r2dbc.gaussdb.authentication.PasswordAuthenticationHandler; @@ -30,7 +30,7 @@ import io.r2dbc.gaussdb.message.backend.RowDescription; import io.r2dbc.gaussdb.message.frontend.FrontendMessage; import io.r2dbc.gaussdb.message.frontend.Query; -import io.r2dbc.gaussdb.util.PostgresqlServerExtension; +import io.r2dbc.gaussdb.util.GaussDBServerExtension; import io.r2dbc.spi.R2dbcNonTransientResourceException; import io.r2dbc.spi.R2dbcPermissionDeniedException; import org.junit.jupiter.api.AfterEach; @@ -76,7 +76,7 @@ final class ReactorNettyClientIntegrationTests { @RegisterExtension - static final PostgresqlServerExtension SERVER = new PostgresqlServerExtension(); + static final GaussDBServerExtension SERVER = new GaussDBServerExtension(); static final Field CONNECTION = ReflectionUtils.findField(ReactorNettyClient.class, "connection"); @@ -293,7 +293,7 @@ void parallelExchange() { @Test void timeoutTest() { - GaussDBConnectionFactory gaussDBConnectionFactory = new GaussDBConnectionFactory(PostgresqlConnectionConfiguration.builder() + GaussDBConnectionFactory gaussDBConnectionFactory = new GaussDBConnectionFactory(GaussDBConnectionConfiguration.builder() .host("example.com") .port(81) .username("test") @@ -313,12 +313,12 @@ void timeoutTest() { @DisabledOnOs(OS.WINDOWS) void unixDomainSocketTest() { - String socket = "/tmp/.s.PGSQL.5432"; + String socket = "/tmp/.s.PGSQL.8000"; assumeThat(KQueue.isAvailable() || Epoll.isAvailable()).describedAs("EPoll or KQueue must be available").isTrue(); assumeThat(new File(socket)).exists(); - GaussDBConnectionFactory gaussDBConnectionFactory = new GaussDBConnectionFactory(PostgresqlConnectionConfiguration.builder() + GaussDBConnectionFactory gaussDBConnectionFactory = new GaussDBConnectionFactory(GaussDBConnectionConfiguration.builder() .socket(socket) .username("postgres") .database(SERVER.getDatabase()) @@ -337,7 +337,7 @@ void unixDomainSocketTest() { @Test @Timeout(10) void queryNeverCompletes() { - GaussDBConnectionFactory connectionFactory = new GaussDBConnectionFactory(PostgresqlConnectionConfiguration.builder() + GaussDBConnectionFactory connectionFactory = new GaussDBConnectionFactory(GaussDBConnectionConfiguration.builder() .host(SERVER.getHost()) .port(SERVER.getPort()) .username(SERVER.getUsername()) @@ -401,7 +401,7 @@ void scramAuthenticationFailed() { } private GaussDBConnectionFactory createConnectionFactory(String username, String password) { - return new GaussDBConnectionFactory(PostgresqlConnectionConfiguration.builder() + return new GaussDBConnectionFactory(GaussDBConnectionConfiguration.builder() .host(SERVER.getHost()) .port(SERVER.getPort()) .username(username) @@ -515,9 +515,9 @@ void userIsNotAllowedToLoginWithoutSsl() { .verifyError(R2dbcPermissionDeniedException.class)); } - private void client(Function configurer, + private void client(Function configurer, Consumer> connectionConsumer) { - PostgresqlConnectionConfiguration.Builder defaultConfig = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration.Builder defaultConfig = GaussDBConnectionConfiguration.builder() .database(SERVER.getDatabase()) .host(SERVER.getHost()) .port(SERVER.getPort()) diff --git a/src/test/java/io/r2dbc/gaussdb/codec/EnumCodecIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/codec/EnumCodecIntegrationTests.java index 2c21380b..2111c089 100644 --- a/src/test/java/io/r2dbc/gaussdb/codec/EnumCodecIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/codec/EnumCodecIntegrationTests.java @@ -17,7 +17,7 @@ package io.r2dbc.gaussdb.codec; import io.r2dbc.gaussdb.AbstractIntegrationTests; -import io.r2dbc.gaussdb.PostgresqlConnectionConfiguration; +import io.r2dbc.gaussdb.GaussDBConnectionConfiguration; import io.r2dbc.gaussdb.GaussDBConnectionFactory; import io.r2dbc.gaussdb.api.GaussDBConnection; import io.r2dbc.gaussdb.api.PostgresqlResult; @@ -50,14 +50,14 @@ static void createEnum() { } @Override - protected void customize(PostgresqlConnectionConfiguration.Builder builder) { + protected void customize(GaussDBConnectionConfiguration.Builder builder) { builder.codecRegistrar(EnumCodec.builder().withEnum("my_enum_with_codec", MyEnum.class).build()); } @Test void shouldNotRegisterIfEmpty() { - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .database(SERVER.getDatabase()) .host(SERVER.getHost()) .port(SERVER.getPort()) @@ -75,7 +75,7 @@ void shouldNotRegisterIfEmpty() { @Test void shouldReportUnresolvableTypes() { - PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder() + GaussDBConnectionConfiguration configuration = GaussDBConnectionConfiguration.builder() .database(SERVER.getDatabase()) .host(SERVER.getHost()) .port(SERVER.getPort()) diff --git a/src/test/java/io/r2dbc/gaussdb/replication/LogicalDecodeIntegrationTests.java b/src/test/java/io/r2dbc/gaussdb/replication/LogicalDecodeIntegrationTests.java index 1709e958..9ca41ada 100644 --- a/src/test/java/io/r2dbc/gaussdb/replication/LogicalDecodeIntegrationTests.java +++ b/src/test/java/io/r2dbc/gaussdb/replication/LogicalDecodeIntegrationTests.java @@ -16,12 +16,12 @@ package io.r2dbc.gaussdb.replication; -import io.r2dbc.gaussdb.PostgresqlConnectionConfiguration; +import io.r2dbc.gaussdb.GaussDBConnectionConfiguration; import io.r2dbc.gaussdb.GaussDBConnectionFactory; import io.r2dbc.gaussdb.api.GaussDBConnection; import io.r2dbc.gaussdb.api.PostgresqlReplicationConnection; import io.r2dbc.gaussdb.api.PostgresqlResult; -import io.r2dbc.gaussdb.util.PostgresqlServerExtension; +import io.r2dbc.gaussdb.util.GaussDBServerExtension; import io.r2dbc.spi.R2dbcNonTransientResourceException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -39,9 +39,9 @@ final class LogicalDecodeIntegrationTests { @RegisterExtension - static final PostgresqlServerExtension SERVER = new PostgresqlServerExtension(); + static final GaussDBServerExtension SERVER = new GaussDBServerExtension(); - private final GaussDBConnectionFactory connectionFactory = new GaussDBConnectionFactory(PostgresqlConnectionConfiguration.builder() + private final GaussDBConnectionFactory connectionFactory = new GaussDBConnectionFactory(GaussDBConnectionConfiguration.builder() .database(SERVER.getDatabase()) .host(SERVER.getHost()) .port(SERVER.getPort()) diff --git a/src/test/java/io/r2dbc/gaussdb/util/ClosingPgTestExecutionListener.java b/src/test/java/io/r2dbc/gaussdb/util/ClosingPgTestExecutionListener.java index 40048d05..54d96176 100644 --- a/src/test/java/io/r2dbc/gaussdb/util/ClosingPgTestExecutionListener.java +++ b/src/test/java/io/r2dbc/gaussdb/util/ClosingPgTestExecutionListener.java @@ -7,11 +7,11 @@ public class ClosingPgTestExecutionListener implements TestExecutionListener { @Override public void testPlanExecutionFinished(TestPlan testPlan) { - if (PostgresqlServerExtension.containerInstance != null) { - PostgresqlServerExtension.containerInstance.stop(); + if (GaussDBServerExtension.containerInstance != null) { + GaussDBServerExtension.containerInstance.stop(); } - if (PostgresqlServerExtension.containerNetwork != null) { - PostgresqlServerExtension.containerNetwork.close(); + if (GaussDBServerExtension.containerNetwork != null) { + GaussDBServerExtension.containerNetwork.close(); } } diff --git a/src/test/java/io/r2dbc/gaussdb/util/PostgresqlServerExtension.java b/src/test/java/io/r2dbc/gaussdb/util/GaussDBServerExtension.java similarity index 89% rename from src/test/java/io/r2dbc/gaussdb/util/PostgresqlServerExtension.java rename to src/test/java/io/r2dbc/gaussdb/util/GaussDBServerExtension.java index aca189e8..3e6a0438 100644 --- a/src/test/java/io/r2dbc/gaussdb/util/PostgresqlServerExtension.java +++ b/src/test/java/io/r2dbc/gaussdb/util/GaussDBServerExtension.java @@ -17,7 +17,7 @@ package io.r2dbc.gaussdb.util; import com.zaxxer.hikari.HikariDataSource; -import io.r2dbc.gaussdb.PostgresqlConnectionConfiguration; +import io.r2dbc.gaussdb.GaussDBConnectionConfiguration; import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.ExtensionContext; @@ -43,10 +43,10 @@ import static org.testcontainers.utility.MountableFile.forHostPath; /** - * JUnit Extension to establish a Postgres database context during integration tests. + * JUnit Extension to establish a GaussDB database context during integration tests. * Uses either {@link TestContainer Testcontainers} or a {@link External locally available database}. */ -public final class PostgresqlServerExtension implements BeforeAllCallback, AfterAllCallback { +public final class GaussDBServerExtension implements BeforeAllCallback, AfterAllCallback { static final String IMAGE_NAME = "postgres:13.3"; @@ -56,12 +56,12 @@ public final class PostgresqlServerExtension implements BeforeAllCallback, After private final Supplier> container = () -> { - if (PostgresqlServerExtension.containerInstance != null) { - return PostgresqlServerExtension.containerInstance; + if (GaussDBServerExtension.containerInstance != null) { + return GaussDBServerExtension.containerInstance; } - PostgresqlServerExtension.containerNetwork = Network.newNetwork(); - return PostgresqlServerExtension.containerInstance = container(); + GaussDBServerExtension.containerNetwork = Network.newNetwork(); + return GaussDBServerExtension.containerInstance = container(); }; private final DatabaseContainer postgres = getContainer(); @@ -72,7 +72,7 @@ public final class PostgresqlServerExtension implements BeforeAllCallback, After private JdbcOperations jdbcOperations; - public PostgresqlServerExtension() { + public GaussDBServerExtension() { } private DatabaseContainer getContainer() { @@ -91,7 +91,7 @@ private DatabaseContainer getContainer() { } return new External(); - +// TODO: now test container is not available for GaussDB, use external // if (preference.equals(External.PREFERENCE)) { // return new External(); // } @@ -139,11 +139,11 @@ public String getClientKey() { return getResourcePath("client.key").toAbsolutePath().toString(); } - public PostgresqlConnectionConfiguration.Builder configBuilder() { - return PostgresqlConnectionConfiguration.builder().database(getDatabase()).host(getHost()).port(getPort()).username(getUsername()).password(getPassword()); + public GaussDBConnectionConfiguration.Builder configBuilder() { + return GaussDBConnectionConfiguration.builder().database(getDatabase()).host(getHost()).port(getPort()).username(getUsername()).password(getPassword()); } - public PostgresqlConnectionConfiguration getConnectionConfiguration() { + public GaussDBConnectionConfiguration getConnectionConfiguration() { return configBuilder().build(); } @@ -199,7 +199,7 @@ private > T container() { .withReuse(true) .withNetworkAliases("r2dbc-postgres") .withCommand("/var/setup.sh") - .withNetwork(PostgresqlServerExtension.containerNetwork); + .withNetwork(GaussDBServerExtension.containerNetwork); return container; } @@ -266,7 +266,7 @@ public Network getNetwork() { @Override public int getPort() { - return 5432; + return 8000; } @Override diff --git a/src/test/java/io/r2dbc/gaussdb/util/PgBouncer.java b/src/test/java/io/r2dbc/gaussdb/util/PgBouncer.java index 46563354..69a99641 100644 --- a/src/test/java/io/r2dbc/gaussdb/util/PgBouncer.java +++ b/src/test/java/io/r2dbc/gaussdb/util/PgBouncer.java @@ -21,7 +21,7 @@ import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy; /** - * {@code pgbouncer} extension that can be added in front of {@link PostgresqlServerExtension}. + * {@code pgbouncer} extension that can be added in front of {@link GaussDBServerExtension}. */ public final class PgBouncer implements AutoCloseable { @@ -29,7 +29,7 @@ public final class PgBouncer implements AutoCloseable { private final GenericContainer container; - public PgBouncer(PostgresqlServerExtension server, String poolMode) { + public PgBouncer(GaussDBServerExtension server, String poolMode) { this.container = new GenericContainer<>(IMAGE_NAME) .withExposedPorts(PostgreSQLContainer.POSTGRESQL_PORT) .withEnv("POOL_MODE", poolMode) diff --git a/src/test/java/io/r2dbc/gaussdb/util/PgPool.java b/src/test/java/io/r2dbc/gaussdb/util/PgPool.java index a8d8ad7d..92fe56f5 100644 --- a/src/test/java/io/r2dbc/gaussdb/util/PgPool.java +++ b/src/test/java/io/r2dbc/gaussdb/util/PgPool.java @@ -21,13 +21,13 @@ import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy; /** - * {@code pgpool} extension that can be added in front of {@link PostgresqlServerExtension}. + * {@code pgpool} extension that can be added in front of {@link GaussDBServerExtension}. */ public final class PgPool implements AutoCloseable { private final GenericContainer container; - public PgPool(PostgresqlServerExtension server) { + public PgPool(GaussDBServerExtension server) { this.container = new GenericContainer<>("bitnami/pgpool:4.1.0") .withExposedPorts(PostgreSQLContainer.POSTGRESQL_PORT) .withEnv("PGPOOL_BACKEND_NODES", String.format("0:%s:%s", server.getPostgres().getNetworkAlias(), PostgreSQLContainer.POSTGRESQL_PORT)) diff --git a/src/test/java/io/r2dbc/gaussdb/util/PostgresqlHighAvailabilityClusterExtension.java b/src/test/java/io/r2dbc/gaussdb/util/PostgresqlHighAvailabilityClusterExtension.java index a0d2bd7f..19ceb37e 100644 --- a/src/test/java/io/r2dbc/gaussdb/util/PostgresqlHighAvailabilityClusterExtension.java +++ b/src/test/java/io/r2dbc/gaussdb/util/PostgresqlHighAvailabilityClusterExtension.java @@ -104,7 +104,7 @@ private static Path getResourcePath(String name) { } private void startPrimary(Network network) { - this.primary = new PostgreSQLContainer<>(PostgresqlServerExtension.IMAGE_NAME) + this.primary = new PostgreSQLContainer<>(GaussDBServerExtension.IMAGE_NAME) .withNetwork(network) .withNetworkAliases("postgres-primary") .withCopyFileToContainer(getHostPath("setup-primary.sh", 0755), "/docker-entrypoint-initdb.d/setup-primary.sh") @@ -119,14 +119,14 @@ private void startPrimary(Network network) { } private void startStandby(Network network) { - this.standby = new CustomPostgreSQLContainer(PostgresqlServerExtension.IMAGE_NAME) + this.standby = new CustomPostgreSQLContainer(GaussDBServerExtension.IMAGE_NAME) .withNetwork(network) .withCopyFileToContainer(getHostPath("setup-standby.sh", 0755), "/setup-standby.sh") .withCommand("/setup-standby.sh") .withEnv("PG_REP_USER", "replication") .withEnv("PG_REP_PASSWORD", "replication_password") .withEnv("PG_MASTER_HOST", "postgres-primary") - .withEnv("PG_MASTER_PORT", "5432"); + .withEnv("PG_MASTER_PORT", "8000"); this.standby.start(); HikariConfig standbyConfig = new HikariConfig(); standbyConfig.setJdbcUrl(this.standby.getJdbcUrl());