Merge from upstream/master.
This commit is contained in:
@@ -3,7 +3,6 @@ package redis.clients.jedis.tests;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PipedInputStream;
|
||||
@@ -16,6 +15,8 @@ import junit.framework.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Protocol;
|
||||
import redis.clients.util.RedisInputStream;
|
||||
import redis.clients.util.RedisOutputStream;
|
||||
|
||||
public class ProtocolTest extends Assert {
|
||||
@Test
|
||||
@@ -25,7 +26,7 @@ public class ProtocolTest extends Assert {
|
||||
PipedOutputStream pos = new PipedOutputStream(pis);
|
||||
|
||||
Protocol protocol = new Protocol();
|
||||
protocol.sendCommand(new DataOutputStream(pos), "GET", "SOMEKEY");
|
||||
protocol.sendCommand(new RedisOutputStream(pos), "GET", "SOMEKEY");
|
||||
|
||||
pos.close();
|
||||
String expectedCommand = "*2\r\n$3\r\nGET\r\n$7\r\nSOMEKEY\r\n";
|
||||
@@ -43,7 +44,7 @@ public class ProtocolTest extends Assert {
|
||||
public void bulkReply() {
|
||||
InputStream is = new ByteArrayInputStream("$6\r\nfoobar\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = (String) protocol.read(new DataInputStream(is));
|
||||
String response = (String) protocol.read(new RedisInputStream(is));
|
||||
assertEquals("foobar", response);
|
||||
}
|
||||
|
||||
@@ -51,9 +52,8 @@ public class ProtocolTest extends Assert {
|
||||
public void fragmentedBulkReply() {
|
||||
FragmentedByteArrayInputStream fis = new FragmentedByteArrayInputStream("$30\r\n012345678901234567890123456789\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = (String) protocol.read(new DataInputStream(fis));
|
||||
String response = (String) protocol.read(new RedisInputStream(fis));
|
||||
assertEquals("012345678901234567890123456789", response);
|
||||
assertEquals(3, fis.getReadMethodCallCount());
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ProtocolTest extends Assert {
|
||||
public void nullBulkReply() {
|
||||
InputStream is = new ByteArrayInputStream("$-1\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = (String) protocol.read(new DataInputStream(is));
|
||||
String response = (String) protocol.read(new RedisInputStream(is));
|
||||
assertEquals(null, response);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ProtocolTest extends Assert {
|
||||
public void singleLineReply() {
|
||||
InputStream is = new ByteArrayInputStream("+OK\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = (String) protocol.read(new DataInputStream(is));
|
||||
String response = (String) protocol.read(new RedisInputStream(is));
|
||||
assertEquals("OK", response);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ProtocolTest extends Assert {
|
||||
public void integerReply() {
|
||||
InputStream is = new ByteArrayInputStream(":123\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
int response = (Integer) protocol.read(new DataInputStream(is));
|
||||
int response = (Integer) protocol.read(new RedisInputStream(is));
|
||||
assertEquals(123, response);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ProtocolTest extends Assert {
|
||||
.getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
List<String> response = (List<String>) (List<?>) protocol
|
||||
.read(new DataInputStream(is));
|
||||
.read(new RedisInputStream(is));
|
||||
List<String> expected = new ArrayList<String>();
|
||||
expected.add("foo");
|
||||
expected.add("bar");
|
||||
@@ -103,7 +103,7 @@ public class ProtocolTest extends Assert {
|
||||
.getBytes());
|
||||
protocol = new Protocol();
|
||||
List<Object> response2 = (List<Object>) protocol
|
||||
.read(new DataInputStream(is));
|
||||
.read(new RedisInputStream(is));
|
||||
List<Object> expected2 = new ArrayList<Object>();
|
||||
expected2.add("foo");
|
||||
expected2.add("OK");
|
||||
@@ -122,7 +122,7 @@ public class ProtocolTest extends Assert {
|
||||
InputStream is = new ByteArrayInputStream("*-1\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
List<String> response = (List<String>) protocol
|
||||
.read(new DataInputStream(is));
|
||||
.read(new RedisInputStream(is));
|
||||
assertNull(response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user