@Test public void testWriteTo() throws Exception { final String s = "Message content"; final byte[] bytes = s.getBytes(StandardCharsets.ISO_8859_1); final StringEntity entity = new StringEntity(s); final HttpEntityWrapper wrapped = new HttpEntityWrapper(entity); ByteArrayOutputStream out = new ByteArrayOutputStream(); wrapped.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(); wrapped.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 { wrapped.writeTo(null); Assert.fail("NullPointerException should have been thrown"); } catch (final NullPointerException ex) { } }
@Override public void writeTo(final OutputStream outStream) throws IOException { wrappedEntity.writeTo(outStream); }
HttpEntityWrapper implements HttpEntity { @Override public void writeTo(final OutputStream outStream) throws IOException { wrappedEntity.writeTo(outStream); } }
HttpEntityWrapper implements HttpEntity { @Override public void writeTo(final OutputStream outStream) throws IOException { wrappedEntity.writeTo(outStream); } HttpEntityWrapper(final HttpEntity wrappedEntity); }
HttpEntityWrapper implements HttpEntity { @Override public void writeTo(final OutputStream outStream) throws IOException { wrappedEntity.writeTo(outStream); } HttpEntityWrapper(final HttpEntity wrappedEntity); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override String getContentType(); @Override String getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(final OutputStream outStream); @Override boolean isStreaming(); @Override Supplier<List<? extends Header>> getTrailers(); @Override Set<String> getTrailerNames(); @Override void close(); @Override String toString(); }
HttpEntityWrapper implements HttpEntity { @Override public void writeTo(final OutputStream outStream) throws IOException { wrappedEntity.writeTo(outStream); } HttpEntityWrapper(final HttpEntity wrappedEntity); @Override boolean isRepeatable(); @Override boolean isChunked(); @Override long getContentLength(); @Override String getContentType(); @Override String getContentEncoding(); @Override InputStream getContent(); @Override void writeTo(final OutputStream outStream); @Override boolean isStreaming(); @Override Supplier<List<? extends Header>> getTrailers(); @Override Set<String> getTrailerNames(); @Override void close(); @Override String toString();  }