@Test public void testSerializeNewCookie() { RuntimeDelegate rd = RuntimeDelegate.getInstance(); HeaderDelegate<NewCookie> newCookieHeaderDelegate = rd.createHeaderDelegate(NewCookie.class); if (newCookieHeaderDelegate == null) { fail("NewCookie header delegate is not regestered in RuntimeDelegateImpl"); } String expectedCookieSerialization = "MyCookie=MyCookieValue;Version=1;Path=.;Domain=mydomain;Comment=Comment;Max-Age=21600;Secure"; NewCookie cookieToSerialize = new NewCookie("MyCookie", "MyCookieValue", ".", "mydomain", 1, "Comment", 21600, true); String serializedCookie = cookieToSerialize.toString(); assertEquals(expectedCookieSerialization, serializedCookie); try { newCookieHeaderDelegate.toString(null); fail("NewCookie is null - IllegalArgumentException must be thrown"); } catch (IllegalArgumentException e) { } }
public String toString(NewCookie cookie) { if (cookie == null) { throw new IllegalArgumentException(Messages.getMessage("cookieIsNull")); } return buildCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie .getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie .isSecure()); }
NewCookieHeaderDelegate implements HeaderDelegate<NewCookie> { public String toString(NewCookie cookie) { if (cookie == null) { throw new IllegalArgumentException(Messages.getMessage("cookieIsNull")); } return buildCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie .getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie .isSecure()); } }
NewCookieHeaderDelegate implements HeaderDelegate<NewCookie> { public String toString(NewCookie cookie) { if (cookie == null) { throw new IllegalArgumentException(Messages.getMessage("cookieIsNull")); } return buildCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie .getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie .isSecure()); }  }
NewCookieHeaderDelegate implements HeaderDelegate<NewCookie> { public String toString(NewCookie cookie) { if (cookie == null) { throw new IllegalArgumentException(Messages.getMessage("cookieIsNull")); } return buildCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie .getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie .isSecure()); }  NewCookie fromString(String cookie); String toString(NewCookie cookie); }
NewCookieHeaderDelegate implements HeaderDelegate<NewCookie> { public String toString(NewCookie cookie) { if (cookie == null) { throw new IllegalArgumentException(Messages.getMessage("cookieIsNull")); } return buildCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie .getDomain(), cookie.getVersion(), cookie.getComment(), cookie.getMaxAge(), cookie .isSecure()); }  NewCookie fromString(String cookie); String toString(NewCookie cookie);  }