public int getCount(String beanName) { AtomicInteger c = count.get(beanName); if (c != null) { return c.intValue(); } else { return 0; } } }
public void testSubscriberLegalAbstract() { eventBus.register(new AbstractImpl()); eventBus.post("42"); assertEquals(1, eventCount.intValue()); }
@Test public void testSubscriberLegal() { eventBus.register(this); eventBus.post("42"); eventBus.unregister(this); assertEquals(1, eventCount.intValue()); }
@Test public void testPostStickyTwoEvents() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.postSticky(new IntTestEvent(7)); eventBus.register(this); assertEquals(2, eventCount.intValue()); }
@Test public void testCancel() { Subscriber canceler = new Subscriber(1, true); eventBus.register(new Subscriber(0, false)); eventBus.register(canceler); eventBus.register(new Subscriber(0, false)); eventBus.post("42"); assertEquals(1, eventCount.intValue()); eventBus.unregister(canceler); eventBus.post("42"); assertEquals(1 + 2, eventCount.intValue()); }
@Test public void testCancelWrongEvent() { eventBus.register(new SubscriberCancelOtherEvent()); eventBus.post("42"); assertEquals(0, eventCount.intValue()); assertNotNull(failed); }
@Test public void testPostStickyRegisterNonSticky() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.register(new NonStickySubscriber()); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); }
@Test public void testPostStickyRemoveClass() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.removeStickyEvent(String.class); assertNull(eventBus.getStickyEvent(String.class)); eventBus.register(this); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); }
public void testSubscriberLegalAbstract() { eventBus.register(new AbstractImpl()); eventBus.post("42"); assertEquals(1, eventCount.intValue()); }
@Test public void testCancelInBetween() { eventBus.register(new Subscriber(2, true)); eventBus.register(new Subscriber(1, false)); eventBus.register(new Subscriber(3, false)); eventBus.post("42"); assertEquals(2, eventCount.intValue()); }
@Test public void testPostStickyRemoveEvent() throws InterruptedException { eventBus.postSticky("Sticky"); assertTrue(eventBus.removeStickyEvent("Sticky")); assertNull(eventBus.getStickyEvent(String.class)); eventBus.register(this); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); }
@Test public void testRemoveStickyEventInSubscriber() throws InterruptedException { eventBus.register(new RemoveStickySubscriber()); eventBus.postSticky("Sticky"); eventBus.register(this); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); assertNull(eventBus.getStickyEvent(String.class)); }
@Test public void testSubscriberLegal() { eventBus.register(this); eventBus.post("42"); eventBus.unregister(this); assertEquals(1, eventCount.intValue()); }
@Test public void testPostNonStickyRegisterSticky() throws InterruptedException { eventBus.post("NonSticky"); eventBus.register(this); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); }
@Test public void testPostStickyRemoveAll() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.postSticky(new IntTestEvent(77)); eventBus.removeAllStickyEvents(); assertNull(eventBus.getStickyEvent(String.class)); assertNull(eventBus.getStickyEvent(IntTestEvent.class)); eventBus.register(this); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); }
@Test public void testCancel() { Subscriber canceler = new Subscriber(1, true); eventBus.register(new Subscriber(0, false)); eventBus.register(canceler); eventBus.register(new Subscriber(0, false)); eventBus.post("42"); assertEquals(1, eventCount.intValue()); eventBus.unregister(canceler); eventBus.post("42"); assertEquals(1 + 2, eventCount.intValue()); }
@Test public void testPostStickyTwoEvents() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.postSticky(new IntTestEvent(7)); eventBus.register(this); assertEquals(2, eventCount.intValue()); }
@Test public void testRemoveStickyEventInSubscriber() throws InterruptedException { eventBus.register(new RemoveStickySubscriber()); eventBus.postSticky("Sticky"); eventBus.register(this); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); assertNull(eventBus.getStickyEvent(String.class)); }
@Test public void testCancelInBetween() { eventBus.register(new Subscriber(2, true)); eventBus.register(new Subscriber(1, false)); eventBus.register(new Subscriber(3, false)); eventBus.post("42"); assertEquals(2, eventCount.intValue()); }
@Test public void testPostStickyRemoveAll() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.postSticky(new IntTestEvent(77)); eventBus.removeAllStickyEvents(); assertNull(eventBus.getStickyEvent(String.class)); assertNull(eventBus.getStickyEvent(IntTestEvent.class)); eventBus.register(this); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); }