@Test
public void testSkip()
{

    byte[] allDataBytes = "Hello, this is http client package, and I am just a test for GatheringByteArrayInputStream".getBytes(UTF_8);
    int length = allDataBytes.length;
    try (GatheringByteArrayInputStream in = new GatheringByteArrayInputStream(
            ImmutableList.of(
                    Arrays.copyOfRange(allDataBytes, 0, length / 3),
                    Arrays.copyOfRange(allDataBytes, length / 3, length / 3 + length / 2),
                    Arrays.copyOfRange(allDataBytes, length / 3 + length / 2, length)),
            length)) {
        int skipped = length / 2;
        int firstPartLength = length / 4;
        int restPartLength = length - firstPartLength - skipped;
        byte[] actual = new byte[length - skipped + 10];
        // read the first part
        assertEquals(in.read(actual, 0, firstPartLength), firstPartLength);
        assertByteArrayEquals(actual, 0, allDataBytes, 0, firstPartLength);
        // skip some bytes
        assertEquals(in.skip(skipped), skipped);
        // read the rest part
        assertEquals(in.read(actual, firstPartLength, restPartLength + 10), restPartLength);
        assertByteArrayEquals(actual, firstPartLength, allDataBytes, firstPartLength + skipped, restPartLength);
        assertEquals(in.skip(10), 0);
        assertEquals(in.read(), -1);
    }
}