use of com.twitter.distributedlog.exceptions.InternalServerException in project distributedlog by twitter.
the class TestStreamOp method testResponseFailedTwice.
@Test(timeout = 60000)
public void testResponseFailedTwice() throws Exception {
WriteOp writeOp = getWriteOp();
writeOp.fail(new InternalServerException("test1"));
writeOp.fail(new InternalServerException("test2"));
WriteResponse response = Await.result(writeOp.result());
assertEquals(StatusCode.INTERNAL_SERVER_ERROR, response.getHeader().getCode());
assertEquals(ResponseUtils.exceptionToHeader(new InternalServerException("test1")), response.getHeader());
}
use of com.twitter.distributedlog.exceptions.InternalServerException 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