commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r666155 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryPredicate.java
Date Tue, 10 Jun 2008 15:31:53 GMT
Author: mbenson
Date: Tue Jun 10 08:31:53 2008
New Revision: 666155

URL: http://svn.apache.org/viewvc?rev=666155&view=rev
Log:
throw IllegalArgumentException on null constructor arg

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryPredicate.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java?rev=666155&r1=666154&r2=666155&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java
Tue Jun 10 08:31:53 2008
@@ -47,6 +47,9 @@
      * @param function the {@link BinaryFunction BinaryFunction} to wrap
      */
     public BinaryFunctionBinaryPredicate(BinaryFunction<? super L, ? super R, Boolean>
function) {
+        if (function == null) {
+            throw new IllegalArgumentException("BinaryFunction argument must not be null");
+        }
         this.function = function;
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryPredicate.java?rev=666155&r1=666154&r2=666155&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryPredicate.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryPredicate.java
Tue Jun 10 08:31:53 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new BinaryFunctionBinaryPredicate(new Constant(Boolean.TRUE));
+        return new BinaryFunctionBinaryPredicate<Object, Object>(Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,43 +62,21 @@
     // ------------------------------------------------------------------------
 
     public void testTestWhenTrue() throws Exception {
-        BinaryPredicate p = new BinaryFunctionBinaryPredicate(new Constant(Boolean.TRUE));
+        BinaryPredicate<Object, Object> p = new BinaryFunctionBinaryPredicate<Object,
Object>(Constant.TRUE);
         assertTrue(p.test(null,null));
     }
 
     public void testTestWhenFalse() throws Exception {
-        BinaryPredicate p = new BinaryFunctionBinaryPredicate(new Constant(Boolean.FALSE));
-        assertTrue(!p.test(null,null));
-    }
-
-    public void testTestWhenNull() throws Exception {
-        BinaryPredicate p = new BinaryFunctionBinaryPredicate(new Constant(null));
-        try {
-            p.test("xyzzy",Boolean.TRUE);
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
-            // expected
-        }
-    }
-
-    public void testTestWhenNonBoolean() throws Exception {
-        BinaryPredicate p = new BinaryFunctionBinaryPredicate(new Constant(new Integer(2)));
-        try {
-            p.test("xyzzy",Boolean.TRUE);
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
-            // expected
-        }
+        BinaryPredicate<Object, Object> p = new BinaryFunctionBinaryPredicate<Object,
Object>(Constant.FALSE);
+        assertFalse(p.test(null,null));
     }
 
     public void testEquals() throws Exception {
-        BinaryPredicate p = new BinaryFunctionBinaryPredicate(new Constant(Boolean.TRUE));
+        BinaryPredicate<Object, Object> p = new BinaryFunctionBinaryPredicate<Object,
Object>(Constant.TRUE);
         assertEquals(p,p);
-        assertObjectsAreEqual(p,new BinaryFunctionBinaryPredicate(new Constant(Boolean.TRUE)));
+        assertObjectsAreEqual(p,new BinaryFunctionBinaryPredicate<Object, Object>(Constant.TRUE));
         assertObjectsAreNotEqual(p,Constant.truePredicate());
-        assertObjectsAreNotEqual(p,new BinaryFunctionBinaryPredicate(null));
-        assertObjectsAreNotEqual(p,new BinaryFunctionBinaryPredicate(new Constant(Boolean.FALSE)));
-        assertObjectsAreEqual(new BinaryFunctionBinaryPredicate(null),new BinaryFunctionBinaryPredicate(null));
+        assertObjectsAreNotEqual(p,new BinaryFunctionBinaryPredicate<Object, Object>(Constant.FALSE));
     }
 
     public void testAdaptNull() throws Exception {
@@ -106,6 +84,6 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(BinaryFunctionBinaryPredicate.adapt(new Constant(Boolean.TRUE)));
+        assertNotNull(BinaryFunctionBinaryPredicate.adapt(Constant.TRUE));
     }
 }



Mime
View raw message