public void testAddListener() {
    EventMulticaster<Integer> multicaster = new CachingEventMulticasterImpl<Integer>();
    IntListener intListener = new IntListener();
    multicaster.addListener(intListener);
    assertEquals(0, intListener.value);
    assertEquals(0, intListener.notifications);

    multicaster = new CachingEventMulticasterImpl<Integer>();
    intListener = new IntListener();
    multicaster.broadcast(5);
    multicaster.addListener(intListener);
    assertEquals(5, intListener.value);
    assertEquals(1, intListener.notifications);
  }
 public void testBroadcastBroadcastPolicyDefault() {
   EventMulticaster<Integer> multicaster = new CachingEventMulticasterImpl<Integer>();
   IntListener intListener = new IntListener();
   multicaster.addListener(intListener);
   multicaster.broadcast(10);
   assertEquals(10, intListener.value);
   assertEquals(1, intListener.notifications);
   multicaster.broadcast(10);
   assertEquals(10, intListener.value);
   assertEquals(2, intListener.notifications);
   multicaster.broadcast(15);
   assertEquals(15, intListener.value);
   assertEquals(3, intListener.notifications);
 }
Example #3
0
 public void removeTreeModelListener(TreeModelListener listener) {
   this.listener = EventMulticaster.remove(this.listener, listener);
 }
Example #4
0
 public void addTreeModelListener(TreeModelListener listener) {
   this.listener = EventMulticaster.add(this.listener, listener);
 }