@Test public void write() throws Exception { String content = "Hello, World."; byte[] rawBytes = content.getBytes("utf-8"); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); HttpClient httpClient = new HttpClient(); httpClient.write(outputStream, rawBytes); assertThat(outputStream.toByteArray(), is(rawBytes)); }
@VisibleForTesting void write(OutputStream outputStream, byte[] content) throws IOException { try { outputStream.write(content); outputStream.flush(); } finally { Closeables.close(outputStream, true); } }
HttpClient { @VisibleForTesting void write(OutputStream outputStream, byte[] content) throws IOException { try { outputStream.write(content); outputStream.flush(); } finally { Closeables.close(outputStream, true); } } }
HttpClient { @VisibleForTesting void write(OutputStream outputStream, byte[] content) throws IOException { try { outputStream.write(content); outputStream.flush(); } finally { Closeables.close(outputStream, true); } } HttpClient(); }
HttpClient { @VisibleForTesting void write(OutputStream outputStream, byte[] content) throws IOException { try { outputStream.write(content); outputStream.flush(); } finally { Closeables.close(outputStream, true); } } HttpClient(); HttpResponse request(HttpRequest httpRequest); void disconnect(); }
HttpClient { @VisibleForTesting void write(OutputStream outputStream, byte[] content) throws IOException { try { outputStream.write(content); outputStream.flush(); } finally { Closeables.close(outputStream, true); } } HttpClient(); HttpResponse request(HttpRequest httpRequest); void disconnect();  }