* Test parsing cookie <tt>"Domain"</tt> attribute.
*/
public void testParseDomain() throws Exception {
CookieSpec cookiespec = new RFC2965Spec();
CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
Header header = new BasicHeader("Set-Cookie2", "name=value;Domain=.domain.com;Version=1;Domain=");
List<Cookie> cookies = cookiespec.parse(header, origin);
assertNotNull(cookies);
assertEquals(1, cookies.size());
// only the first occurrence of domain attribute is considered, others ignored
ClientCookie cookie = (ClientCookie) cookies.get(0);
assertEquals(".domain.com", cookie.getDomain());
assertTrue(cookie.containsAttribute(ClientCookie.DOMAIN_ATTR));
// should put a leading dot if there is no dot in front of domain
header = new BasicHeader("Set-Cookie2", "name=value;Domain=domain.com;Version=1");
cookies = cookiespec.parse(header, origin);
assertNotNull(cookies);
assertEquals(1, cookies.size());
cookie = (ClientCookie) cookies.get(0);
assertEquals(".domain.com", cookie.getDomain());