DATAREDIS-580 - Polishing.
Fix tests not closing connections properly. Remove usage of Optional in constructors, avoid recreating DirectFieldAccessor on every getConnection call and update documentation. Original Pull Request: #287
This commit is contained in:
@@ -389,6 +389,9 @@ public class LettuceConnectionFactoryTests {
|
||||
@Test // DATAREDIS-580
|
||||
public void factoryUsesMasterSlaveConnections() {
|
||||
|
||||
assumeThat(String.format("No slaves connected to %s:%s.", SettingsUtils.getHost(), SettingsUtils.getPort()),
|
||||
connection.info("replication").getProperty("connected_slaves", "0").compareTo("0") > 0, is(true));
|
||||
|
||||
LettuceClientConfiguration configuration = LettuceTestClientConfiguration.builder().readFrom(ReadFrom.SLAVE)
|
||||
.build();
|
||||
|
||||
@@ -402,7 +405,7 @@ public class LettuceConnectionFactoryTests {
|
||||
assertThat(connection.ping(), is(equalTo("PONG")));
|
||||
assertThat(connection.info().getProperty("role"), is(equalTo("slave")));
|
||||
} finally {
|
||||
this.connection.close();
|
||||
connection.close();
|
||||
}
|
||||
|
||||
factory.destroy();
|
||||
|
||||
@@ -22,8 +22,6 @@ import io.lettuce.core.api.sync.RedisCommands;
|
||||
import io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands;
|
||||
import io.lettuce.core.cluster.api.sync.RedisClusterCommands;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
@@ -45,8 +43,7 @@ public abstract class LettuceReactiveClusterCommandsTestsBase {
|
||||
assumeThat(clientProvider.test(), is(true));
|
||||
nativeCommands = clientProvider.getClient().connect().sync();
|
||||
connection = new LettuceReactiveRedisClusterConnection(
|
||||
new ClusterConnectionProvider(clientProvider.getClient(), LettuceReactiveRedisConnection.CODEC,
|
||||
Optional.empty()),
|
||||
new ClusterConnectionProvider(clientProvider.getClient(), LettuceReactiveRedisConnection.CODEC),
|
||||
clientProvider.getClient());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -90,9 +89,9 @@ public abstract class LettuceReactiveCommandsTestsBase {
|
||||
List<Object[]> parameters = new ArrayList<>();
|
||||
|
||||
StandaloneConnectionProvider standaloneProvider = new StandaloneConnectionProvider(standalone.getClient(),
|
||||
LettuceReactiveRedisConnection.CODEC, Optional.empty());
|
||||
LettuceReactiveRedisConnection.CODEC);
|
||||
StandaloneConnectionProvider nativeConnectionProvider = new StandaloneConnectionProvider(standalone.getClient(),
|
||||
StringCodec.UTF8, Optional.empty());
|
||||
StringCodec.UTF8);
|
||||
|
||||
parameters.add(new Object[] { standaloneProvider, nativeConnectionProvider, "Standalone" });
|
||||
parameters.add(new Object[] {
|
||||
@@ -102,9 +101,9 @@ public abstract class LettuceReactiveCommandsTestsBase {
|
||||
if (cluster.test()) {
|
||||
|
||||
ClusterConnectionProvider clusterProvider = new ClusterConnectionProvider(cluster.getClient(),
|
||||
LettuceReactiveRedisConnection.CODEC, Optional.empty());
|
||||
LettuceReactiveRedisConnection.CODEC);
|
||||
ClusterConnectionProvider nativeClusterConnectionProvider = new ClusterConnectionProvider(cluster.getClient(),
|
||||
StringCodec.UTF8, Optional.empty());
|
||||
StringCodec.UTF8);
|
||||
|
||||
parameters.add(new Object[] { clusterProvider, nativeClusterConnectionProvider, "Cluster" });
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public class LettuceSentinelIntegrationTests extends AbstractConnectionIntegrati
|
||||
LettuceClientConfiguration configuration = LettuceTestClientConfiguration.builder().readFrom(ReadFrom.SLAVE)
|
||||
.build();
|
||||
|
||||
LettuceConnectionFactory factory = new LettuceConnectionFactory(SettingsUtils.standaloneConfiguration(),
|
||||
LettuceConnectionFactory factory = new LettuceConnectionFactory(SENTINEL_CONFIG,
|
||||
configuration);
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
@@ -229,7 +229,7 @@ public class LettuceSentinelIntegrationTests extends AbstractConnectionIntegrati
|
||||
assertThat(connection.ping(), is(equalTo("PONG")));
|
||||
assertThat(connection.info().getProperty("role"), is(equalTo("slave")));
|
||||
} finally {
|
||||
this.connection.close();
|
||||
connection.close();
|
||||
}
|
||||
|
||||
factory.destroy();
|
||||
|
||||
Reference in New Issue
Block a user