CookieCollection implements Collection<Cookie> { @Override public boolean remove(Object o) { if(o instanceof String) { return cookieMap.remove((String)o) != null; } if(o instanceof Cookie) { Cookie c=(Cookie)o; return cookieMap.remove(c.getName()) != null; } return false; } CookieCollection();  CookieCollection(Cookie... cookies);  CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie [] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear();  }
@Test public void remove() throws Exception { CookieCollection cookies = new CookieCollection(cookie, brownieCookie, cupsCookie); cookies.remove(cookie); Assert.assertEquals(2, cookies.size()); Assert.assertFalse(cookies.contains(cookie)); Assert.assertFalse(cookies.contains(COOKIE_NAME)); Assert.assertTrue(cookies.contains(brownieCookie)); Assert.assertTrue(cookies.contains(BROWNIE_NAME)); }