You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2003/12/24 23:38:33 UTC

cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/bag TestTypedSortedBag.java TestPredicatedSortedBag.java

scolebourne    2003/12/24 14:38:32

  Modified:    collections/src/test/org/apache/commons/collections/bag
                        TestTypedSortedBag.java
                        TestPredicatedSortedBag.java
  Log:
  Fix test class to not hard code empty Bag
  
  Revision  Changes    Path
  1.5       +8 -10     jakarta-commons/collections/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java
  
  Index: TestTypedSortedBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestTypedSortedBag.java	5 Dec 2003 20:22:12 -0000	1.4
  +++ TestTypedSortedBag.java	24 Dec 2003 22:38:32 -0000	1.5
  @@ -94,7 +94,6 @@
       protected Class stringClass = this.getName().getClass();
       private Object obj = new Object();
       protected Class objectClass = obj.getClass();
  -    protected SortedBag emptyBag = new TreeBag();
       protected SortedBag nullBag = null;
       
       protected SortedBag decorateBag(SortedBag bag, Class claz) {
  @@ -102,19 +101,19 @@
       }
   
       public Bag makeBag() {
  -        return decorateBag(emptyBag, objectClass);
  +        return decorateBag(new TreeBag(), objectClass);
       }
       
       protected Bag makeTestBag() {
  -        return decorateBag(emptyBag, stringClass);
  +        return decorateBag(new TreeBag(), stringClass);
       }
       
       //--------------------------------------------------------------------------
       
       public void testDecorate() {
  -        SortedBag bag = decorateBag(emptyBag, stringClass);
  +        SortedBag bag = decorateBag(new TreeBag(), stringClass);
           try {
  -            SortedBag bag3 = decorateBag(emptyBag, null);
  +            SortedBag bag3 = decorateBag(new TreeBag(), null);
               fail("Expecting IllegalArgumentException for null predicate");
           } catch (IllegalArgumentException e) {}
           try {
  @@ -124,7 +123,7 @@
       }
       
       public void testSortOrder() {
  -        SortedBag bag = decorateBag(emptyBag, stringClass);
  +        SortedBag bag = decorateBag(new TreeBag(), stringClass);
           String one = "one";
           String two = "two";
           String three = "three";
  @@ -134,7 +133,6 @@
           assertEquals("first element", bag.first(), one);
           assertEquals("last element", bag.last(), two); 
           Comparator c = bag.comparator();
  -        assertTrue("natural order, so comparator should be null", 
  -            c == null);
  +        assertTrue("natural order, so comparator should be null", c == null);
       }
   }
  
  
  
  1.5       +8 -10     jakarta-commons/collections/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java
  
  Index: TestPredicatedSortedBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestPredicatedSortedBag.java	5 Dec 2003 20:22:12 -0000	1.4
  +++ TestPredicatedSortedBag.java	24 Dec 2003 22:38:32 -0000	1.5
  @@ -78,7 +78,6 @@
    */
   public class TestPredicatedSortedBag extends AbstractTestSortedBag {
       
  -    private SortedBag emptyBag = new TreeBag();
       private SortedBag nullBag = null;
       
       public TestPredicatedSortedBag(String testName) {
  @@ -111,20 +110,20 @@
       }
       
       public Bag makeBag() {
  -        return decorateBag(emptyBag, truePredicate);
  +        return decorateBag(new TreeBag(), truePredicate);
       }
       
       protected Bag makeTestBag() {
  -        return decorateBag(emptyBag, stringPredicate());
  +        return decorateBag(new TreeBag(), stringPredicate());
       }
       
       //--------------------------------------------------------------------------
       
       public void testDecorate() {
  -        SortedBag bag = decorateBag(emptyBag, stringPredicate());
  +        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
           SortedBag bag2 = ((PredicatedSortedBag) bag).getSortedBag();
           try {
  -            SortedBag bag3 = decorateBag(emptyBag, null);
  +            SortedBag bag3 = decorateBag(new TreeBag(), null);
               fail("Expecting IllegalArgumentException for null predicate");
           } catch (IllegalArgumentException e) {}
           try {
  @@ -134,7 +133,7 @@
       }
       
       public void testSortOrder() {
  -        SortedBag bag = decorateBag(emptyBag, stringPredicate());
  +        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
           String one = "one";
           String two = "two";
           String three = "three";
  @@ -144,7 +143,6 @@
           assertEquals("first element", bag.first(), one);
           assertEquals("last element", bag.last(), two); 
           Comparator c = bag.comparator();
  -        assertTrue("natural order, so comparator should be null", 
  -            c == null);
  +        assertTrue("natural order, so comparator should be null", c == null);
       }
   }
  
  
  

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