Code example for ArrayList

Methods: add

0
        InputStream is = new ByteArrayInputStream(
                "*4\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$5\r\nHello\r\n$5\r\nWorld\r\n" 
                        .getBytes());
        List<byte[]> response = (List<byte[]>) Protocol
                .read(new RedisInputStream(is));
        List<byte[]> expected = new ArrayList<byte[]>();
        expected.add(SafeEncoder.encode("foo"));
        expected.add(SafeEncoder.encode("bar"));
        expected.add(SafeEncoder.encode("Hello"));
        expected.add(SafeEncoder.encode("World"));
 
        assertEquals(expected, response);
    } 
 
    @SuppressWarnings("unchecked") 
    @Test 
    public void nullMultiBulkReply() { 
        InputStream is = new ByteArrayInputStream("*-1\r\n".getBytes());
        List<String> response = (List<String>) Protocol
                .read(new RedisInputStream(is));
        assertNull(response);