Search in sources :

Example 1 with TestWorkHandler

use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.

the class DisruptorTest method shouldProvideEventsToWorkHandlers.

@Test
public void shouldProvideEventsToWorkHandlers() throws Exception {
    final TestWorkHandler workHandler1 = createTestWorkHandler();
    final TestWorkHandler workHandler2 = createTestWorkHandler();
    disruptor.handleEventsWithWorkerPool(workHandler1, workHandler2);
    publishEvent();
    publishEvent();
    workHandler1.processEvent();
    workHandler2.processEvent();
}
Also used : TestWorkHandler(com.lmax.disruptor.dsl.stubs.TestWorkHandler) Test(org.junit.Test)

Example 2 with TestWorkHandler

use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.

the class DisruptorTest method shouldSupportCombiningWorkerPoolWithEventHandlerAsDependencyWhenNotPreviouslyRegistered.

@Test
public void shouldSupportCombiningWorkerPoolWithEventHandlerAsDependencyWhenNotPreviouslyRegistered() throws Exception {
    final TestWorkHandler workHandler1 = createTestWorkHandler();
    final DelayedEventHandler delayedEventHandler1 = createDelayedEventHandler();
    final DelayedEventHandler delayedEventHandler2 = createDelayedEventHandler();
    disruptor.handleEventsWith(delayedEventHandler1).and(disruptor.handleEventsWithWorkerPool(workHandler1)).then(delayedEventHandler2);
    publishEvent();
    publishEvent();
    delayedEventHandler1.processEvent();
    delayedEventHandler1.processEvent();
    workHandler1.processEvent();
    delayedEventHandler2.processEvent();
    workHandler1.processEvent();
    delayedEventHandler2.processEvent();
}
Also used : TestWorkHandler(com.lmax.disruptor.dsl.stubs.TestWorkHandler) DelayedEventHandler(com.lmax.disruptor.dsl.stubs.DelayedEventHandler) Test(org.junit.Test)

Example 3 with TestWorkHandler

use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.

the class DisruptorTest method createTestWorkHandler.

private TestWorkHandler createTestWorkHandler() {
    final TestWorkHandler testWorkHandler = new TestWorkHandler();
    testWorkHandlers.add(testWorkHandler);
    return testWorkHandler;
}
Also used : TestWorkHandler(com.lmax.disruptor.dsl.stubs.TestWorkHandler)

Example 4 with TestWorkHandler

use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.

the class DisruptorTest method tearDown.

@After
public void tearDown() throws Exception {
    for (DelayedEventHandler delayedEventHandler : delayedEventHandlers) {
        delayedEventHandler.stopWaiting();
    }
    for (TestWorkHandler testWorkHandler : testWorkHandlers) {
        testWorkHandler.stopWaiting();
    }
    disruptor.halt();
    executor.joinAllThreads();
}
Also used : TestWorkHandler(com.lmax.disruptor.dsl.stubs.TestWorkHandler) DelayedEventHandler(com.lmax.disruptor.dsl.stubs.DelayedEventHandler) After(org.junit.After)

Example 5 with TestWorkHandler

use of com.lmax.disruptor.dsl.stubs.TestWorkHandler in project disruptor by LMAX-Exchange.

the class DisruptorTest method shouldSupportUsingWorkerPoolAsDependency.

@Test
public void shouldSupportUsingWorkerPoolAsDependency() throws Exception {
    final TestWorkHandler workHandler1 = createTestWorkHandler();
    final TestWorkHandler workHandler2 = createTestWorkHandler();
    final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
    disruptor.handleEventsWithWorkerPool(workHandler1, workHandler2).then(delayedEventHandler);
    publishEvent();
    publishEvent();
    assertThat(disruptor.getBarrierFor(delayedEventHandler).getCursor(), equalTo(-1L));
    workHandler2.processEvent();
    workHandler1.processEvent();
    delayedEventHandler.processEvent();
}
Also used : TestWorkHandler(com.lmax.disruptor.dsl.stubs.TestWorkHandler) DelayedEventHandler(com.lmax.disruptor.dsl.stubs.DelayedEventHandler) Test(org.junit.Test)

Aggregations

TestWorkHandler (com.lmax.disruptor.dsl.stubs.TestWorkHandler)9 Test (org.junit.Test)7 DelayedEventHandler (com.lmax.disruptor.dsl.stubs.DelayedEventHandler)5 TestEvent (com.lmax.disruptor.support.TestEvent)1 After (org.junit.After)1