ParseByteArrayHttpBody extends ParseHttpBody { @Override public void writeTo(OutputStream out) throws IOException { if (out == null) { throw new IllegalArgumentException("Output stream may not be null"); } out.write(content); } ParseByteArrayHttpBody(String content, String contentType);  ParseByteArrayHttpBody(byte[] content, String contentType); @Override InputStream getContent(); @Override void writeTo(OutputStream out);  }
@Test public void testWriteTo() throws IOException { String content = "content"; String contentType = "application/json"; ParseByteArrayHttpBody body = new ParseByteArrayHttpBody(content, contentType); ByteArrayOutputStream output = new ByteArrayOutputStream(); body.writeTo(output); String contentAgain = output.toString(); assertEquals(content, contentAgain); }