Fix some broken U tests (there are stille broken tests, working on it)
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -54,7 +54,7 @@
|
|||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.8.1</version>
|
<version>4.8.1</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class Client extends BinaryClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void type(final String key) {
|
public void type(final String key) {
|
||||||
del(key.getBytes(Protocol.UTF8));
|
type(key.getBytes(Protocol.UTF8));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keys(final String pattern) {
|
public void keys(final String pattern) {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class Connection {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JedisException("Could not connect to redis-server", 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++;
|
pipelinedCommands++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,12 @@ public class Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getBulkReply() {
|
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() {
|
public byte[] getBinaryBulkReply() {
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public class JedisTest extends JedisCommandTestBase {
|
|||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static void compareList(List expected, List result) {
|
public static void compareList(List expected, List result) {
|
||||||
|
assertEquals(expected.size(), result.size());
|
||||||
|
|
||||||
final Iterator expectedit = expected.iterator();
|
final Iterator expectedit = expected.iterator();
|
||||||
final Iterator responseit = result.iterator();
|
final Iterator responseit = result.iterator();
|
||||||
while(expectedit.hasNext()) {
|
while(expectedit.hasNext()) {
|
||||||
|
|||||||
@@ -6,8 +6,20 @@ import java.util.List;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import redis.clients.jedis.JedisException;
|
import redis.clients.jedis.JedisException;
|
||||||
|
import redis.clients.jedis.tests.JedisTest;
|
||||||
|
|
||||||
public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
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
|
@Test
|
||||||
public void ping() {
|
public void ping() {
|
||||||
String status = jedis.ping();
|
String status = jedis.ping();
|
||||||
@@ -19,14 +31,26 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
|||||||
String status = jedis.set("foo", "bar");
|
String status = jedis.set("foo", "bar");
|
||||||
assertEquals("OK", status);
|
assertEquals("OK", status);
|
||||||
|
|
||||||
|
status = jedis.set(bfoo, bbar);
|
||||||
|
assertEquals("OK", status);
|
||||||
|
|
||||||
int reply = jedis.exists("foo");
|
int reply = jedis.exists("foo");
|
||||||
assertEquals(1, reply);
|
assertEquals(1, reply);
|
||||||
|
|
||||||
|
reply = jedis.exists(bfoo);
|
||||||
|
assertEquals(1, reply);
|
||||||
|
|
||||||
reply = jedis.del("foo");
|
reply = jedis.del("foo");
|
||||||
assertEquals(1, reply);
|
assertEquals(1, reply);
|
||||||
|
|
||||||
|
reply = jedis.del(bfoo);
|
||||||
|
assertEquals(1, reply);
|
||||||
|
|
||||||
reply = jedis.exists("foo");
|
reply = jedis.exists("foo");
|
||||||
assertEquals(0, reply);
|
assertEquals(0, reply);
|
||||||
|
|
||||||
|
reply = jedis.exists(bfoo);
|
||||||
|
assertEquals(0, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -52,6 +76,29 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
|||||||
|
|
||||||
reply = jedis.del("foo1", "foo2");
|
reply = jedis.del("foo1", "foo2");
|
||||||
assertEquals(0, reply);
|
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
|
@Test
|
||||||
@@ -59,6 +106,11 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
|||||||
jedis.set("foo", "bar");
|
jedis.set("foo", "bar");
|
||||||
String status = jedis.type("foo");
|
String status = jedis.type("foo");
|
||||||
assertEquals("string", status);
|
assertEquals("string", status);
|
||||||
|
|
||||||
|
// Binary
|
||||||
|
jedis.set(bfoo, bbar);
|
||||||
|
status = jedis.type(bfoo);
|
||||||
|
assertEquals("string", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -76,6 +128,26 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
|||||||
keys = jedis.keys("bar*");
|
keys = jedis.keys("bar*");
|
||||||
|
|
||||||
assertEquals(expected, keys);
|
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
|
@Test
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package redis.clients.jedis.tests.commands;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|||||||
@@ -179,10 +179,10 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
|||||||
jedis.zadd("foo", 2d, "a");
|
jedis.zadd("foo", 2d, "a");
|
||||||
|
|
||||||
Double score = jedis.zscore("foo", "b");
|
Double score = jedis.zscore("foo", "b");
|
||||||
assertEquals(10d, score);
|
assertEquals((Double)10d, score);
|
||||||
|
|
||||||
score = jedis.zscore("foo", "c");
|
score = jedis.zscore("foo", "c");
|
||||||
assertEquals(0.1d, score);
|
assertEquals((Double)0.1d, score);
|
||||||
|
|
||||||
score = jedis.zscore("foo", "s");
|
score = jedis.zscore("foo", "s");
|
||||||
assertNull(score);
|
assertNull(score);
|
||||||
|
|||||||
Reference in New Issue
Block a user