CookieUtils { @SuppressWarnings("unchecked") public static Map<String,Cookie> toMap(Cookie[] cookies){ if(cookies == null || cookies.length == 0) return new HashMap(0); Map map = new HashMap(cookies.length * 2); for(Cookie c : cookies) { map.put(c.getName(), c); } return map; }  @SuppressWarnings("unchecked") static Map<String,Cookie> toMap(Cookie[] cookies);  }
@Test public void toMap() { Cookie[] cs = new Cookie[]{new Cookie("empty",""),new Cookie("blank"," ")}; Map<String,Cookie> map = CookieUtils.toMap(cs); Assert.assertNotNull(map.get("empty")); Assert.assertNull(map.get("null")); Assert.assertEquals(map.size(),2); }