Skip to content

Commit

Permalink
Move bitfield tests to proper place (#1409)
Browse files Browse the repository at this point in the history
* and fix some unneed preparing / cleaning up
  • Loading branch information
HeartSaVioR committed Oct 16, 2016
1 parent e9d85af commit 686a5f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 46 deletions.
33 changes: 0 additions & 33 deletions src/test/java/redis/clients/jedis/tests/JedisTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,37 +155,4 @@ public void checkDisconnectOnQuit() {
assertFalse(jedis.getClient().isConnected());
}

@Test
public void testBitfield() {
Jedis jedis = new Jedis("redis://localhost:6380");
jedis.auth("foobared");
jedis.del("mykey");
try {
List<Long> responses = jedis.bitfield("mykey", "INCRBY","i5","100","1", "GET", "u4", "0");
assertEquals(1l, responses.get(0).longValue());
assertEquals(0l, responses.get(1).longValue());
} finally {
jedis.del("mykey");
}
}

@Test
/**
* Binary Jedis tests should be in their own class
*/
public void testBinaryBitfield() {
jedis.close();
BinaryJedis binaryJedis = new BinaryJedis("localhost");
binaryJedis.auth("foobared");
binaryJedis.del("mykey".getBytes());
try {
List<byte[]> responses = binaryJedis.bitfield("mykey".getBytes(), "INCRBY".getBytes(),"i5".getBytes(),"100".getBytes(),"1".getBytes(), "GET".getBytes(), "u4".getBytes(), "0".getBytes());
assertEquals(1l, responses.get(0));
assertEquals(0l, responses.get(1));
} finally {
binaryJedis.del("mykey".getBytes());
binaryJedis.close();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import redis.clients.jedis.BitPosParams;
import redis.clients.jedis.Protocol;

import java.util.List;

public class BitCommandsTest extends JedisCommandTestBase {
@Test
public void setAndgetbit() {
Expand Down Expand Up @@ -141,8 +143,6 @@ public void setAndgetrange() {

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

jedis.setbit("foo", 16, true);
jedis.setbit("foo", 24, true);
jedis.setbit("foo", 40, true);
Expand All @@ -153,8 +153,6 @@ public void bitCount() {

long c3 = jedis.bitcount("foo", 2L, 5L);
assertEquals(3, c3);

jedis.del("foo");
}

@Test
Expand All @@ -173,26 +171,32 @@ public void bitOp() {
jedis.bitop(BitOP.XOR, "resultXor", "key1", "key2");
String resultXor = jedis.get("resultXor");
assertEquals("\u0024", resultXor);

jedis.del("resultAnd");
jedis.del("resultOr");
jedis.del("resultXor");
jedis.del("key1");
jedis.del("key2");
}

@Test
public void bitOpNot() {
jedis.del("key");
jedis.setbit("key", 0, true);
jedis.setbit("key", 4, true);

jedis.bitop(BitOP.NOT, "resultNot", "key");

String resultNot = jedis.get("resultNot");
assertEquals("\u0077", resultNot);
}

jedis.del("key");
jedis.del("resultNot");
@Test
public void testBitfield() {
List<Long> responses = jedis.bitfield("mykey", "INCRBY","i5","100","1", "GET", "u4", "0");
assertEquals(1L, responses.get(0).longValue());
assertEquals(0L, responses.get(1).longValue());
}

@Test
public void testBinaryBitfield() {
List<byte[]> responses = jedis.bitfield("mykey".getBytes(), "INCRBY".getBytes(),"i5".getBytes(),
"100".getBytes(),"1".getBytes(), "GET".getBytes(), "u4".getBytes(), "0".getBytes());
assertEquals(1L, responses.get(0));
assertEquals(0L, responses.get(1));
}

}

0 comments on commit 686a5f8

Please sign in to comment.