ScopedSet implements ScopeSubscriber, Set<E> { public boolean removeAll(final Collection<?> c) { boolean changed = false; for (Object o : c) { if (remove(o) && !changed) { changed = true; } } return changed; } ScopedSet(final ScopeObserver scopeObserver); void addScopedSetObserver(final ScopedSetObserver<E> obs); void removeScopedSetObserver(final ScopedSetObserver<E> obs); void close(); void enterScope(final Scope previous, final Scope next); void exitScope(final Scope previous, final Scope next); boolean add(final E e); boolean addAll(final Collection<? extends E> c); void clear(); boolean contains(final Object o); boolean containsAll(final Collection<?> c); boolean isEmpty(); Iterator<E> iterator(); boolean remove(final Object o); boolean removeAll(final Collection<?> c); boolean retainAll(final Collection<?> c); int size(); Object[] toArray(); T[] toArray(final T[] a);  }
@Test public void testRemoveAll() { final ScopedSet<String> set = new ScopedSet<String>(observer); set.enterScope(null, Scope.SESSION); final String test1 = "test1"; final String test2 = "test2"; final String test3 = "test2"; Assert.assertFalse(set.contains(test1)); Assert.assertFalse(set.contains(test2)); set.add(test1); set.add(test2); Assert.assertTrue(set.contains(test1)); Assert.assertTrue(set.contains(test2)); Assert.assertEquals(2, set.size()); set.add(test3); Assert.assertTrue(set.contains(test1)); Assert.assertTrue(set.contains(test2)); Assert.assertEquals(2, set.size()); set.enterScope(Scope.SESSION, Scope.DOCUMENT); final String test4 = "test4"; set.add(test4); set.add(test3); Assert.assertTrue(set.contains(test1)); Assert.assertTrue(set.contains(test2)); Assert.assertTrue(set.contains(test4)); Assert.assertEquals(3, set.size()); final Collection<String> col = new java.util.ArrayList<String>(); col.add(test1); col.add(test2); col.add(test4); set.removeAll(col); Assert.assertFalse(set.contains(test1)); Assert.assertFalse(set.contains(test2)); Assert.assertFalse(set.contains(test4)); Assert.assertEquals(0, set.size()); }