Change mSetNX/multiSetIfAbsent return type to Boolean
DATAREDIS-177
This commit is contained in:
@@ -865,9 +865,21 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
Map<String, String> vals = new HashMap<String, String>();
|
||||
vals.put("height", "5");
|
||||
vals.put("width", "1");
|
||||
connection.mSetNXString(vals);
|
||||
actual.add(connection.mSetNXString(vals));
|
||||
actual.add(connection.mGet("height", "width"));
|
||||
verifyResults(Arrays.asList(new Object[] { Arrays.asList(new String[] { "5", "1" }) }),
|
||||
verifyResults(Arrays.asList(new Object[] { true, Arrays.asList(new String[] { "5", "1" }) }),
|
||||
actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMSetNxFailure() {
|
||||
connection.set("height", "2");
|
||||
Map<String, String> vals = new HashMap<String, String>();
|
||||
vals.put("height", "5");
|
||||
vals.put("width", "1");
|
||||
actual.add(connection.mSetNXString(vals));
|
||||
actual.add(connection.mGet("height", "width"));
|
||||
verifyResults(Arrays.asList(new Object[] { false, Arrays.asList(new String[] { "2", null }) }),
|
||||
actual);
|
||||
}
|
||||
|
||||
|
||||
@@ -339,6 +339,18 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
|
||||
actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMSetNxFailure() {
|
||||
connection.set("height", "2");
|
||||
Map<String, String> vals = new HashMap<String, String>();
|
||||
vals.put("height", "5");
|
||||
vals.put("width", "1");
|
||||
actual.add(connection.mSetNXString(vals));
|
||||
actual.add(connection.mGet("height", "width"));
|
||||
verifyResults(Arrays.asList(new Object[] { 0l, Arrays.asList(new String[] { "2", null }) }),
|
||||
actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetNx() {
|
||||
actual.add(connection.setNX("notaround", "54"));
|
||||
|
||||
@@ -80,6 +80,10 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat
|
||||
public void testMSetNx() {
|
||||
}
|
||||
|
||||
@Ignore("https://github.com/alphazero/jredis/issues/64 Protocol error: expected '$' got '*' on mset")
|
||||
public void testMSetNxFailure() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectionClosesWhenNotPooled() {
|
||||
connection.close();
|
||||
|
||||
@@ -186,6 +186,18 @@ public class LettuceConnectionPipelineIntegrationTests extends
|
||||
actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMSetNxFailure() {
|
||||
connection.set("height", "2");
|
||||
Map<String, String> vals = new HashMap<String, String>();
|
||||
vals.put("height", "5");
|
||||
vals.put("width", "1");
|
||||
actual.add(connection.mSetNXString(vals));
|
||||
actual.add(connection.mGet("height", "width"));
|
||||
verifyResults(Arrays.asList(new Object[] { false, Arrays.asList(new String[] { "2", null }) }),
|
||||
actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetNx() {
|
||||
actual.add(connection.setNX("notaround", "54"));
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
package org.springframework.data.redis.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -71,4 +76,23 @@ public class DefaultValueOperationsTests {
|
||||
valueOps.increment(key, -10d);
|
||||
assertEquals("1.9", valueOps.get(key));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiSetIfAbsent() {
|
||||
Map<String,String> keysAndValues = new HashMap<String,String>();
|
||||
keysAndValues.put("foo", "bar");
|
||||
keysAndValues.put("baz", "test");
|
||||
assertTrue(valueOps.multiSetIfAbsent(keysAndValues));
|
||||
assertEquals(new HashSet<String>(keysAndValues.values()),
|
||||
new HashSet<String>(valueOps.multiGet(keysAndValues.keySet())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiSetIfAbsentFailure() {
|
||||
valueOps.set("foo", "alreadyset");
|
||||
Map<String,String> keysAndValues = new HashMap<String,String>();
|
||||
keysAndValues.put("foo", "bar");
|
||||
keysAndValues.put("baz", "test");
|
||||
assertFalse(valueOps.multiSetIfAbsent(keysAndValues));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user