public void testSmove() throws ExecutionException, InterruptedException { String key1 = "SET_MOVE_KEY1"; String key2 = "SET_MOVE_KEY2"; client.delete(key1, key2).get(); long reply = client.sadd(key1, "a", "b", "c", "d").get(); assertEquals(4, reply); reply = client.sadd(key2, "e").get(); assertEquals(1, reply); reply = client.smove(key1, key2, "d").get(); assertEquals(1, reply); reply = client.scard(key1).get(); assertEquals(3, reply); reply = client.scard(key2).get(); assertEquals(2, reply); reply = client.smove(key1, key2, "e").get(); assertEquals(0, reply); }
public void testSaddAndCardAndMembers() throws ExecutionException, InterruptedException { String key = "SET_ADD_KEY"; client.delete(key).get(); long reply = client.sadd(key, "OK", "KO").get(); assertEquals(2, reply); reply = client.scard(key).get(); assertEquals(2, reply); List<String> cached = (List<String>) client.smembers(key).get(); assertEquals(2, cached.size()); assertEquals("OK", cached.get(0)); assertEquals("KO", cached.get(1)); }
public void testSpopAndRandomAndRem() throws ExecutionException, InterruptedException { String key1 = "SET_POP_KEY1"; client.delete(key1).get(); long reply = client.sadd(key1, "a", "b", "c", "d").get(); assertEquals(4, reply); String pop = (String) client.spop(key1).get(); assertNotNull(pop); reply = client.scard(key1).get(); assertEquals(3, reply); pop = (String) client.srandomMember(key1).get(); assertNotNull(pop); reply = client.scard(key1).get(); assertEquals(3, reply); List<String> randoms = (List<String>) client.srandomMember(key1, 2).get(); assertEquals(2, randoms.size()); reply = client.sadd(key1, "a", "b", "c", "d").get(); assertEquals(1, reply); reply = client.srem(key1, "a", "b").get(); assertEquals(2, reply); reply = client.sisMember(key1, "a").get(); assertEquals(0, reply); reply = client.sisMember(key1, "c").get(); assertEquals(1, reply); }