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();  }
@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)); }