/** * Skipped more than what's expected. */ @Test public void testOverSkipped() throws IOException { byte[] bytes = new byte[100]; LengthCheckInputStream is = new LengthCheckInputStream( new ByteArrayInputStream(bytes), 99, INCLUDE_SKIPPED_BYTES); try { is.skip(100); fail(); } catch (AmazonClientException ex) { // expected } is.close(); } }
/** * Actual number of bytes consumed is less than what's expected, when * skipped bytes are excluded. */ @Test public void testSkipExcludedFailure() throws IOException { byte[] bytes = new byte[100]; LengthCheckInputStream is = new LengthCheckInputStream( new ByteArrayInputStream(bytes), 100, EXCLUDE_SKIPPED_BYTES); assertTrue(10 == is.skip(10)); try { StreamUtils.consumeInputStream(is); fail(); } catch (AmazonClientException ex) { // expected } is.close(); }