@Test public void testSuccessfulWrites() { MockHttpClient client = new MockHttpClient(); MockRequestBuilder requestBuilder = new MockRequestBuilder(); MockResponseHandler responseHandler = new MockResponseHandler(); MockAsyncHttpWriterBuilder builder = new MockAsyncHttpWriterBuilder(client, requestBuilder, responseHandler); TestAsyncHttpWriter asyncHttpWriter = new TestAsyncHttpWriter(builder); List<MockWriteCallback> callbacks = new ArrayList<>(); for (int i = 0; i < 4; i++) { callbacks.add(new MockWriteCallback()); } asyncHttpWriter.write(new Object(), callbacks.get(0)); asyncHttpWriter.write(new Object(), callbacks.get(1)); asyncHttpWriter.write(new Object(), callbacks.get(2)); try { asyncHttpWriter.flush(); } catch (IOException e) { Assert.fail("Flush failed"); } asyncHttpWriter.write(new Object(), callbacks.get(3)); try { asyncHttpWriter.close(); } catch (IOException e) { Assert.fail("Close failed"); } for (MockWriteCallback callback : callbacks) { Assert.assertTrue(callback.isSuccess); } Assert.assertTrue(client.isCloseCalled); Assert.assertTrue(responseHandler.recordsInLastRequest.size() == 1); }
@Override public void close() throws IOException { try { super.close(); } finally { httpClient.close(); } }
AsyncHttpWriter extends AbstractAsyncDataWriter<D> { @Override public void close() throws IOException { try { super.close(); } finally { httpClient.close(); } } }
AsyncHttpWriter extends AbstractAsyncDataWriter<D> { @Override public void close() throws IOException { try { super.close(); } finally { httpClient.close(); } } AsyncHttpWriter(AsyncHttpWriterBuilder builder); }
AsyncHttpWriter extends AbstractAsyncDataWriter<D> { @Override public void close() throws IOException { try { super.close(); } finally { httpClient.close(); } } AsyncHttpWriter(AsyncHttpWriterBuilder builder); @Override void close(); }
AsyncHttpWriter extends AbstractAsyncDataWriter<D> { @Override public void close() throws IOException { try { super.close(); } finally { httpClient.close(); } } AsyncHttpWriter(AsyncHttpWriterBuilder builder); @Override void close(); static final int DEFAULT_MAX_ATTEMPTS; }