use of com.lmax.disruptor.dsl.stubs.ExceptionThrowingEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportSpecifyingADefaultExceptionHandlerForEventProcessors.
@Test
public void shouldSupportSpecifyingADefaultExceptionHandlerForEventProcessors() throws Exception {
AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>();
ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled);
RuntimeException testException = new RuntimeException();
ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException);
disruptor.setDefaultExceptionHandler(exceptionHandler);
disruptor.handleEventsWith(handler);
publishEvent();
final Throwable actualException = waitFor(eventHandled);
assertSame(testException, actualException);
}
use of com.lmax.disruptor.dsl.stubs.ExceptionThrowingEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportSpecifyingAExceptionHandlerForEventProcessors.
@Test
public void shouldSupportSpecifyingAExceptionHandlerForEventProcessors() throws Exception {
AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>();
ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled);
RuntimeException testException = new RuntimeException();
ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException);
disruptor.handleExceptionsWith(exceptionHandler);
disruptor.handleEventsWith(handler);
publishEvent();
final Throwable actualException = waitFor(eventHandled);
assertSame(testException, actualException);
}
use of com.lmax.disruptor.dsl.stubs.ExceptionThrowingEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldApplyDefaultExceptionHandlerToExistingEventProcessors.
@Test
public void shouldApplyDefaultExceptionHandlerToExistingEventProcessors() throws Exception {
AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>();
ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled);
RuntimeException testException = new RuntimeException();
ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException);
disruptor.handleEventsWith(handler);
disruptor.setDefaultExceptionHandler(exceptionHandler);
publishEvent();
final Throwable actualException = waitFor(eventHandled);
assertSame(testException, actualException);
}
use of com.lmax.disruptor.dsl.stubs.ExceptionThrowingEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldBeAbleToOverrideTheExceptionHandlerForAEventProcessor.
@Test
public void shouldBeAbleToOverrideTheExceptionHandlerForAEventProcessor() throws Exception {
final RuntimeException testException = new RuntimeException();
final ExceptionThrowingEventHandler eventHandler = new ExceptionThrowingEventHandler(testException);
disruptor.handleEventsWith(eventHandler);
AtomicReference<Throwable> reference = new AtomicReference<Throwable>();
StubExceptionHandler exceptionHandler = new StubExceptionHandler(reference);
disruptor.handleExceptionsFor(eventHandler).with(exceptionHandler);
publishEvent();
waitFor(reference);
}
use of com.lmax.disruptor.dsl.stubs.ExceptionThrowingEventHandler in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldOnlyApplyExceptionsHandlersSpecifiedViaHandleExceptionsWithOnNewEventProcessors.
@Test
public void shouldOnlyApplyExceptionsHandlersSpecifiedViaHandleExceptionsWithOnNewEventProcessors() throws Exception {
AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>();
ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled);
RuntimeException testException = new RuntimeException();
ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException);
disruptor.handleExceptionsWith(exceptionHandler);
disruptor.handleEventsWith(handler);
disruptor.handleExceptionsWith(new FatalExceptionHandler());
publishEvent();
final Throwable actualException = waitFor(eventHandled);
assertSame(testException, actualException);
}
Aggregations