diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-10 03:54:48 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-10 03:54:48 +0200 |
commit | 3b49b2053e9f9d26b73db0ffc8380a60706ee095 (patch) | |
tree | 9678d5abb4af070bbf0fd89c684e91f5fd472c31 /test/jrummikub/util | |
parent | 4a860e53cf6f2f97f18785673399498609e6504b (diff) | |
download | JRummikub-3b49b2053e9f9d26b73db0ffc8380a60706ee095.tar JRummikub-3b49b2053e9f9d26b73db0ffc8380a60706ee095.zip |
Added all missing comments
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@213 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/util')
-rw-r--r-- | test/jrummikub/util/Event1Test.java | 205 | ||||
-rw-r--r-- | test/jrummikub/util/Event2Test.java | 219 | ||||
-rw-r--r-- | test/jrummikub/util/EventTest.java | 8 |
3 files changed, 226 insertions, 206 deletions
diff --git a/test/jrummikub/util/Event1Test.java b/test/jrummikub/util/Event1Test.java index c3f388e..6d61882 100644 --- a/test/jrummikub/util/Event1Test.java +++ b/test/jrummikub/util/Event1Test.java @@ -4,105 +4,112 @@ import static org.junit.Assert.*; import org.junit.Test; +/** + * Test class for {@link Event1} + */ public class Event1Test { - int fired, fired2; - - @Test - public void singleListener() { - fired = 0; - Event1<Integer> testEvent = new Event1<Integer>(); - testEvent.add(new IListener1<Integer>() { - - @Override - public void handle(Integer n) { - fired += n; - - } - }); - assertEquals(fired, 0); - testEvent.emit(10); - assertEquals(fired, 10); - testEvent.emit(20); - assertEquals(fired, 30); - } - - @Test - public void twoListeners() { - fired = 0; - fired2 = 0; - Event1<Integer> testEvent = new Event1<Integer>(); - testEvent.add(new IListener1<Integer>() { - - @Override - public void handle(Integer n) { - fired += n; - - } - }); - testEvent.add(new IListener1<Integer>() { - - @Override - public void handle(Integer n) { - fired2 -= n; - - } - }); - assertEquals(fired, 0); - assertEquals(fired2, 0); - testEvent.emit(5); - assertEquals(fired, 5); - assertEquals(fired2, -5); - - } - - @Test - public void removeListener() { - fired = 0; - Event1<Integer> testEvent = new Event1<Integer>(); - testEvent.add(new IListener1<Integer>() { - - @Override - public void handle(Integer n) { - fired += n; - - } - }); - IListener1<Integer> rem = new IListener1<Integer>() { - - @Override - public void handle(Integer n) { - fail(); - } - }; - testEvent.add(rem); - testEvent.remove(rem); - testEvent.emit(10); - assertEquals(fired, 10); - } - - @Test - public void removeListenerByConnection() { - fired = 0; - Event1<Integer> testEvent = new Event1<Integer>(); - testEvent.add(new IListener1<Integer>() { - - @Override - public void handle(Integer n) { - fired += n; - - } - }); - IListener1<Integer> rem = new IListener1<Integer>() { - - @Override - public void handle(Integer n) { - fail(); - } - }; - Connection connection = testEvent.add(rem); - connection.remove(); - testEvent.emit(10); - assertEquals(fired, 10); - } + int fired, fired2; + + /** */ + @Test + public void singleListener() { + fired = 0; + Event1<Integer> testEvent = new Event1<Integer>(); + testEvent.add(new IListener1<Integer>() { + + @Override + public void handle(Integer n) { + fired += n; + + } + }); + assertEquals(fired, 0); + testEvent.emit(10); + assertEquals(fired, 10); + testEvent.emit(20); + assertEquals(fired, 30); + } + + /** */ + @Test + public void twoListeners() { + fired = 0; + fired2 = 0; + Event1<Integer> testEvent = new Event1<Integer>(); + testEvent.add(new IListener1<Integer>() { + + @Override + public void handle(Integer n) { + fired += n; + + } + }); + testEvent.add(new IListener1<Integer>() { + + @Override + public void handle(Integer n) { + fired2 -= n; + + } + }); + assertEquals(fired, 0); + assertEquals(fired2, 0); + testEvent.emit(5); + assertEquals(fired, 5); + assertEquals(fired2, -5); + + } + + /** */ + @Test + public void removeListener() { + fired = 0; + Event1<Integer> testEvent = new Event1<Integer>(); + testEvent.add(new IListener1<Integer>() { + + @Override + public void handle(Integer n) { + fired += n; + + } + }); + IListener1<Integer> rem = new IListener1<Integer>() { + + @Override + public void handle(Integer n) { + fail(); + } + }; + testEvent.add(rem); + testEvent.remove(rem); + testEvent.emit(10); + assertEquals(fired, 10); + } + + /** */ + @Test + public void removeListenerByConnection() { + fired = 0; + Event1<Integer> testEvent = new Event1<Integer>(); + testEvent.add(new IListener1<Integer>() { + + @Override + public void handle(Integer n) { + fired += n; + + } + }); + IListener1<Integer> rem = new IListener1<Integer>() { + + @Override + public void handle(Integer n) { + fail(); + } + }; + Connection connection = testEvent.add(rem); + connection.remove(); + testEvent.emit(10); + assertEquals(fired, 10); + } } diff --git a/test/jrummikub/util/Event2Test.java b/test/jrummikub/util/Event2Test.java index c258ddf..4298729 100644 --- a/test/jrummikub/util/Event2Test.java +++ b/test/jrummikub/util/Event2Test.java @@ -4,122 +4,129 @@ import static org.junit.Assert.*; import org.junit.Test; +/** + * Test class for {@link Event2} + */ public class Event2Test { - int fired, fired2, fired3, fired4; + int fired, fired2, fired3, fired4; - @Test - public void singleListener() { - fired = 0; - fired2 = 0; - Event2<Integer, Integer> testEvent = new Event2<Integer, Integer>(); - testEvent.add(new IListener2<Integer, Integer>() { + /** */ + @Test + public void singleListener() { + fired = 0; + fired2 = 0; + Event2<Integer, Integer> testEvent = new Event2<Integer, Integer>(); + testEvent.add(new IListener2<Integer, Integer>() { - @Override - public void handle(Integer n, Integer m) { - fired += n; - fired2 += m; - } - }); - assertEquals(fired, 0); - assertEquals(fired2, 0); - testEvent.emit(10, 5); - assertEquals(fired, 10); - assertEquals(fired2, 5); - testEvent.emit(20, 45); - assertEquals(fired, 30); - assertEquals(fired2, 50); - } + @Override + public void handle(Integer n, Integer m) { + fired += n; + fired2 += m; + } + }); + assertEquals(fired, 0); + assertEquals(fired2, 0); + testEvent.emit(10, 5); + assertEquals(fired, 10); + assertEquals(fired2, 5); + testEvent.emit(20, 45); + assertEquals(fired, 30); + assertEquals(fired2, 50); + } - @Test - public void twoListeners() { - fired = 0; - fired2 = 0; - fired3 = 0; - fired4 = 0; - Event2<Integer, Integer> testEvent = new Event2<Integer, Integer>(); - testEvent.add(new IListener2<Integer, Integer>() { + /** */ + @Test + public void twoListeners() { + fired = 0; + fired2 = 0; + fired3 = 0; + fired4 = 0; + Event2<Integer, Integer> testEvent = new Event2<Integer, Integer>(); + testEvent.add(new IListener2<Integer, Integer>() { - @Override - public void handle(Integer n, Integer m) { - fired += n; - fired2 += m; - } - }); - testEvent.add(new IListener2<Integer, Integer>() { + @Override + public void handle(Integer n, Integer m) { + fired += n; + fired2 += m; + } + }); + testEvent.add(new IListener2<Integer, Integer>() { - @Override - public void handle(Integer n, Integer m) { - fired3 -= n; - fired4 -= m; - } - }); - assertEquals(fired, 0); - assertEquals(fired2, 0); - assertEquals(fired3, 0); - assertEquals(fired4, 0); - testEvent.emit(5, 10); - assertEquals(fired, 5); - assertEquals(fired2, 10); - assertEquals(fired3, -5); - assertEquals(fired4, -10); - } + @Override + public void handle(Integer n, Integer m) { + fired3 -= n; + fired4 -= m; + } + }); + assertEquals(fired, 0); + assertEquals(fired2, 0); + assertEquals(fired3, 0); + assertEquals(fired4, 0); + testEvent.emit(5, 10); + assertEquals(fired, 5); + assertEquals(fired2, 10); + assertEquals(fired3, -5); + assertEquals(fired4, -10); + } - @Test - public void removeListener() { - fired = 0; - fired2 = 0; - Event2<Integer, Integer> testEvent = new Event2<Integer, Integer>(); - testEvent.add(new IListener2<Integer, Integer>() { + /** */ + @Test + public void removeListener() { + fired = 0; + fired2 = 0; + Event2<Integer, Integer> testEvent = new Event2<Integer, Integer>(); + testEvent.add(new IListener2<Integer, Integer>() { - @Override - public void handle(Integer n, Integer m) { - fired += n; - fired2 += m; - } - }); - IListener2<Integer, Integer> rem = new IListener2<Integer, Integer>() { + @Override + public void handle(Integer n, Integer m) { + fired += n; + fired2 += m; + } + }); + IListener2<Integer, Integer> rem = new IListener2<Integer, Integer>() { - @Override - public void handle(Integer n, Integer m) { - fail(); - } - }; - assertEquals(fired, 0); - assertEquals(fired2, 0); - testEvent.add(rem); - testEvent.remove(rem); - testEvent.emit(10, 20); - assertEquals(fired, 10); - assertEquals(fired2, 20); - } - - @Test - public void removeListenerByConnection() { - fired = 0; - fired2 = 0; - Event2<Integer, Integer> testEvent = new Event2<Integer, Integer>(); - testEvent.add(new IListener2<Integer, Integer>() { + @Override + public void handle(Integer n, Integer m) { + fail(); + } + }; + assertEquals(fired, 0); + assertEquals(fired2, 0); + testEvent.add(rem); + testEvent.remove(rem); + testEvent.emit(10, 20); + assertEquals(fired, 10); + assertEquals(fired2, 20); + } - @Override - public void handle(Integer n, Integer m) { - fired += n; - fired2 += m; - } - }); - IListener2<Integer, Integer> rem = new IListener2<Integer, Integer>() { + /** */ + @Test + public void removeListenerByConnection() { + fired = 0; + fired2 = 0; + Event2<Integer, Integer> testEvent = new Event2<Integer, Integer>(); + testEvent.add(new IListener2<Integer, Integer>() { - @Override - public void handle(Integer n, Integer m) { - fail(); - } - }; - assertEquals(fired, 0); - assertEquals(fired2, 0); - Connection connection = testEvent.add(rem); - connection.remove(); - testEvent.emit(10, 20); - assertEquals(fired, 10); - assertEquals(fired2, 20); - } + @Override + public void handle(Integer n, Integer m) { + fired += n; + fired2 += m; + } + }); + IListener2<Integer, Integer> rem = new IListener2<Integer, Integer>() { + + @Override + public void handle(Integer n, Integer m) { + fail(); + } + }; + assertEquals(fired, 0); + assertEquals(fired2, 0); + Connection connection = testEvent.add(rem); + connection.remove(); + testEvent.emit(10, 20); + assertEquals(fired, 10); + assertEquals(fired2, 20); + } } diff --git a/test/jrummikub/util/EventTest.java b/test/jrummikub/util/EventTest.java index f8c505c..de2e4e6 100644 --- a/test/jrummikub/util/EventTest.java +++ b/test/jrummikub/util/EventTest.java @@ -2,10 +2,13 @@ package jrummikub.util; import org.junit.Test; import static org.junit.Assert.*; - +/** + * Test class for {@link Event} + */ public class EventTest { boolean fired, fired2; + /** */ @Test public void singleListener() { fired = false; @@ -26,6 +29,7 @@ public class EventTest { assertTrue(fired); } + /** */ @Test public void twoListeners() { fired = false; @@ -55,6 +59,7 @@ public class EventTest { } + /** */ @Test public void removeListener() { fired = false; @@ -80,6 +85,7 @@ public class EventTest { assertTrue(fired); } + /** */ @Test public void removeListenerByConnection() { fired = false; |