コード例 #1
0
  @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());
  }
コード例 #2
0
  @Test
  public void testPropagateToChildWithListenerMethods() {
    MultipleListeners listener = new MultipleListeners();

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

    assertNull(listener.theIntegerEvent);
    assertNull(listener.theIntegerPayload);
    assertNotNull(listener.theStringEvent);
    assertEquals("Hello World", listener.theStringEvent.getPayload());
    assertEquals("Hello World", listener.theStringPayload);
  }
コード例 #3
0
  @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);
  }