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); }
public void removeTreeModelListener(TreeModelListener listener) { this.listener = EventMulticaster.remove(this.listener, listener); }
public void addTreeModelListener(TreeModelListener listener) { this.listener = EventMulticaster.add(this.listener, listener); }