@Test public void testWriteToBuffered() throws Exception { final byte[] bytes = "Message content".getBytes(StandardCharsets.US_ASCII); final InputStreamEntity httpentity = new InputStreamEntity(new ByteArrayInputStream(bytes), -1, null); final BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity); ByteArrayOutputStream out = new ByteArrayOutputStream(); bufentity.writeTo(out); byte[] bytes2 = out.toByteArray(); Assert.assertNotNull(bytes2); Assert.assertEquals(bytes.length, bytes2.length); for (int i = 0; i < bytes.length; i++) { Assert.assertEquals(bytes[i], bytes2[i]); } out = new ByteArrayOutputStream(); bufentity.writeTo(out); bytes2 = out.toByteArray(); Assert.assertNotNull(bytes2); Assert.assertEquals(bytes.length, bytes2.length); for (int i = 0; i < bytes.length; i++) { Assert.assertEquals(bytes[i], bytes2[i]); } try { bufentity.writeTo(null); Assert.fail("NullPointerException should have been thrown"); } catch (final NullPointerException ex) { } }
@Override public void writeTo(final OutputStream outStream) throws IOException { Args.notNull(outStream, "Output stream"); if (this.buffer != null) { outStream.write(this.buffer); } else { super.writeTo(outStream); } }
BufferedHttpEntity extends HttpEntityWrapper { @Override public void writeTo(final OutputStream outStream) throws IOException { Args.notNull(outStream, "Output stream"); if (this.buffer != null) { outStream.write(this.buffer); } else { super.writeTo(outStream); } } }
BufferedHttpEntity extends HttpEntityWrapper { @Override public void writeTo(final OutputStream outStream) throws IOException { Args.notNull(outStream, "Output stream"); if (this.buffer != null) { outStream.write(this.buffer); } else { super.writeTo(outStream); } } BufferedHttpEntity(final HttpEntity entity); }
BufferedHttpEntity extends HttpEntityWrapper { @Override public void writeTo(final OutputStream outStream) throws IOException { Args.notNull(outStream, "Output stream"); if (this.buffer != null) { outStream.write(this.buffer); } else { super.writeTo(outStream); } } BufferedHttpEntity(final HttpEntity entity); @Override long getContentLength(); @Override InputStream getContent(); @Override boolean isChunked(); @Override boolean isRepeatable(); @Override void writeTo(final OutputStream outStream); @Override boolean isStreaming(); }
BufferedHttpEntity extends HttpEntityWrapper { @Override public void writeTo(final OutputStream outStream) throws IOException { Args.notNull(outStream, "Output stream"); if (this.buffer != null) { outStream.write(this.buffer); } else { super.writeTo(outStream); } } BufferedHttpEntity(final HttpEntity entity); @Override long getContentLength(); @Override InputStream getContent(); @Override boolean isChunked(); @Override boolean isRepeatable(); @Override void writeTo(final OutputStream outStream); @Override boolean isStreaming();  }