refactoring

pull/5477/merge
Nikita Koksharov 1 year ago
parent 8ae712423d
commit ec4c75c522

@ -28,26 +28,12 @@ import org.redisson.client.codec.StringCodec;
import org.redisson.config.Config; import org.redisson.config.Config;
import org.redisson.connection.balancer.RandomLoadBalancer; import org.redisson.connection.balancer.RandomLoadBalancer;
public class RedissonSortedSetTest extends BaseTest { public class RedissonSortedSetTest extends RedisDockerTest {
@Test @Test
public void testNameMapper() throws InterruptedException, IOException { public void testNameMapper() {
RedisRunner master1 = new RedisRunner().port(6890).randomDir().nosave(); testInCluster(client -> {
RedisRunner master2 = new RedisRunner().port(6891).randomDir().nosave(); Config config = client.getConfig();
RedisRunner master3 = new RedisRunner().port(6892).randomDir().nosave();
RedisRunner slave1 = new RedisRunner().port(6900).randomDir().nosave();
RedisRunner slave2 = new RedisRunner().port(6901).randomDir().nosave();
RedisRunner slave3 = new RedisRunner().port(6902).randomDir().nosave();
ClusterRunner clusterRunner = new ClusterRunner()
.addNode(master1, slave1)
.addNode(master2, slave2)
.addNode(master3, slave3);
ClusterRunner.ClusterProcesses process = clusterRunner.run();
Thread.sleep(5000);
Config config = new Config();
config.useClusterServers() config.useClusterServers()
.setNameMapper(new NameMapper() { .setNameMapper(new NameMapper() {
@Override @Override
@ -59,9 +45,7 @@ public class RedissonSortedSetTest extends BaseTest {
public String unmap(String name) { public String unmap(String name) {
return name.replace(":suffix:", ""); return name.replace(":suffix:", "");
} }
}) });
.setLoadBalancer(new RandomLoadBalancer())
.addNodeAddress(process.getNodes().stream().findAny().get().getRedisServerAddressAndPort());
RedissonClient redisson = Redisson.create(config); RedissonClient redisson = Redisson.create(config);
RSortedSet<Long> set = redisson.getSortedSet("simple", LongCodec.INSTANCE); RSortedSet<Long> set = redisson.getSortedSet("simple", LongCodec.INSTANCE);
@ -77,6 +61,8 @@ public class RedissonSortedSetTest extends BaseTest {
set.delete(); set.delete();
assertThat(redisson.getKeys().count()).isZero(); assertThat(redisson.getKeys().count()).isZero();
redisson.shutdown();
});
} }

Loading…
Cancel
Save