@Test public void testEventClassHierarchySticky() { eventBus.postSticky("Hello"); eventBus.postSticky(new MyEvent()); eventBus.postSticky(new MyEventExtended()); eventBus.register(new StickySubscriber()); assertEquals(1, countMyEventExtended); assertEquals(1, countMyEvent); assertEquals(0, countObjectEvent); }
@Test public void testPostStickyTwice() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.postSticky("NewSticky"); eventBus.register(this); assertEquals("NewSticky", lastEvent); }
@Test public void testPostStickyTwoEvents() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.postSticky(new IntTestEvent(7)); eventBus.register(this); assertEquals(2, eventCount.intValue()); }
@Test public void testEventClassHierarchySticky() { eventBus.postSticky("Hello"); eventBus.postSticky(new MyEvent()); eventBus.postSticky(new MyEventExtended()); eventBus.register(new StickySubscriber()); assertEquals(1, countMyEventExtended); assertEquals(2, countMyEvent); assertEquals(3, countObjectEvent); }
@Test public void testPostSticky() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.register(this); assertEquals("Sticky", lastEvent); assertEquals(Thread.currentThread(), lastThread); }
@Test public void testPostStickyRegisterNonSticky() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.register(new NonStickySubscriber()); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); }
@Test public void testEventClassHierarchySticky() { eventBus.postSticky("Hello"); eventBus.postSticky(new MyEvent()); eventBus.postSticky(new MyEventExtended()); eventBus.register(new StickySubscriber()); assertEquals(1, countMyEventExtended); assertEquals(1, countMyEvent); assertEquals(0, countObjectEvent); }
@Test public void testPostStickyTwice() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.postSticky("NewSticky"); eventBus.register(this); assertEquals("NewSticky", lastEvent); }
@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 testPostStickyTwoEvents() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.postSticky(new IntTestEvent(7)); eventBus.register(this); assertEquals(2, 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()); }
@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 testPostStickyAndGet() throws InterruptedException { eventBus.postSticky("Sticky"); assertEquals("Sticky", eventBus.getStickyEvent(String.class)); }
@Test public void testPostSticky() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.register(this); assertEquals("Sticky", lastEvent); assertEquals(Thread.currentThread(), lastThread); }
@Test public void testPostStickyRegisterNonSticky() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.register(new NonStickySubscriber()); assertNull(lastEvent); assertEquals(0, eventCount.intValue()); }
@Test public void testPostStickyThenPostNormal() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.post("NonSticky"); eventBus.register(this); assertEquals("Sticky", lastEvent); }
@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 testPostStickyRemoveClass() throws InterruptedException { eventBus.postSticky("Sticky"); eventBus.removeStickyEvent(String.class); assertNull(eventBus.getStickyEvent(String.class)); eventBus.register(this); assertNull(lastEvent); assertEquals(0, 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)); }