Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,19 @@ public void setGet() {
assertNull(jedis.setGet(bbar, bfoo));
}

@Test
public void setGetWithParams() {
jedis.del(bfoo);

// no previous, return null
assertNull(jedis.setGet(bfoo, bbar, setParams().nx()));

// key already exists, new value should not be set, previous value should be bbar
assertArrayEquals(bbar, jedis.setGet(bfoo, binaryValue, setParams().nx()));

assertArrayEquals(bbar, jedis.setGet(bfoo, binaryValue, setParams().xx()));
}

@Test
public void sendCommandTest() {
Object obj = jedis.sendCommand(SET, "x".getBytes(), "1".getBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static redis.clients.jedis.params.SetParams.setParams;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -41,6 +42,19 @@ public void getSet() {
assertEquals("bar", value);
}

@Test
public void setGetWithParams() {
jedis.del("foo");

// no previous, return null
assertNull(jedis.setGet("foo", "bar", setParams().nx()));

// key already exists, new value should not be set, previous value should be bbar
assertEquals("bar", jedis.setGet("foo", "foobar", setParams().nx()));

assertEquals("bar", jedis.setGet("foo", "foobar", setParams().xx()));
}

@Test
public void getDel() {
String status = jedis.set("foo", "bar");
Expand Down
Loading