use of net.morimekta.testing.concurrent.FakeScheduledExecutor in project providence by morimekta.
the class QueuedFileMessageWriterTest method testFailedWrite.
@Test
public void testFailedWrite() throws IOException {
MessageWriter target = mock(MessageWriter.class);
FakeClock clock = new FakeClock();
long start = clock.millis();
FakeScheduledExecutor executor = new FakeScheduledExecutor(clock);
QueuedMessageWriter writer = new FakeQueuedMessageWriter(target, executor, clock);
writer.write(new CompactFields("foo", 42, "bar"));
writer.write(new CompactFields("foo", 42, "bar"));
when(target.write(any(CompactFields.class))).thenThrow(new IOException());
when(target.write(any(CompactFields.class))).thenAnswer(i -> {
executor.shutdown();
throw new IOException();
});
clock.tick(1);
assertThat(clock.millis() - start, is(138L));
verify(target).write(any(CompactFields.class));
verify(target).write(any(CompactFields.class));
verifyNoMoreInteractions(target);
}
Aggregations