Search in sources :

Example 76 with HttpHeaders

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));
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Example 77 with HttpHeaders

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));
}
Also used : Locale(java.util.Locale) HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Example 78 with HttpHeaders

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));
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Example 79 with HttpHeaders

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());
}
Also used : Exchange(org.apache.cxf.message.Exchange) Cookie(javax.ws.rs.core.Cookie) HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 80 with HttpHeaders

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);
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Aggregations

HttpHeaders (javax.ws.rs.core.HttpHeaders)87 Test (org.junit.Test)57 Message (org.apache.cxf.message.Message)31 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 Optional (java.util.Optional)11 CatalogFramework (ddf.catalog.CatalogFramework)10 MultipartBody (org.apache.cxf.jaxrs.ext.multipart.MultipartBody)10 JsonObject (com.google.gson.JsonObject)9 Locale (java.util.Locale)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 Response (javax.ws.rs.core.Response)8 UriInfo (javax.ws.rs.core.UriInfo)8 IOException (java.io.IOException)7 WebApplicationException (javax.ws.rs.WebApplicationException)7 MediaType (javax.ws.rs.core.MediaType)7 RequestInfo (com.liferay.apio.architect.request.RequestInfo)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 Conditions (com.liferay.apio.architect.test.util.json.Conditions)5 OutputStream (java.io.OutputStream)5 Annotation (java.lang.annotation.Annotation)5