@Override public void postFromTransaction(final BusEvent event, final Transmogrifier transmogrifier) throws EventBusException { checkInitialized("postFromTransaction"); delegate.post(event); }
@Override public void unregister(final Object handlerInstance) throws EventBusException { checkInitialized("unregister"); delegate.unregister(handlerInstance); }
@Override public void register(final Object handlerInstance) throws EventBusException { checkInitialized("register"); delegate.register(handlerInstance); }
public void testSimpleWithExceptionAndRetrySuccess() { try { final MyEventHandler handler = new MyEventHandler(1, 1); eventBus.register(handler); eventBus.post(new MyEvent("my-event", 1L, "MY_EVENT_TYPE", 1L, 2L, UUID.randomUUID())); final boolean completed = handler.waitForCompletion(5000); Assert.assertEquals(completed, true); } catch (Exception ignored) { } }
@Override @BeforeClass(groups = "slow") public void beforeClass() throws Exception { super.beforeClass(); busService = new DefaultPersistentBus(getDBI(), clock, getPersistentBusConfig(), metricRegistry); testEventBusBase = new TestEventBusBase(busService); }
@Override public PersistentBus get() { return new DefaultPersistentBus(dbi, clock, busConfig, metricRegistry); } }
@BeforeClass(groups = "fast") public void beforeClass() throws Exception { busService = new InMemoryPersistentBus(); testEventBusBase = new TestEventBusBase(busService); }
@Test(groups = "fast") public void testSimple() { testEventBusBase.testSimple(); }
public void completeDispatch() { dispatchQueuedEvents(); }
@Override public void stop() { if (isStarted.compareAndSet(true, false)) { stopQueue(); } }
@Override public void unregister(final Object handlerInstance) throws EventBusException { if (isStarted.get()) { eventBusDelegate.unregister(handlerInstance); } else { log.warn("Attempting to unregister handler " + handlerInstance + " in a non initialized bus"); } }
@Test(groups = "slow") public void testSimpleWithExceptionAndFail() { testEventBusBase.testSimpleWithExceptionAndFail(); } }
@Test(groups = "fast") public void testDifferentType() { testEventBusBase.testDifferentType(); } }
@Subscribe public synchronized void processMyEvent(final MyEvent event) { //log.debug("Got event {} {}", event.name, event.value); if (gotExceptions < nbThrowExceptions) { gotExceptions++; throw new MyEventHandlerException("FAIL"); } gotEvents++; }
@Test(groups = "slow") public void testSimpleWithExceptionAndRetrySuccess() { testEventBusBase.testSimpleWithExceptionAndRetrySuccess(); }
public void testSimpleWithExceptionAndFail() { try { final MyEventHandler handler = new MyEventHandler(1, 4); eventBus.register(handler); eventBus.post(new MyEvent("my-event", 1L, "MY_EVENT_TYPE", 1L, 2L, UUID.randomUUID())); final boolean completed = handler.waitForCompletion(5000); Assert.assertEquals(completed, false); } catch (Exception ignored) { } }
@Override public void post(final BusEvent event) throws EventBusException { checkInitialized("post"); delegate.post(event); }
@Test(groups = "slow") public void testSimple() { testEventBusBase.testSimple(); }
public void testDifferentType() { try { final MyEventHandler handler = new MyEventHandler(1, 0); eventBus.register(handler); for (int i = 0; i < 5; i++) { eventBus.post(new MyOtherEvent("my-other-event", (double) i, "MY_EVENT_TYPE", 1L, 2L, UUID.randomUUID())); } eventBus.post(new MyEvent("my-event", 11l, "MY_EVENT_TYPE", 1L, 2L, UUID.randomUUID())); final boolean completed = handler.waitForCompletion(10000); Assert.assertEquals(completed, true); } catch (Exception e) { Assert.fail("", e); } } }
public void testSimple() { try { final int nbEvents = 5; final MyEventHandler handler = new MyEventHandler(nbEvents, 0); eventBus.register(handler); for (int i = 0; i < nbEvents; i++) { eventBus.post(new MyEvent("my-event", (long) i, "MY_EVENT_TYPE", 1L, 2L, UUID.randomUUID())); } final boolean completed = handler.waitForCompletion(10000); Assert.assertEquals(completed, true); } catch (Exception e) { Assert.fail("", e); } }