@Test
    public void testMarkInitiallyAndReset() throws Exception {
        InputStream in = new ByteArrayInputStream(sampleData.getBytes());
        LengthCheckInputStream rvis = new LengthCheckInputStream(in,
                sampleData.getBytes().length, INCLUDE_SKIPPED_BYTES);
        rvis.mark(100);
        rvis.read(new byte[100]);
        rvis.reset();
        rvis.read(new byte[sampleData.getBytes().length]);
        try {
            rvis.read();
        } catch (Exception e) {
            fail();
        }

        rvis.close();
        StreamUtils.consumeInputStream(rvis);

    }
This test case initiates a mark at the start, reads the first 100 bytes
from the stream. Now the stream is reset and it is drained. At the last
read, the length validation must be success.
aws-java-sdk-core/src/test/java/com/amazonaws/util/LengthCheckInputStreamTest.java