1 16 package org.apache.commons.collections.iterators; 17 18 import java.util.ArrayList ; 19 import java.util.Arrays ; 20 import java.util.Collections ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 24 import junit.framework.Test; 25 import junit.framework.TestSuite; 26 27 import org.apache.commons.collections.Unmodifiable; 28 29 36 public class TestUnmodifiableIterator extends AbstractTestIterator { 37 38 protected String [] testArray = { "One", "Two", "Three" }; 39 protected List testList = new ArrayList (Arrays.asList(testArray)); 40 41 public static Test suite() { 42 return new TestSuite(TestUnmodifiableIterator.class); 43 } 44 45 public TestUnmodifiableIterator(String testName) { 46 super(testName); 47 } 48 49 public Iterator makeEmptyIterator() { 50 return UnmodifiableIterator.decorate(Collections.EMPTY_LIST.iterator()); 51 } 52 53 public Iterator makeFullIterator() { 54 return UnmodifiableIterator.decorate(testList.iterator()); 55 } 56 57 public boolean supportsRemove() { 58 return false; 59 } 60 61 public void testIterator() { 63 assertTrue(makeEmptyIterator() instanceof Unmodifiable); 64 } 65 66 public void testDecorateFactory() { 67 Iterator it = makeFullIterator(); 68 assertSame(it, UnmodifiableIterator.decorate(it)); 69 70 it = testList.iterator(); 71 assertTrue(it != UnmodifiableIterator.decorate(it)); 72 73 try { 74 UnmodifiableIterator.decorate(null); 75 fail(); 76 } catch (IllegalArgumentException ex) {} 77 } 78 79 } 80 | Popular Tags |