@Test
public void shouldExhaustRetries() throws TransportException, IOException {

  Sink sink = mock(Sink.class);
  TcpTransport transport = new TcpTransport(sink, 4, 0);
  TcpTransportBuffer transportBuffer = mock(TcpTransportBuffer.class);
  Buffer buffer = new Buffer();
  when(transportBuffer.getInternalBuffer()).thenReturn(buffer);
  doThrow(new IOException()).when(sink).write(eq(buffer), eq(0L));
  try {
    transport.sendBatch(transportBuffer);
    fail("Should exhaust retries");
  } catch (TransportException ex) {
    assertTrue(ex.getCause() instanceof RetriesExhaustedException);
  }
  verify(sink, times(5)).write(eq(buffer), eq(0L));
}