1 16 package org.apache.commons.collections.bag; 17 18 import junit.framework.Test; 19 import junit.framework.TestSuite; 20 21 import org.apache.commons.collections.Bag; 22 import org.apache.commons.collections.collection.TestTransformedCollection; 23 24 33 public class TestTransformedSortedBag extends AbstractTestSortedBag { 34 35 public TestTransformedSortedBag(String testName) { 36 super(testName); 37 } 38 39 public static Test suite() { 40 return new TestSuite(TestTransformedSortedBag.class); 41 } 42 43 public static void main(String args[]) { 44 String [] testCaseName = { TestTransformedSortedBag.class.getName()}; 45 junit.textui.TestRunner.main(testCaseName); 46 } 47 48 public Bag makeBag() { 49 return TransformedSortedBag.decorate(new TreeBag(), TestTransformedCollection.NOOP_TRANSFORMER); 50 } 51 52 public void testTransformedBag() { 53 Bag bag = TransformedSortedBag.decorate(new TreeBag(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); 54 assertEquals(0, bag.size()); 55 Object [] els = new Object [] {"1", "3", "5", "7", "2", "4", "6"}; 56 for (int i = 0; i < els.length; i++) { 57 bag.add(els[i]); 58 assertEquals(i + 1, bag.size()); 59 assertEquals(true, bag.contains(new Integer ((String ) els[i]))); 60 } 61 62 assertEquals(true, bag.remove(new Integer ((String ) els[0]))); 63 64 } 65 66 public String getCompatibilityVersion() { 67 return "3.1"; 68 } 69 70 82 } 83 | Popular Tags |