use of com.twitter.distributedlog.service.stream.WriteOp in project distributedlog by twitter.
the class TestStreamOp method testResponseSucceededThenFailed.
@Test(timeout = 60000)
public void testResponseSucceededThenFailed() throws Exception {
AsyncLogWriter writer = mock(AsyncLogWriter.class);
when(writer.write((LogRecord) any())).thenReturn(Future.value(new DLSN(1, 2, 3)));
when(writer.getStreamName()).thenReturn("test");
WriteOp writeOp = getWriteOp();
writeOp.execute(writer, new Sequencer() {
public long nextId() {
return 0;
}
}, new Object());
writeOp.fail(new InternalServerException("test2"));
WriteResponse response = Await.result(writeOp.result());
assertEquals(StatusCode.SUCCESS, response.getHeader().getCode());
}
Aggregations