String result = EncodingUtils.getString(out.toByteArray(), CONTENT_CHARSET);
assertEquals(result, "1234567890");
}
public void testSkip() throws IOException {
InputStream in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[20]), 10L);
assertEquals(10, in.skip(10));
assertTrue(in.read() == -1);
in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[20]), 10L);
in.read();
assertEquals(9, in.skip(10));
assertTrue(in.read() == -1);
in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[20]), 2L);
in.read();
in.read();
assertTrue(in.skip(10) <= 0);
assertTrue(in.skip(-1) == 0);
assertTrue(in.read() == -1);
in = new ContentLengthInputStream(new HttpDataReceiverMockup(new byte[2]), 4L);
in.read();
assertTrue(in.skip(2) == 1);
}