use of javax.ws.rs.core.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testGetCookieWithAttributes.
@Test
public void testGetCookieWithAttributes() throws Exception {
Message m = createMessage(createHeader(HttpHeaders.COOKIE, "$Version=1;a=b"));
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.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testMultipleAcceptableLanguages.
@Test
public void testMultipleAcceptableLanguages() throws Exception {
MetadataMap<String, String> headers = createHeader(HttpHeaders.ACCEPT_LANGUAGE, "en;q=0.7, en-gb;q=0.8, da, zh-Hans-SG;q=0.9");
Message m = createMessage(headers);
HttpHeaders h = new HttpHeadersImpl(m);
List<Locale> languages = h.getAcceptableLanguages();
assertEquals(4, languages.size());
assertEquals(new Locale("da"), languages.get(0));
assertEquals(new Locale("zh", "Hans-SG"), languages.get(1));
assertEquals(new Locale("en", "GB"), languages.get(2));
assertEquals(new Locale("en"), languages.get(3));
}
use of javax.ws.rs.core.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testNoRequestHeader.
@Test
public void testNoRequestHeader() throws Exception {
Message m = createMessage(createHeader("COMPLEX_HEADER", "b=c; param=c, a=b;param=b"));
HttpHeaders h = new HttpHeadersImpl(m);
List<String> values = h.getRequestHeader("HEADER");
assertNull(values);
}
use of javax.ws.rs.core.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testGetNoMediaTypes.
@Test
public void testGetNoMediaTypes() throws Exception {
Message m = new MessageImpl();
m.put(Message.PROTOCOL_HEADERS, Collections.emptyMap());
HttpHeaders h = new HttpHeadersImpl(m);
List<MediaType> acceptValues = h.getAcceptableMediaTypes();
assertEquals(1, acceptValues.size());
assertEquals("*/*", acceptValues.get(0).toString());
}
use of javax.ws.rs.core.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testGetEmptyHeader.
@Test
public void testGetEmptyHeader() throws Exception {
Message m = new MessageImpl();
// this is what happens at runtime and is tested in the system tests
Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
headers.put("A", Collections.<String>emptyList());
m.put(Message.PROTOCOL_HEADERS, headers);
HttpHeaders h = new HttpHeadersImpl(m);
List<String> values = h.getRequestHeader("A");
assertTrue(values.isEmpty());
}
Aggregations