### Question:
CookieHeaderDelegate implements HeaderDelegate<Cookie> { public String toString(Cookie cookie) { if (cookie == null) { throw new IllegalArgumentException(Messages.getMessage("headerIsNull", "Cookie")); } StringBuilder cookieHeader = new StringBuilder(); cookieHeader.append(VERSION + "=").append(cookie.getVersion()).append(';'); cookieHeader.append(cookie.getName()).append('='); appendValue(cookieHeader, cookie.getValue()); if (cookie.getDomain() != null) { cookieHeader.append(";" + DOMAIN + "="); appendValue(cookieHeader, cookie.getDomain()); } if (cookie.getPath() != null) { cookieHeader.append(";" + PATH + "="); appendValue(cookieHeader, cookie.getPath()); } return cookieHeader.toString(); }  Cookie fromString(String cookie); String toString(Cookie cookie);  }### Answer:
@Test public void testSerializeNewCookie() { RuntimeDelegate rd = RuntimeDelegate.getInstance(); HeaderDelegate<Cookie> cookieHeaderDelegate = rd.createHeaderDelegate(Cookie.class); if (cookieHeaderDelegate == null) { fail("Cookie header delegate is not regestered in RuntimeDelegateImpl"); } String expectedCookieSerialization = "$Version=1;MyCookie=MyCookieValue;$Domain=mydomain;$Path=."; Cookie cookieToSerialize = new Cookie("MyCookie", "MyCookieValue", ".", "mydomain", 1); String serializedCookie = cookieToSerialize.toString(); assertEquals(expectedCookieSerialization, serializedCookie); try { cookieHeaderDelegate.toString(null); fail("Cookie is null - IllegalArgumentException must be thrown"); } catch (IllegalArgumentException e) { } }