use of com.lmax.disruptor.support.TestEvent in project disruptor by LMAX-Exchange.
the class FatalExceptionHandlerTest method shouldHandleFatalException.
@Test
public void shouldHandleFatalException() {
final Exception causeException = new Exception();
final TestEvent event = new TestEvent();
ExceptionHandler<Object> exceptionHandler = new FatalExceptionHandler();
try {
exceptionHandler.handleEventException(causeException, 0L, event);
} catch (RuntimeException ex) {
Assert.assertEquals(causeException, ex.getCause());
}
}
use of com.lmax.disruptor.support.TestEvent in project disruptor by LMAX-Exchange.
the class IgnoreExceptionHandlerTest method shouldHandleAndIgnoreException.
@Test
public void shouldHandleAndIgnoreException() {
final Exception ex = new Exception();
final TestEvent event = new TestEvent();
ExceptionHandler<Object> exceptionHandler = new IgnoreExceptionHandler();
exceptionHandler.handleEventException(ex, 0L, event);
}
use of com.lmax.disruptor.support.TestEvent in project disruptor by LMAX-Exchange.
the class ConsumerRepositoryTest method setUp.
@Before
public void setUp() throws Exception {
consumerRepository = new ConsumerRepository<TestEvent>();
eventProcessor1 = new DummyEventProcessor(new Sequence());
eventProcessor2 = new DummyEventProcessor(new Sequence());
eventProcessor1.run();
eventProcessor2.run();
handler1 = new SleepingEventHandler();
handler2 = new SleepingEventHandler();
barrier1 = new DummySequenceBarrier();
barrier2 = new DummySequenceBarrier();
}
use of com.lmax.disruptor.support.TestEvent in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldWaitUntilAllFirstEventProcessorsProcessEventBeforeMakingItAvailableToDependentEventProcessors.
@Test
public void shouldWaitUntilAllFirstEventProcessorsProcessEventBeforeMakingItAvailableToDependentEventProcessors() throws Exception {
DelayedEventHandler eventHandler1 = createDelayedEventHandler();
CountDownLatch countDownLatch = new CountDownLatch(2);
EventHandler<TestEvent> eventHandler2 = new EventHandlerStub<TestEvent>(countDownLatch);
disruptor.handleEventsWith(eventHandler1).then(eventHandler2);
ensureTwoEventsProcessedAccordingToDependencies(countDownLatch, eventHandler1);
}
use of com.lmax.disruptor.support.TestEvent in project disruptor by LMAX-Exchange.
the class DisruptorTest method shouldSupportCustomProcessorsAsDependencies.
@Test
public void shouldSupportCustomProcessorsAsDependencies() throws Exception {
RingBuffer<TestEvent> ringBuffer = disruptor.getRingBuffer();
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
CountDownLatch countDownLatch = new CountDownLatch(2);
EventHandler<TestEvent> handlerWithBarrier = new EventHandlerStub<TestEvent>(countDownLatch);
final BatchEventProcessor<TestEvent> processor = new BatchEventProcessor<TestEvent>(ringBuffer, ringBuffer.newBarrier(), delayedEventHandler);
disruptor.handleEventsWith(processor).then(handlerWithBarrier);
ensureTwoEventsProcessedAccordingToDependencies(countDownLatch, delayedEventHandler);
}
Aggregations