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.List ; 22 import java.util.ListIterator ; 23 24 import junit.framework.Test; 25 import junit.framework.TestSuite; 26 27 import org.apache.commons.collections.Unmodifiable; 28 29 36 public class TestUnmodifiableListIterator extends AbstractTestListIterator { 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(TestUnmodifiableListIterator.class); 43 } 44 45 public TestUnmodifiableListIterator(String testName) { 46 super(testName); 47 } 48 49 public ListIterator makeEmptyListIterator() { 50 return UnmodifiableListIterator.decorate(Collections.EMPTY_LIST.listIterator()); 51 } 52 53 public ListIterator makeFullListIterator() { 54 return UnmodifiableListIterator.decorate(testList.listIterator()); 55 } 56 57 public boolean supportsRemove() { 58 return false; 59 } 60 61 public boolean supportsAdd() { 62 return false; 63 } 64 65 public boolean supportsSet() { 66 return false; 67 } 68 69 public void testListIterator() { 71 assertTrue(makeEmptyListIterator() instanceof Unmodifiable); 72 } 73 74 public void testDecorateFactory() { 75 ListIterator it = makeFullListIterator(); 76 assertSame(it, UnmodifiableListIterator.decorate(it)); 77 78 it = testList.listIterator(); 79 assertTrue(it != UnmodifiableListIterator.decorate(it)); 80 81 try { 82 UnmodifiableListIterator.decorate(null); 83 fail(); 84 } catch (IllegalArgumentException ex) {} 85 } 86 87 } 88 | Popular Tags |