summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-04 21:40:11 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-04 21:40:11 +0200
commitfe019e5eae8d8e740d7620044727988c6d28a423 (patch)
tree57730f84b89863252cd70cdc59cce1fc20f85196
parentd559e1707722a4cd04a70185520f31e94ff26b18 (diff)
downloadJRummikub-fe019e5eae8d8e740d7620044727988c6d28a423.tar
JRummikub-fe019e5eae8d8e740d7620044727988c6d28a423.zip
Make mock events emittable
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@123 72836036-5685-4462-b002-a69064685172
-rw-r--r--test/jrummikub/util/MockEvent.java22
-rw-r--r--test/jrummikub/util/MockEvent1.java6
-rw-r--r--test/jrummikub/util/MockEvent2.java6
3 files changed, 26 insertions, 8 deletions
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<IListener> listeners = new HashSet<IListener>();
-
+
+ @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<T> implements IEvent1<T> {
public void remove(IListener1<T> listener) {
listeners.remove(listener);
}
+
+ public void emit(T value) {
+ for (IListener1<T> 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<T1, T2> implements IEvent2<T1, T2> {
public void remove(IListener2<T1, T2> listener) {
listeners.remove(listener);
}
+
+ public void emit(T1 value1, T2 value2) {
+ for (IListener2<T1, T2> listener : listeners) {
+ listener.handle(value1, value2);
+ }
+ }
}