use of javax.ws.rs.core.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testGetHeaderNameValue.
@Test
public void testGetHeaderNameValue() throws Exception {
Message m = createMessage(createHeader("COMPLEX_HEADER", "b=c; param=c, a=b;param=b"));
m.put(HttpHeadersImpl.HEADER_SPLIT_PROPERTY, "true");
HttpHeaders h = new HttpHeadersImpl(m);
List<String> values = h.getRequestHeader("COMPLEX_HEADER");
assertNotNull(values);
assertEquals(2, values.size());
assertEquals("b=c; param=c", values.get(0));
assertEquals("a=b;param=b", values.get(1));
}
use of javax.ws.rs.core.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testSingleAcceptableLanguages.
@Test
public void testSingleAcceptableLanguages() throws Exception {
Message m = createMessage(createHeader(HttpHeaders.ACCEPT_LANGUAGE, "en"));
HttpHeaders h = new HttpHeadersImpl(m);
List<Locale> languages = h.getAcceptableLanguages();
assertEquals(1, languages.size());
assertEquals(new Locale("en"), languages.get(0));
}
use of javax.ws.rs.core.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testGetHeader.
@Test
public void testGetHeader() throws Exception {
Message m = createMessage(createHeaders());
m.put(HttpHeadersImpl.HEADER_SPLIT_PROPERTY, "true");
HttpHeaders h = new HttpHeadersImpl(m);
List<String> acceptValues = h.getRequestHeader("Accept");
assertEquals(3, acceptValues.size());
assertEquals("text/bar;q=0.6", acceptValues.get(0));
assertEquals("text/*;q=1", acceptValues.get(1));
assertEquals("application/xml", acceptValues.get(2));
List<String> contentValues = h.getRequestHeader("Content-Type");
assertEquals(1, contentValues.size());
assertEquals("*/*", contentValues.get(0));
List<String> dateValues = h.getRequestHeader("Date");
assertEquals(1, dateValues.size());
assertEquals("Tue, 21 Oct 2008 17:00:00 GMT", dateValues.get(0));
}
use of javax.ws.rs.core.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testGetCookiesWithCRLF.
@Test
public void testGetCookiesWithCRLF() throws Exception {
Message m = createMessage(createHeader(HttpHeaders.COOKIE, "a=b\r\nc=d"));
Exchange ex = new ExchangeImpl();
ex.setInMessage(m);
ex.put(HttpHeadersImpl.COOKIE_SEPARATOR_PROPERTY, "crlf");
m.setExchange(ex);
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.HttpHeaders in project cxf by apache.
the class HttpHeadersImplTest method testGetHeaderString.
@Test
public void testGetHeaderString() throws Exception {
Message m = createMessage(createHeaders());
HttpHeaders h = new HttpHeadersImpl(m);
String date = h.getHeaderString("Date");
assertEquals("Tue, 21 Oct 2008 17:00:00 GMT", date);
}
Aggregations