1 16 package org.apache.commons.collections.buffer; 17 18 import junit.framework.Test; 19 import junit.framework.TestCase; 20 import junit.framework.TestSuite; 21 22 import org.apache.commons.collections.ArrayStack; 23 import org.apache.commons.collections.Buffer; 24 import org.apache.commons.collections.collection.TestTransformedCollection; 25 26 35 public class TestTransformedBuffer extends TestCase { 36 37 public TestTransformedBuffer(String testName) { 38 super(testName); 39 } 40 41 public static Test suite() { 42 return new TestSuite(TestTransformedBuffer.class); 43 } 44 45 public static void main(String args[]) { 46 String [] testCaseName = { TestTransformedBuffer.class.getName()}; 47 junit.textui.TestRunner.main(testCaseName); 48 } 49 50 public void testTransformedBuffer() { 51 Buffer buffer = TransformedBuffer.decorate(new ArrayStack(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER); 52 assertEquals(0, buffer.size()); 53 Object [] els = new Object [] {"1", "3", "5", "7", "2", "4", "6"}; 54 for (int i = 0; i < els.length; i++) { 55 buffer.add(els[i]); 56 assertEquals(i + 1, buffer.size()); 57 assertEquals(true, buffer.contains(new Integer ((String ) els[i]))); 58 assertEquals(false, buffer.contains(els[i])); 59 } 60 61 assertEquals(false, buffer.remove(els[0])); 62 assertEquals(true, buffer.remove(new Integer ((String ) els[0]))); 63 64 } 65 } 66 | Popular Tags |