From fe019e5eae8d8e740d7620044727988c6d28a423 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 4 May 2011 21:40:11 +0200 Subject: Make mock events emittable git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@123 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/util/MockEvent.java | 22 ++++++++++++++-------- test/jrummikub/util/MockEvent1.java | 6 ++++++ test/jrummikub/util/MockEvent2.java | 6 ++++++ 3 files changed, 26 insertions(+), 8 deletions(-) (limited to 'test/jrummikub/util') diff --git a/test/jrummikub/util/MockEvent.java b/test/jrummikub/util/MockEvent.java index 85f2c28..2f0efe5 100644 --- a/test/jrummikub/util/MockEvent.java +++ b/test/jrummikub/util/MockEvent.java @@ -4,14 +4,20 @@ import java.util.HashSet; public class MockEvent implements IEvent { public HashSet listeners = new HashSet(); - + + @Override + public void add(IListener listener) { + listeners.add(listener); + } + @Override - public void add(IListener listener) { - listeners.add(listener); - } + public void remove(IListener listener) { + listeners.remove(listener); + } - @Override - public void remove(IListener listener) { - listeners.remove(listener); - } + public void emit() { + for (IListener listener : listeners) { + listener.handle(); + } + } } diff --git a/test/jrummikub/util/MockEvent1.java b/test/jrummikub/util/MockEvent1.java index 36af527..74cae0f 100644 --- a/test/jrummikub/util/MockEvent1.java +++ b/test/jrummikub/util/MockEvent1.java @@ -14,4 +14,10 @@ public class MockEvent1 implements IEvent1 { public void remove(IListener1 listener) { listeners.remove(listener); } + + public void emit(T value) { + for (IListener1 listener : listeners) { + listener.handle(value); + } + } } diff --git a/test/jrummikub/util/MockEvent2.java b/test/jrummikub/util/MockEvent2.java index 4f01372..93e8228 100644 --- a/test/jrummikub/util/MockEvent2.java +++ b/test/jrummikub/util/MockEvent2.java @@ -14,4 +14,10 @@ public class MockEvent2 implements IEvent2 { public void remove(IListener2 listener) { listeners.remove(listener); } + + public void emit(T1 value1, T2 value2) { + for (IListener2 listener : listeners) { + listener.handle(value1, value2); + } + } } -- cgit v1.2.3