@Test
    public void testVarious() {
        PeekableListIterator<String> it = new PeekableListIterator<String>(strings.listIterator());

        assertTrue(it.hasNext());
        assertEquals("0", it.peek());
        assertTrue(it.hasNext());
        assertEquals("0", it.next());
        assertEquals("1", it.next());
        assertEquals("2", it.next());
        assertEquals("3", it.peek());
        assertEquals("3", it.peek());
        assertEquals("3", it.peek());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertEquals("3", it.next());
        //cursor is now before 4
        it.add("banana");
        it.add("apple");
        //added before 4
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertTrue(it.hasNext());
        assertEquals("4", it.peek());
        assertEquals("4", it.peek());
        assertEquals("4", it.peek());
        assertEquals("4", it.peek());
        //removing 3
        it.remove();
        assertEquals("4", it.peek());
        assertEquals("4", it.next());
        //replacing 4 with orange:
        it.set("orange");
        assertEquals("5", it.peek());
        assertEquals("5", it.next());
        assertFalse(it.hasNext());
        assertNull(it.peek());
        try {
            it.next();
            fail("Shouldn't have worked.");
        } catch (NoSuchElementException nsee) {
            // empty
        }
    }
Tests that PeekableListIterator behaves as expected.

@author Einar M R Rosenvinge
document/src/test/java/com/yahoo/document/annotation/PeekableListIteratorTestCase.java