RemoteList implements List<E> { @Override public Iterator<E> iterator() { return listIterator(0); } RemoteList(String cacheName, Object key);  RemoteList(String cacheName, Object key, Factory<List<E>> listFactory);  RemoteList(NamedCache cache, Object key);  RemoteList(NamedCache cache, Object key, Factory<List<E>> listFactory); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<E> iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(E e); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> objects); @Override boolean addAll(Collection<? extends E> objects); @Override boolean addAll(int i, Collection<? extends E> objects); @Override boolean removeAll(Collection<?> objects); @Override boolean retainAll(Collection<?> objects); @Override void clear(); @Override E get(int i); @Override E set(int i, E e); @Override void add(int i, E e); @Override E remove(int i); @Override int indexOf(Object o); @Override int lastIndexOf(Object o); @Override ListIterator<E> listIterator(); @Override ListIterator<E> listIterator(int i); @Override List<E> subList(int start, int end); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testIterator() { RemoteList<String> l = new RemoteList<String>(cache, 1L, new LinkedListFactory<String>()); l.addAll(Arrays.asList("one", "two", "three")); for (Iterator<String> it = l.iterator(); it.hasNext(); ) { it.next(); it.remove(); } assertTrue(l.isEmpty()); l.addAll(Arrays.asList("one", "two", "three")); for (ListIterator<String> it = l.listIterator(2); it.hasPrevious(); ) { it.previous(); it.remove(); } assertEquals(1, l.size()); assertEquals("three", l.get(0)); l.clear(); l.addAll(Arrays.asList("one", "two", "three")); for (ListIterator<String> it = l.listIterator(); it.hasNext(); ) { String str = it.next(); it.set(str.toUpperCase()); } assertEquals(Arrays.asList("ONE", "TWO", "THREE"), l); ListIterator<String> it = l.listIterator(); it.add("0"); it.next(); it.next(); it.add("2 1/2"); it.next(); it.add("4"); assertEquals(Arrays.asList("0", "ONE", "TWO", "2 1/2", "THREE", "4"), l); }