@Test
    public void testContentLength() throws Exception {
        InputStream in = new ByteArrayInputStream(sampleData.getBytes());

        LengthCheckInputStream rvis = new LengthCheckInputStream(in,
                sampleData.getBytes().length, INCLUDE_SKIPPED_BYTES);
        try {
            StreamUtils.consumeInputStream(rvis);
        } catch (Exception e) {
            fail();
        }

        rvis.close();
    }
Tests if the content length set in the stream equals the bytes read from
the stream. If any exception is thrown, then the test fails.
aws-java-sdk-core/src/test/java/com/amazonaws/util/LengthCheckInputStreamTest.java