RemoteSet implements Set<E> { @Override public Object[] toArray() { return remoteSet().toArray(); } 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 testToArray() { RemoteSet<Integer> l = new RemoteSet<Integer>(cache, 1L, new TreeSetFactory<Integer>()); l.addAll(Arrays.asList(0, 1, 2)); assertTrue(Arrays.equals(new Object[] {0, 1, 2}, l.toArray())); assertTrue(Arrays.equals(new Integer[] {0, 1, 2}, l.toArray(new Integer[3]))); }