1 17 package org.apache.commons.collections.primitives; 18 19 import java.util.Collections ; 20 21 import junit.framework.Test; 22 import junit.framework.TestCase; 23 import junit.framework.TestSuite; 24 25 import org.apache.commons.collections.primitives.adapters.IteratorCharIterator; 26 27 31 public class TestAbstractCharCollection extends TestCase { 32 33 36 public TestAbstractCharCollection(String testName) { 37 super(testName); 38 } 39 40 public static Test suite() { 41 return new TestSuite(TestAbstractCharCollection.class); 42 } 43 44 47 public void testAddIsUnsupportedByDefault() { 48 CharCollection col = new CharCollectionImpl(); 49 try { 50 col.add((char)1); 51 fail("Expected UnsupportedOperationException"); 52 } catch(UnsupportedOperationException e) { 53 } 55 } 56 59 60 static class CharCollectionImpl extends AbstractCharCollection { 61 public CharCollectionImpl() { 62 } 63 64 public CharIterator iterator() { 65 return new IteratorCharIterator(Collections.EMPTY_LIST.iterator()); 66 } 67 68 public int size() { 69 return 0; 70 } 71 } 72 } | Popular Tags |