"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDecompressingEntity.java" between
httpcomponents-client-5.2-src.tar.gz and httpcomponents-client-5.2.1-src.tar.gz

About: Apache HttpComponents Client provides reusable components for client-side authentication, HTTP state management, and HTTP connection management. Java sources.

TestDecompressingEntity.java  (httpcomponents-client-5.2-src):TestDecompressingEntity.java  (httpcomponents-client-5.2.1-src)
skipping to change at line 83 skipping to change at line 83
final InputStream in2 = entity.getContent(); final InputStream in2 = entity.getContent();
Assertions.assertSame(in1, in2); Assertions.assertSame(in1, in2);
EntityUtils.consume(entity); EntityUtils.consume(entity);
EntityUtils.consume(entity); EntityUtils.consume(entity);
} }
@Test @Test
public void testWriteToStream() throws Exception { public void testWriteToStream() throws Exception {
final CRC32 crc32 = new CRC32(); final CRC32 crc32 = new CRC32();
final StringEntity wrapped = new StringEntity("1234567890", StandardChar sets.US_ASCII); final StringEntity wrapped = new StringEntity("1234567890", StandardChar sets.US_ASCII);
final ChecksumEntity entity = new ChecksumEntity(wrapped, crc32); try (final ChecksumEntity entity = new ChecksumEntity(wrapped, crc32)) {
Assertions.assertFalse(entity.isStreaming()); Assertions.assertFalse(entity.isStreaming());
final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ByteArrayOutputStream out = new ByteArrayOutputStream();
entity.writeTo(out); entity.writeTo(out);
final String s = new String(out.toByteArray(), StandardCharsets.US_ASCII final String s = new String(out.toByteArray(), StandardCharsets.US_A
); SCII);
Assertions.assertEquals("1234567890", s); Assertions.assertEquals("1234567890", s);
Assertions.assertEquals(639479525L, crc32.getValue()); Assertions.assertEquals(639479525L, crc32.getValue());
}
} }
static class ChecksumEntity extends DecompressingEntity { static class ChecksumEntity extends DecompressingEntity {
public ChecksumEntity(final HttpEntity wrapped, final Checksum checksum) { public ChecksumEntity(final HttpEntity wrapped, final Checksum checksum) {
super(wrapped, inStream -> new CheckedInputStream(inStream, checksum )); super(wrapped, inStream -> new CheckedInputStream(inStream, checksum ));
} }
} }
 End of changes. 3 change blocks. 
8 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)