use of javax.ws.rs.core.Cookie in project cxf by apache.
the class CookieHeaderProviderTest method testToString.
@Test
public void testToString() {
Cookie c = new Cookie("foo", "bar", "path", "domain", 2);
assertEquals("$Version=2;foo=bar;$Path=path;$Domain=domain", c.toString());
}
use of javax.ws.rs.core.Cookie in project cxf by apache.
the class HttpHeadersImplTest method testGetCookies.
@Test
public void testGetCookies() throws Exception {
Message m = new MessageImpl();
m.setExchange(new ExchangeImpl());
MetadataMap<String, String> headers = createHeaders();
headers.putSingle(HttpHeaders.COOKIE, "a=$b;c=d");
m.put(Message.PROTOCOL_HEADERS, headers);
HttpHeaders h = new HttpHeadersImpl(m);
Map<String, Cookie> cookies = h.getCookies();
assertEquals(2, cookies.size());
assertEquals("$b", cookies.get("a").getValue());
assertEquals("d", cookies.get("c").getValue());
}
use of javax.ws.rs.core.Cookie in project cxf by apache.
the class HttpHeadersImplTest method testGetCookieWithAttributes.
@Test
public void testGetCookieWithAttributes() throws Exception {
Message m = new MessageImpl();
m.setExchange(new ExchangeImpl());
MetadataMap<String, String> headers = createHeaders();
headers.putSingle(HttpHeaders.COOKIE, "$Version=1;a=b");
m.put(Message.PROTOCOL_HEADERS, headers);
HttpHeaders h = new HttpHeadersImpl(m);
Map<String, Cookie> cookies = h.getCookies();
assertEquals(1, cookies.size());
Cookie cookie = cookies.get("a");
assertEquals("b", cookie.getValue());
assertEquals(1, cookie.getVersion());
}
use of javax.ws.rs.core.Cookie in project cxf by apache.
the class HttpHeadersImplTest method testGetCookiesWithAttributes.
@Test
public void testGetCookiesWithAttributes() throws Exception {
Message m = new MessageImpl();
m.setExchange(new ExchangeImpl());
MetadataMap<String, String> headers = createHeaders();
headers.putSingle(HttpHeaders.COOKIE, "$Version=1;a=b, $Version=1;c=d");
m.put(Message.PROTOCOL_HEADERS, headers);
HttpHeaders h = new HttpHeadersImpl(m);
Map<String, Cookie> cookies = h.getCookies();
assertEquals(2, cookies.size());
Cookie cookieA = cookies.get("a");
assertEquals("b", cookieA.getValue());
assertEquals(1, cookieA.getVersion());
Cookie cookieC = cookies.get("c");
assertEquals("d", cookieC.getValue());
assertEquals(1, cookieA.getVersion());
}
use of javax.ws.rs.core.Cookie in project cxf by apache.
the class HttpHeadersImpl method getCookies.
public Map<String, Cookie> getCookies() {
List<String> values = headers.get(HttpHeaders.COOKIE);
if (values == null || values.isEmpty()) {
return Collections.emptyMap();
}
Map<String, Cookie> cl = new HashMap<>();
for (String value : values) {
if (value == null) {
continue;
}
List<String> cs = getHeaderValues(HttpHeaders.COOKIE, value, getCookieSeparator(value));
for (String c : cs) {
Cookie cookie = Cookie.valueOf(c);
cl.put(cookie.getName(), cookie);
}
}
return cl;
}
Aggregations