@Test
  public void testSubscribeAndPublishWithListenerMethodsWithTopic() {
    MultipleListeners listener = new MultipleListeners();

    sessionEventBus.subscribe(listener);
    sessionEventBus.publish("shouldSucceed", this, "Hello World");
    sessionEventBus.publish("shouldSucceed.int", this, 10);

    // null because not called with topic
    assertNull(listener.theStringPayload);
    assertNull(listener.theStringEvent);
    assertNull(listener.theIntegerPayload);
    assertNull(listener.theIntegerEvent);

    // null because topic must fail
    assertNull(listener.theStringPayloadWithTopicFail);
    assertNull(listener.theIntegerPayloadWithTopicFail);
    assertNull(listener.theIntegerEventWithTopic);

    assertNotNull(listener.theStringPayloadWithTopic);
    assertNotNull(listener.theStringEventWithTopic);

    assertEquals("Hello World", listener.theStringPayloadWithTopic);
    assertEquals("Hello World", listener.theStringEventWithTopic.getPayload());
    assertEquals(10, listener.theIntegerPayloadWithTopic.intValue());
  }
  @Test
  @SuppressWarnings({"unchecked", "rawtypes"})
  public void testPublishToParentScope() {
    StringListener stringListener = mock(StringListener.class);

    applicationEventBus.subscribe(stringListener);
    sessionEventBus.publish(EventScope.APPLICATION, this, "Hello World");

    ArgumentCaptor<Event> event = ArgumentCaptor.forClass(Event.class);
    verify(stringListener).onEvent(event.capture());
    assertEquals("Hello World", event.getValue().getPayload());
  }
  @Test
  public void testPublishToParentScopeWithListenerMethods() {
    MultipleListeners listener = new MultipleListeners();

    applicationEventBus.subscribe(listener);
    sessionEventBus.publish(EventScope.APPLICATION, this, "Hello World");

    assertNull(listener.theIntegerEvent);
    assertNull(listener.theIntegerPayload);
    assertNotNull(listener.theStringEvent);
    assertEquals("Hello World", listener.theStringEvent.getPayload());
    assertEquals("Hello World", listener.theStringPayload);
  }
  @Test
  public void testSubscribeAndPublishWithListenerMethods() {
    MultipleListeners listener = new MultipleListeners();

    sessionEventBus.subscribe(listener);
    sessionEventBus.publish(this, "Hello World");

    assertNull(listener.theIntegerEvent);
    assertNull(listener.theIntegerPayload);
    assertNotNull(listener.theStringEvent);
    assertEquals("Hello World", listener.theStringEvent.getPayload());
    assertEquals("Hello World", listener.theStringPayload);
  }
  @Test
  public void testNoPropagationToChildWithListenerMethods() {
    MultipleListeners listener = new MultipleListeners();

    sessionEventBus.subscribe(listener, false);
    sessionEventBus.publish(this, "Hello World Session");
    applicationEventBus.publish(this, "Hello World Application");

    assertNull(listener.theIntegerEvent);
    assertNull(listener.theIntegerPayload);
    assertNotNull(listener.theStringEvent);
    assertEquals("Hello World Session", listener.theStringEvent.getPayload());
    assertEquals("Hello World Session", listener.theStringPayload);
  }
  @Test
  @SuppressWarnings({"unchecked", "rawtypes"})
  public void testNoPropagationToChild() {
    StringListener stringListener = mock(StringListener.class);

    sessionEventBus.subscribe(stringListener, false);
    applicationEventBus.publish(this, "Hello World");
    sessionEventBus.publish(this, "Hello World");

    ArgumentCaptor<Event> event = ArgumentCaptor.forClass(Event.class);
    verify(stringListener, only()).onEvent(event.capture());
    verifyNoMoreInteractions(stringListener);
    assertEquals("Hello World", event.getValue().getPayload());
  }