Browse files

Fix some broken U tests (there are stille broken tests, working on it)

  • Loading branch information...
1 parent abd464f commit ead39394a11e75d1f26989b2477d40c62404b60f @yaourt yaourt committed Nov 4, 2010
View
2 pom.xml
@@ -54,7 +54,7 @@
<artifactId>junit</artifactId>
<version>4.8.1</version>
<type>jar</type>
- <scope>compile</scope>
+ <scope>test</scope>
</dependency>
</dependencies>
View
2 src/main/java/redis/clients/jedis/Client.java
@@ -34,7 +34,7 @@ public void del(final String... keys) {
}
public void type(final String key) {
- del(key.getBytes(Protocol.UTF8));
+ type(key.getBytes(Protocol.UTF8));
}
public void keys(final String pattern) {
View
9 src/main/java/redis/clients/jedis/Connection.java
@@ -79,7 +79,7 @@ protected Connection sendCommand(final Command cmd) {
} catch (IOException e) {
throw new JedisException("Could not connect to redis-server", e);
}
- protocol.sendCommand(outputStream, cmd, (byte[])null);
+ protocol.sendCommand(outputStream, cmd, new byte[0][]);
pipelinedCommands++;
return this;
}
@@ -144,7 +144,12 @@ protected String getStatusCodeReply() {
}
public String getBulkReply() {
- return new String(getBinaryBulkReply(), Protocol.UTF8);
+ final byte[] result = getBinaryBulkReply();
+ if (null != result) {
+ return new String(result, Protocol.UTF8);
+ } else {
+ return null;
+ }
}
public byte[] getBinaryBulkReply() {
View
2 src/test/java/redis/clients/jedis/tests/JedisTest.java
@@ -46,6 +46,8 @@ public void connectWithShardInfo() {
@SuppressWarnings("rawtypes")
public static void compareList(List expected, List result) {
+ assertEquals(expected.size(), result.size());
+
final Iterator expectedit = expected.iterator();
final Iterator responseit = result.iterator();
while(expectedit.hasNext()) {
View
72 src/test/java/redis/clients/jedis/tests/commands/AllKindOfValuesCommandsTest.java
@@ -6,8 +6,20 @@
import org.junit.Test;
import redis.clients.jedis.JedisException;
+import redis.clients.jedis.tests.JedisTest;
public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
+ final byte[] bfoo = {0x01, 0x02, 0x03, 0x04};
+ final byte[] bfoo1 = {0x01, 0x02, 0x03, 0x04, 0x0A};
+ final byte[] bfoo2 = {0x01, 0x02, 0x03, 0x04, 0x0B};
+ final byte[] bfoo3 = {0x01, 0x02, 0x03, 0x04, 0x0C};
+ final byte[] bbar = {0x05, 0x06, 0x07, 0x08};
+ final byte[] bbar1 = {0x05, 0x06, 0x07, 0x08, 0x0A};
+ final byte[] bbar2 = {0x05, 0x06, 0x07, 0x08, 0x0B};
+ final byte[] bbar3 = {0x05, 0x06, 0x07, 0x08, 0x0C};
+
+ final byte[] bfoobar = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
+
@Test
public void ping() {
String status = jedis.ping();
@@ -19,14 +31,26 @@ public void exists() {
String status = jedis.set("foo", "bar");
assertEquals("OK", status);
+ status = jedis.set(bfoo, bbar);
+ assertEquals("OK", status);
+
int reply = jedis.exists("foo");
assertEquals(1, reply);
+ reply = jedis.exists(bfoo);
+ assertEquals(1, reply);
+
reply = jedis.del("foo");
assertEquals(1, reply);
+ reply = jedis.del(bfoo);
+ assertEquals(1, reply);
+
reply = jedis.exists("foo");
assertEquals(0, reply);
+
+ reply = jedis.exists(bfoo);
+ assertEquals(0, reply);
}
@Test
@@ -52,13 +76,41 @@ public void del() {
reply = jedis.del("foo1", "foo2");
assertEquals(0, reply);
+
+ // Binary ...
+ jedis.set(bfoo1, bbar1);
+ jedis.set(bfoo2, bbar2);
+ jedis.set(bfoo3, bbar3);
+
+ reply = jedis.del(bfoo1, bfoo2, bfoo3);
+ assertEquals(3, reply);
+
+ reply = jedis.exists(bfoo1);
+ assertEquals(0, reply);
+ reply = jedis.exists(bfoo2);
+ assertEquals(0, reply);
+ reply = jedis.exists(bfoo3);
+ assertEquals(0, reply);
+
+ jedis.set(bfoo1, bbar1);
+
+ reply = jedis.del(bfoo1, bfoo2);
+ assertEquals(1, reply);
+
+ reply = jedis.del(bfoo1, bfoo2);
+ assertEquals(0, reply);
}
@Test
public void type() {
jedis.set("foo", "bar");
String status = jedis.type("foo");
assertEquals("string", status);
+
+ // Binary
+ jedis.set(bfoo, bbar);
+ status = jedis.type(bfoo);
+ assertEquals("string", status);
}
@Test
@@ -76,6 +128,26 @@ public void keys() {
keys = jedis.keys("bar*");
assertEquals(expected, keys);
+
+ // Binary
+ jedis.set(bfoo, bbar);
+ jedis.set(bfoobar, bbar);
+
+ byte[] bfoostar = new byte[bfoo.length+1];
+ System.arraycopy(bfoo, 0, bfoostar, 0, bfoo.length);
+ bfoostar[bfoostar.length-1] = '*';
+ List<byte[]> bkeys = jedis.keys(bfoostar);
+ List<byte[]> bexpected = new ArrayList<byte[]>();
+ bexpected.add(bfoo);
+ bexpected.add(bfoobar);
+ JedisTest.compareList(bexpected, bkeys);
+// assertEquals(expected, keys);
+
+ expected = new ArrayList<String>();
+ keys = jedis.keys("bar*");
+
+ assertEquals(expected, keys);
+
}
@Test
View
2 src/test/java/redis/clients/jedis/tests/commands/JedisCommandTestBase.java
@@ -3,7 +3,7 @@
import java.io.IOException;
import java.net.UnknownHostException;
-import junit.framework.Assert;
+import org.junit.Assert;
import org.junit.After;
import org.junit.Before;
View
4 src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java
@@ -179,10 +179,10 @@ public void zscore() {
jedis.zadd("foo", 2d, "a");
Double score = jedis.zscore("foo", "b");
- assertEquals(10d, score);
+ assertEquals((Double)10d, score);
score = jedis.zscore("foo", "c");
- assertEquals(0.1d, score);
+ assertEquals((Double)0.1d, score);
score = jedis.zscore("foo", "s");
assertNull(score);

0 comments on commit ead3939

Please sign in to comment.