RemoteSet implements Set<E> { @Override public Iterator<E> iterator() { return new RemoteSetIterator(remoteSet()); } RemoteSet(String cacheName, Object key);  RemoteSet(String cacheName, Object key, Factory<Set<E>> factory);  RemoteSet(NamedCache cache, Object key);  RemoteSet(NamedCache cache, Object key, Factory<Set<E>> factory); @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 removeAll(Collection<?> objects); @Override boolean retainAll(Collection<?> objects); @Override void clear(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testIterator() { RemoteSet<String> l = new RemoteSet<String>(cache, 1L); l.addAll(Arrays.asList("one", "two", "three")); for (Iterator<String> it = l.iterator(); it.hasNext(); ) { it.next(); it.remove(); } assertTrue(l.isEmpty()); }