use of com.lmax.disruptor.support.DummySequenceBarrier in project disruptor by LMAX-Exchange.
the class TimeoutBlockingWaitStrategyTest method shouldTimeoutWaitFor.
@Test
public void shouldTimeoutWaitFor() throws Exception {
final SequenceBarrier sequenceBarrier = new DummySequenceBarrier();
long theTimeout = 500;
TimeoutBlockingWaitStrategy waitStrategy = new TimeoutBlockingWaitStrategy(theTimeout, TimeUnit.MILLISECONDS);
Sequence cursor = new Sequence(5);
Sequence dependent = cursor;
long t0 = System.currentTimeMillis();
try {
waitStrategy.waitFor(6, cursor, dependent, sequenceBarrier);
fail("TimeoutException should have been thrown");
} catch (TimeoutException e) {
}
long t1 = System.currentTimeMillis();
long timeWaiting = t1 - t0;
assertTrue(timeWaiting >= theTimeout);
}
use of com.lmax.disruptor.support.DummySequenceBarrier 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.DummySequenceBarrier in project disruptor by LMAX-Exchange.
the class LiteTimeoutBlockingWaitStrategyTest method shouldTimeoutWaitFor.
@Test
public void shouldTimeoutWaitFor() throws Exception {
final SequenceBarrier sequenceBarrier = new DummySequenceBarrier();
long theTimeout = 500;
LiteTimeoutBlockingWaitStrategy waitStrategy = new LiteTimeoutBlockingWaitStrategy(theTimeout, TimeUnit.MILLISECONDS);
Sequence cursor = new Sequence(5);
Sequence dependent = cursor;
long t0 = System.currentTimeMillis();
try {
waitStrategy.waitFor(6, cursor, dependent, sequenceBarrier);
fail("TimeoutException should have been thrown");
} catch (TimeoutException e) {
}
long t1 = System.currentTimeMillis();
long timeWaiting = t1 - t0;
assertTrue(timeWaiting >= theTimeout);
}
Aggregations