/**
* Tests if null cookie values are handled correctly.
*/
public void testNullCookieValueFormatting() {
Cookie cookie = new Cookie("name", null);
cookie.setDomain(".whatever.com");
cookie.setPath("/");
cookie.setDomainAttributeSpecified(true);
cookie.setPathAttributeSpecified(true);
CookieSpec cookiespec = new RFC2109Spec();
Header[] headers = cookiespec.formatCookies(new Cookie[] { cookie });
assertNotNull(headers);
assertEquals(1, headers.length);
assertEquals("$Version=0; name=; $Path=/; $Domain=.whatever.com",
headers[0].getValue());
cookie.setVersion(1);
headers = cookiespec.formatCookies(new Cookie[] { cookie });
assertNotNull(headers);
assertEquals(1, headers.length);
assertEquals("$Version=\"1\"; name=; $Path=\"/\"; $Domain=\".whatever.com\"",
headers[0].getValue());