Package org.apache.commons.collections

Examples of org.apache.commons.collections.SortedBag


   public Bag makeBag() {
      return new TreeBag();
   }

   public SortedBag setupBag() {
      SortedBag bag = (SortedBag)makeBag();
      bag.add("C");
      bag.add("A");
      bag.add("B");
      bag.add("D");
      return bag;
   }
View Full Code Here


    }
   
    //--------------------------------------------------------------------------
   
    public void testDecorate() {
        SortedBag bag = decorateBag(new TreeBag(), stringClass);
        try {
            SortedBag bag3 = decorateBag(new TreeBag(), null);
            fail("Expecting IllegalArgumentException for null predicate");
        } catch (IllegalArgumentException e) {}
        try {
            SortedBag bag4 = decorateBag(nullBag, stringClass);
            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {}
    }
View Full Code Here

            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {}
    }
   
    public void testSortOrder() {
        SortedBag bag = decorateBag(new TreeBag(), stringClass);
        String one = "one";
        String two = "two";
        String three = "three";
        bag.add(one);
        bag.add(two);
        bag.add(three);
        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);
    }
View Full Code Here

    }
   
    //--------------------------------------------------------------------------
   
    public void testDecorate() {
        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
        SortedBag bag2 = ((PredicatedSortedBag) bag).getSortedBag();
        try {
            SortedBag bag3 = decorateBag(new TreeBag(), null);
            fail("Expecting IllegalArgumentException for null predicate");
        } catch (IllegalArgumentException e) {}
        try {
            SortedBag bag4 = decorateBag(nullBag, stringPredicate());
            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {}
    }
View Full Code Here

            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {}
    }
   
    public void testSortOrder() {
        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
        String one = "one";
        String two = "two";
        String three = "three";
        bag.add(one);
        bag.add(two);
        bag.add(three);
        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);
    }
View Full Code Here

   public Bag makeBag() {
      return new TreeBag();
   }

   public SortedBag setupBag() {
      SortedBag bag = (SortedBag)makeBag();
      bag.add("C");
      bag.add("A");
      bag.add("B");
      bag.add("D");
      return bag;
   }
View Full Code Here

    }
   
    //--------------------------------------------------------------------------
   
    public void testDecorate() {
        SortedBag bag = decorateBag(new TreeBag(), stringClass);
        try {
            SortedBag bag3 = decorateBag(new TreeBag(), null);
            fail("Expecting IllegalArgumentException for null predicate");
        } catch (IllegalArgumentException e) {}
        try {
            SortedBag bag4 = decorateBag(nullBag, stringClass);
            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {}
    }
View Full Code Here

            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {}
    }
   
    public void testSortOrder() {
        SortedBag bag = decorateBag(new TreeBag(), stringClass);
        String one = "one";
        String two = "two";
        String three = "three";
        bag.add(one);
        bag.add(two);
        bag.add(three);
        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);
    }
View Full Code Here

    }
   
    //--------------------------------------------------------------------------
   
    public void testDecorate() {
        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
        SortedBag bag2 = ((PredicatedSortedBag) bag).getSortedBag();
        try {
            SortedBag bag3 = decorateBag(new TreeBag(), null);
            fail("Expecting IllegalArgumentException for null predicate");
        } catch (IllegalArgumentException e) {}
        try {
            SortedBag bag4 = decorateBag(nullBag, stringPredicate());
            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {}
    }
View Full Code Here

            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {}
    }
   
    public void testSortOrder() {
        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
        String one = "one";
        String two = "two";
        String three = "three";
        bag.add(one);
        bag.add(two);
        bag.add(three);
        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);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.SortedBag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.