Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 77037 invoked from network); 10 Jun 2008 15:32:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jun 2008 15:32:15 -0000 Received: (qmail 55339 invoked by uid 500); 10 Jun 2008 15:32:17 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 55259 invoked by uid 500); 10 Jun 2008 15:32:17 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 55250 invoked by uid 99); 10 Jun 2008 15:32:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 08:32:16 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 15:31:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BBABA23889C1; Tue, 10 Jun 2008 08:31:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@commons.apache.org From: mbenson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080610153153.BBABA23889C1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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(Constant.TRUE); } // Lifecycle @@ -62,43 +62,21 @@ // ------------------------------------------------------------------------ public void testTestWhenTrue() throws Exception { - BinaryPredicate p = new BinaryFunctionBinaryPredicate(new Constant(Boolean.TRUE)); + BinaryPredicate p = new BinaryFunctionBinaryPredicate(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 p = new BinaryFunctionBinaryPredicate(Constant.FALSE); + assertFalse(p.test(null,null)); } public void testEquals() throws Exception { - BinaryPredicate p = new BinaryFunctionBinaryPredicate(new Constant(Boolean.TRUE)); + BinaryPredicate p = new BinaryFunctionBinaryPredicate(Constant.TRUE); assertEquals(p,p); - assertObjectsAreEqual(p,new BinaryFunctionBinaryPredicate(new Constant(Boolean.TRUE))); + assertObjectsAreEqual(p,new BinaryFunctionBinaryPredicate(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(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)); } }