/** * Verify that iterator is not modifiable */ public void testUnmodifiableIterator() { setupList(); Iterator iterator = list.iterator(); try { Object obj = iterator.next(); iterator.remove(); fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { // expected } }
public List makeFullList() { ArrayList list = new ArrayList(); list.addAll(Arrays.asList(getFullElements())); return UnmodifiableList.decorate(list); }
protected void setupList() { list = (UnmodifiableList) makeFullList(); array = new ArrayList(); array.add(new Integer(1)); }
/** * Verify that base list and sublists are not modifiable */ public void testUnmodifiable() { setupList(); verifyUnmodifiable(list); verifyUnmodifiable(list.subList(0, 2)); }
protected void verifyUnmodifiable(List list) { try { list.add(0, new Integer(0)); fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) {
public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(TestCursorableLinkedList.suite()); suite.addTest(TestNodeCachingLinkedList.suite()); suite.addTest(TestTreeList.suite()); suite.addTest(TestFixedSizeList.suite()); suite.addTest(TestGrowthList.suite()); suite.addTest(TestPredicatedList.suite()); suite.addTest(TestSetUniqueList.suite()); suite.addTest(TestSynchronizedList.suite()); suite.addTest(TestTransformedList.suite()); suite.addTest(TestTypedList.suite()); suite.addTest(TestUnmodifiableList.suite()); return suite; }