You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rw...@apache.org on 2003/03/04 17:51:47 UTC

cvs commit: jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator BaseComparisonPredicateTest.java TestIsEquivalent.java TestIsGreaterThan.java TestIsGreaterThanOrEqual.java TestIsLessThan.java TestIsLessThanOrEqual.java TestIsNotEquivalent.java TestAll.java

rwaldhoff    2003/03/04 08:51:47

  Modified:    functor/src/java/org/apache/commons/functor/core/comparator
                        IsEquivalent.java IsGreaterThan.java
                        IsGreaterThanOrEqual.java IsLessThan.java
                        IsLessThanOrEqual.java IsNotEquivalent.java
               functor/src/test/org/apache/commons/functor/core/comparator
                        TestAll.java
  Added:       functor/src/test/org/apache/commons/functor/core/comparator
                        BaseComparisonPredicateTest.java
                        TestIsEquivalent.java TestIsGreaterThan.java
                        TestIsGreaterThanOrEqual.java TestIsLessThan.java
                        TestIsLessThanOrEqual.java TestIsNotEquivalent.java
  Log:
  add tests
  
  Revision  Changes    Path
  1.2       +4 -5      jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsEquivalent.java
  
  Index: IsEquivalent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsEquivalent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IsEquivalent.java	24 Feb 2003 11:38:06 -0000	1.1
  +++ IsEquivalent.java	4 Mar 2003 16:51:46 -0000	1.2
  @@ -128,9 +128,8 @@
        */
       public int hashCode() {
           int hash = "IsEquivalent".hashCode();
  -        if(null != comparator) {
  -            hash ^= comparator.hashCode();
  -        }
  +        // by construction, comparator is never null
  +        hash ^= comparator.hashCode();
           return hash;
       }
   
  
  
  
  1.2       +4 -5      jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsGreaterThan.java
  
  Index: IsGreaterThan.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsGreaterThan.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IsGreaterThan.java	24 Feb 2003 11:38:06 -0000	1.1
  +++ IsGreaterThan.java	4 Mar 2003 16:51:46 -0000	1.2
  @@ -125,9 +125,8 @@
        */
       public int hashCode() {
           int hash = "IsGreaterThan".hashCode();
  -        if(null != comparator) {
  -            hash ^= comparator.hashCode();
  -        }
  +        // by construction, comparator is never null
  +        hash ^= comparator.hashCode();
           return hash;
       }
   
  
  
  
  1.2       +4 -5      jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsGreaterThanOrEqual.java
  
  Index: IsGreaterThanOrEqual.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsGreaterThanOrEqual.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IsGreaterThanOrEqual.java	24 Feb 2003 11:38:06 -0000	1.1
  +++ IsGreaterThanOrEqual.java	4 Mar 2003 16:51:46 -0000	1.2
  @@ -125,9 +125,8 @@
        */
       public int hashCode() {
           int hash = "IsGreaterThanOrEqual".hashCode();
  -        if(null != comparator) {
  -            hash ^= comparator.hashCode();
  -        }
  +        // by construction, comparator is never null
  +        hash ^= comparator.hashCode();
           return hash;
       }
   
  
  
  
  1.2       +4 -5      jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsLessThan.java
  
  Index: IsLessThan.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsLessThan.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IsLessThan.java	24 Feb 2003 11:38:06 -0000	1.1
  +++ IsLessThan.java	4 Mar 2003 16:51:46 -0000	1.2
  @@ -125,9 +125,8 @@
        */
       public int hashCode() {
           int hash = "IsLessThan".hashCode();
  -        if(null != comparator) {
  -            hash ^= comparator.hashCode();
  -        }
  +        // by construction, comparator is never null
  +        hash ^= comparator.hashCode();
           return hash;
       }
   
  
  
  
  1.2       +4 -5      jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsLessThanOrEqual.java
  
  Index: IsLessThanOrEqual.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsLessThanOrEqual.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IsLessThanOrEqual.java	24 Feb 2003 11:38:06 -0000	1.1
  +++ IsLessThanOrEqual.java	4 Mar 2003 16:51:46 -0000	1.2
  @@ -125,9 +125,8 @@
        */
       public int hashCode() {
           int hash = "IsLessThanOrEqual".hashCode();
  -        if(null != comparator) {
  -            hash ^= comparator.hashCode();
  -        }
  +        // by construction, comparator is never null
  +        hash ^= comparator.hashCode();
           return hash;
       }
   
  
  
  
  1.2       +4 -5      jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsNotEquivalent.java
  
  Index: IsNotEquivalent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsNotEquivalent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IsNotEquivalent.java	24 Feb 2003 11:38:06 -0000	1.1
  +++ IsNotEquivalent.java	4 Mar 2003 16:51:46 -0000	1.2
  @@ -128,9 +128,8 @@
        */
       public int hashCode() {
           int hash = "IsNotEquivalent".hashCode();
  -        if(null != comparator) {
  -            hash ^= comparator.hashCode();
  -        }
  +        // by construction, comparator is never null
  +        hash ^= comparator.hashCode();
           return hash;
       }
   
  
  
  
  1.3       +10 -4     jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestAll.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestAll.java	21 Feb 2003 00:12:29 -0000	1.2
  +++ TestAll.java	4 Mar 2003 16:51:46 -0000	1.3
  @@ -73,8 +73,14 @@
           TestSuite suite = new TestSuite();
           
           suite.addTest(TestComparableComparator.suite());
  -        suite.addTest(TestComparatorFunction.suite());
  -        
  +        suite.addTest(TestComparatorFunction.suite());        
  +        suite.addTest(TestIsLessThan.suite());
  +        suite.addTest(TestIsLessThanOrEqual.suite());
  +        suite.addTest(TestIsEquivalent.suite());
  +        suite.addTest(TestIsGreaterThan.suite());
  +        suite.addTest(TestIsGreaterThanOrEqual.suite());
  +        suite.addTest(TestIsNotEquivalent.suite());
  +            
           return suite;
       }
   }
  
  
  
  1.1                  jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/BaseComparisonPredicateTest.java
  
  Index: BaseComparisonPredicateTest.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/BaseComparisonPredicateTest.java,v 1.1 2003/03/04 16:51:46 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.functor.core.comparator;
  
  import org.apache.commons.functor.BaseFunctorTest;
  import org.apache.commons.functor.BinaryPredicate;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/03/04 16:51:46 $
   * @author Rodney Waldhoff
   */
  public abstract class BaseComparisonPredicateTest extends BaseFunctorTest {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public BaseComparisonPredicateTest(String testName) {
          super(testName);
      }
  
      // Lifecycle
      // ------------------------------------------------------------------------
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
      // Tests
      // ------------------------------------------------------------------------
      
      public final void testTestNull() throws Exception {
          BinaryPredicate p = (BinaryPredicate)(makeFunctor());
          try {
              p.test(new Integer(2),null);
              fail("Expected NullPointerException");
          } catch(NullPointerException e) {
              // expected
          }
          try {
              p.test(null,new Integer(2));
              fail("Expected NullPointerException");
          } catch(NullPointerException e) {
              // expected
          }
          try {
              p.test(null,null);
              fail("Expected NullPointerException");
          } catch(NullPointerException e) {
              // expected
          }
      }
      
      public final void testTestNonComparable() throws Exception {
          BinaryPredicate p = (BinaryPredicate)(makeFunctor());
          try {
              p.test(new Integer(2),new Object());
              fail("Expected ClassCastException");
          } catch(ClassCastException e) {
              // expected
          }
          try {
              p.test(new Object(),new Integer(2));
              fail("Expected ClassCastException");
          } catch(ClassCastException e) {
              // expected
          }
          try {
              p.test(new Object(),new Object());
              fail("Expected ClassCastException");
          } catch(ClassCastException e) {
              // expected
          }
      }
          
  }
  
  
  
  1.1                  jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsEquivalent.java
  
  Index: TestIsEquivalent.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsEquivalent.java,v 1.1 2003/03/04 16:51:46 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.functor.core.comparator;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.functor.BaseFunctorTest;
  import org.apache.commons.functor.core.ConstantPredicate;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/03/04 16:51:46 $
   * @author Rodney Waldhoff
   */
  public class TestIsEquivalent extends BaseComparisonPredicateTest {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public TestIsEquivalent(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestIsEquivalent.class);
      }
  
      // Functor Testing Framework
      // ------------------------------------------------------------------------
  
      protected Object makeFunctor() {
          return new IsEquivalent();
      }
  
      // Lifecycle
      // ------------------------------------------------------------------------
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
      // Tests
      // ------------------------------------------------------------------------
      
      public void testTest() throws Exception {
          IsEquivalent p = new IsEquivalent();
          assertTrue(!p.test(new Integer(2),new Integer(4)));
          assertTrue(!p.test(new Integer(3),new Integer(4)));
          assertTrue(p.test(new Integer(4),new Integer(4)));
          assertTrue(!p.test(new Integer(5),new Integer(4)));
          assertTrue(!p.test(new Integer(6),new Integer(4)));
      }
      
      public void testEquals() throws Exception {
          IsEquivalent p = new IsEquivalent();
          assertEquals(p,p);
  
          assertObjectsAreEqual(p,new IsEquivalent());
          assertObjectsAreEqual(p,new IsEquivalent(null));
          assertObjectsAreEqual(p,new IsEquivalent(new ComparableComparator()));
          assertObjectsAreEqual(p,IsEquivalent.getEquivalent());
          assertSame(IsEquivalent.getEquivalent(),IsEquivalent.getEquivalent());
          assertObjectsAreNotEqual(p,new ConstantPredicate(false));
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java
  
  Index: TestIsGreaterThan.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java,v 1.1 2003/03/04 16:51:46 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.functor.core.comparator;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.functor.BaseFunctorTest;
  import org.apache.commons.functor.BinaryPredicate;
  import org.apache.commons.functor.core.ConstantPredicate;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/03/04 16:51:46 $
   * @author Rodney Waldhoff
   */
  public class TestIsGreaterThan extends BaseComparisonPredicateTest {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public TestIsGreaterThan(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestIsGreaterThan.class);
      }
  
      // Functor Testing Framework
      // ------------------------------------------------------------------------
  
      protected Object makeFunctor() {
          return new IsGreaterThan();
      }
  
      // Lifecycle
      // ------------------------------------------------------------------------
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
      // Tests
      // ------------------------------------------------------------------------
      
      public void testTest() throws Exception {
          IsGreaterThan p = new IsGreaterThan();
          assertTrue(!p.test(new Integer(2),new Integer(4)));
          assertTrue(!p.test(new Integer(3),new Integer(4)));
          assertTrue(!p.test(new Integer(4),new Integer(4)));
          assertTrue(p.test(new Integer(5),new Integer(4)));
          assertTrue(p.test(new Integer(6),new Integer(4)));
      }
      
      public void testEquals() throws Exception {
          IsGreaterThan p = new IsGreaterThan();
          assertEquals(p,p);
  
          assertObjectsAreEqual(p,new IsGreaterThan());
          assertObjectsAreEqual(p,new IsGreaterThan(null));
          assertObjectsAreEqual(p,new IsGreaterThan(new ComparableComparator()));
          assertObjectsAreEqual(p,IsGreaterThan.getGreaterThan());
          assertSame(IsGreaterThan.getGreaterThan(),IsGreaterThan.getGreaterThan());
          assertObjectsAreNotEqual(p,new ConstantPredicate(false));
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java
  
  Index: TestIsGreaterThanOrEqual.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java,v 1.1 2003/03/04 16:51:46 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.functor.core.comparator;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.functor.BaseFunctorTest;
  import org.apache.commons.functor.BinaryPredicate;
  import org.apache.commons.functor.core.ConstantPredicate;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/03/04 16:51:46 $
   * @author Rodney Waldhoff
   */
  public class TestIsGreaterThanOrEqual extends BaseComparisonPredicateTest {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public TestIsGreaterThanOrEqual(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestIsGreaterThanOrEqual.class);
      }
  
      // Functor Testing Framework
      // ------------------------------------------------------------------------
  
      protected Object makeFunctor() {
          return new IsGreaterThanOrEqual();
      }
  
      // Lifecycle
      // ------------------------------------------------------------------------
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
      // Tests
      // ------------------------------------------------------------------------
      
      public void testTest() throws Exception {
          IsGreaterThanOrEqual p = new IsGreaterThanOrEqual();
          assertTrue(!p.test(new Integer(2),new Integer(4)));
          assertTrue(!p.test(new Integer(3),new Integer(4)));
          assertTrue(p.test(new Integer(4),new Integer(4)));
          assertTrue(p.test(new Integer(5),new Integer(4)));
          assertTrue(p.test(new Integer(6),new Integer(4)));
      }
      
      public void testEquals() throws Exception {
          IsGreaterThanOrEqual p = new IsGreaterThanOrEqual();
          assertEquals(p,p);
  
          assertObjectsAreEqual(p,new IsGreaterThanOrEqual());
          assertObjectsAreEqual(p,new IsGreaterThanOrEqual(null));
          assertObjectsAreEqual(p,new IsGreaterThanOrEqual(new ComparableComparator()));
          assertObjectsAreEqual(p,IsGreaterThanOrEqual.getGreaterThanOrEqual());
          assertSame(IsGreaterThanOrEqual.getGreaterThanOrEqual(),IsGreaterThanOrEqual.getGreaterThanOrEqual());
          assertObjectsAreNotEqual(p,new ConstantPredicate(false));
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsLessThan.java
  
  Index: TestIsLessThan.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsLessThan.java,v 1.1 2003/03/04 16:51:46 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.functor.core.comparator;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.functor.BaseFunctorTest;
  import org.apache.commons.functor.core.ConstantPredicate;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/03/04 16:51:46 $
   * @author Rodney Waldhoff
   */
  public class TestIsLessThan extends BaseComparisonPredicateTest {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public TestIsLessThan(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestIsLessThan.class);
      }
  
      // Functor Testing Framework
      // ------------------------------------------------------------------------
  
      protected Object makeFunctor() {
          return new IsLessThan();
      }
  
      // Lifecycle
      // ------------------------------------------------------------------------
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
      // Tests
      // ------------------------------------------------------------------------
      
      public void testTest() throws Exception {
          IsLessThan p = new IsLessThan();
          assertTrue(p.test(new Integer(2),new Integer(4)));
          assertTrue(p.test(new Integer(3),new Integer(4)));
          assertTrue(!p.test(new Integer(4),new Integer(4)));
          assertTrue(!p.test(new Integer(5),new Integer(4)));
          assertTrue(!p.test(new Integer(6),new Integer(4)));
      }
      
      public void testEquals() throws Exception {
          IsLessThan p = new IsLessThan();
          assertEquals(p,p);
  
          assertObjectsAreEqual(p,new IsLessThan());
          assertObjectsAreEqual(p,new IsLessThan(null));
          assertObjectsAreEqual(p,new IsLessThan(new ComparableComparator()));
          assertObjectsAreEqual(p,IsLessThan.getLessThan());
          assertSame(IsLessThan.getLessThan(),IsLessThan.getLessThan());
          assertObjectsAreNotEqual(p,new ConstantPredicate(false));
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java
  
  Index: TestIsLessThanOrEqual.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java,v 1.1 2003/03/04 16:51:46 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.functor.core.comparator;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.functor.BaseFunctorTest;
  import org.apache.commons.functor.core.ConstantPredicate;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/03/04 16:51:46 $
   * @author Rodney Waldhoff
   */
  public class TestIsLessThanOrEqual extends BaseComparisonPredicateTest {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public TestIsLessThanOrEqual(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestIsLessThanOrEqual.class);
      }
  
      // Functor Testing Framework
      // ------------------------------------------------------------------------
  
      protected Object makeFunctor() {
          return new IsLessThanOrEqual();
      }
  
      // Lifecycle
      // ------------------------------------------------------------------------
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
      // Tests
      // ------------------------------------------------------------------------
      
      public void testTest() throws Exception {
          IsLessThanOrEqual p = new IsLessThanOrEqual();
          assertTrue(p.test(new Integer(2),new Integer(4)));
          assertTrue(p.test(new Integer(3),new Integer(4)));
          assertTrue(p.test(new Integer(4),new Integer(4)));
          assertTrue(!p.test(new Integer(5),new Integer(4)));
          assertTrue(!p.test(new Integer(6),new Integer(4)));
      }
      
      public void testEquals() throws Exception {
          IsLessThanOrEqual p = new IsLessThanOrEqual();
          assertEquals(p,p);
  
          assertObjectsAreEqual(p,new IsLessThanOrEqual());
          assertObjectsAreEqual(p,new IsLessThanOrEqual(null));
          assertObjectsAreEqual(p,new IsLessThanOrEqual(new ComparableComparator()));
          assertObjectsAreEqual(p,IsLessThanOrEqual.getLessThanOrEqual());
          assertSame(IsLessThanOrEqual.getLessThanOrEqual(),IsLessThanOrEqual.getLessThanOrEqual());
          assertObjectsAreNotEqual(p,new ConstantPredicate(false));
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java
  
  Index: TestIsNotEquivalent.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java,v 1.1 2003/03/04 16:51:46 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.functor.core.comparator;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.functor.BaseFunctorTest;
  import org.apache.commons.functor.core.ConstantPredicate;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/03/04 16:51:46 $
   * @author Rodney Waldhoff
   */
  public class TestIsNotEquivalent extends BaseComparisonPredicateTest {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public TestIsNotEquivalent(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestIsNotEquivalent.class);
      }
  
      // Functor Testing Framework
      // ------------------------------------------------------------------------
  
      protected Object makeFunctor() {
          return new IsNotEquivalent();
      }
  
      // Lifecycle
      // ------------------------------------------------------------------------
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
      // Tests
      // ------------------------------------------------------------------------
      
      public void testTest() throws Exception {
          IsNotEquivalent p = new IsNotEquivalent();
          assertTrue(p.test(new Integer(2),new Integer(4)));
          assertTrue(p.test(new Integer(3),new Integer(4)));
          assertTrue(!p.test(new Integer(4),new Integer(4)));
          assertTrue(p.test(new Integer(5),new Integer(4)));
          assertTrue(p.test(new Integer(6),new Integer(4)));
      }
      
      public void testEquals() throws Exception {
          IsNotEquivalent p = new IsNotEquivalent();
          assertEquals(p,p);
  
          assertObjectsAreEqual(p,new IsNotEquivalent());
          assertObjectsAreEqual(p,new IsNotEquivalent(null));
          assertObjectsAreEqual(p,new IsNotEquivalent(new ComparableComparator()));
          assertObjectsAreEqual(p,IsNotEquivalent.getNotEquivalent());
          assertSame(IsNotEquivalent.getNotEquivalent(),IsNotEquivalent.getNotEquivalent());
          assertObjectsAreNotEqual(p,new ConstantPredicate(false));
      }
      
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org