CollectionView implements Collection<E> { public Object[] toArray() { return this.collection.toArray(); } CollectionView(Collection<E> collection); boolean add(E element); boolean addAll(Collection<? extends E> collection); void clear(); boolean contains(Object o); boolean containsAll(Collection<?> c); boolean isEmpty(); Iterator<E> iterator(); boolean remove(Object o); boolean removeAll(Collection<?> c); boolean retainAll(Collection<?> c); int size(); Object[] toArray(); T[] toArray(T[] a); String toString();  }
@Test public void testToArray() { for (int i = 0; i < 5; ++i) { assertEquals(this.source.toArray(), this.testobj.toArray()); assertTrue(this.testobj.toArray() instanceof Object[]); assertEquals(i, this.testobj.toArray().length); this.source.add(new Object()); assertEquals(this.source.toArray(), this.testobj.toArray()); assertTrue(this.testobj.toArray() instanceof Object[]); assertEquals(i + 1, this.testobj.toArray().length); } }