diff options
Diffstat (limited to 'guava-tests/test/com/google/common/eventbus/EventHandlerTest.java')
-rw-r--r-- | guava-tests/test/com/google/common/eventbus/EventHandlerTest.java | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/guava-tests/test/com/google/common/eventbus/EventHandlerTest.java b/guava-tests/test/com/google/common/eventbus/EventHandlerTest.java index bdbc332..00a189a 100644 --- a/guava-tests/test/com/google/common/eventbus/EventHandlerTest.java +++ b/guava-tests/test/com/google/common/eventbus/EventHandlerTest.java @@ -16,12 +16,9 @@ package com.google.common.eventbus; -import com.google.common.testing.EqualsTester; - -import junit.framework.TestCase; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import junit.framework.TestCase; /** * Test case for {@link EventHandler}. @@ -59,6 +56,31 @@ public class EventHandlerTest extends TestCase { methodArgument == FIXTURE_ARGUMENT); } + /** + * Checks that EventHandler's constructor disallows null methods. + */ + public void testRejectionOfNullMethods() { + try { + new EventHandler(this, null); + fail("EventHandler must immediately reject null methods."); + } catch (NullPointerException e) { + // Hooray! + } + } + + /** + * Checks that EventHandler's constructor disallows null targets. + */ + public void testRejectionOfNullTargets() { + Method method = getRecordingMethod(); + try { + new EventHandler(null, method); + fail("EventHandler must immediately reject null targets."); + } catch (NullPointerException e) { + // Huzzah! + } + } + public void testExceptionWrapping() { Method method = getExceptionThrowingMethod(); EventHandler handler = new EventHandler(this, method); @@ -84,17 +106,6 @@ public class EventHandlerTest extends TestCase { } } - public void testEquals() throws Exception { - Method charAt = String.class.getMethod("charAt", int.class); - Method concat = String.class.getMethod("concat", String.class); - new EqualsTester() - .addEqualityGroup( - new EventHandler("foo", charAt), new EventHandler("foo", charAt)) - .addEqualityGroup(new EventHandler("bar", charAt)) - .addEqualityGroup(new EventHandler("foo", concat)) - .testEquals(); - } - /** * Gets a reference to {@link #recordingMethod(Object)}. * |