@Test
public void testNormal()
{

    byte[] lastStringArray = "client".getBytes(UTF_8);
    byte[] lastArray = Arrays.copyOf(lastStringArray, lastStringArray.length + 32);
    arraycopy(lastStringArray, 0, lastArray, 0, lastStringArray.length);
    List<byte[]> buffers = ImmutableList.of(
            "hello ".getBytes(UTF_8),
            "this ".getBytes(UTF_8),
            "is ".getBytes(UTF_8),
            "http ".getBytes(UTF_8),
            lastArray);
    byte[] expectedAll = "hello this is http client".getBytes();
    byte[] expectedPartial = "hello this".getBytes();
    try (GatheringByteArrayInputStream in = new GatheringByteArrayInputStream(buffers, expectedAll.length)) {
        byte[] buffer = new byte[expectedAll.length + 32];
        // read the first part
        assertEquals(in.read(buffer, 0, expectedPartial.length), expectedPartial.length);
        // verify the first part
        assertByteArrayEquals(buffer, 0, expectedPartial, 0, expectedPartial.length);
        // read the remaining part
        assertEquals(in.read(buffer, expectedPartial.length, buffer.length - expectedPartial.length), expectedAll.length - expectedPartial.length);
        // verify the whole string
        assertByteArrayEquals(buffer, 0, expectedAll, 0, expectedAll.length);
        // make sure there is no more data
        assertEquals(-1, in.read(buffer, 0, expectedAll.length));
    }
}