Search in sources :

Example 81 with HttpHeaders

use of javax.ws.rs.core.HttpHeaders in project cxf by apache.

the class HttpHeadersImplTest method testGetCookies.

@Test
public void testGetCookies() throws Exception {
    Message m = createMessage(createHeader(HttpHeaders.COOKIE, "a=$b;c=d"));
    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 : Cookie(javax.ws.rs.core.Cookie) HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Example 82 with HttpHeaders

use of javax.ws.rs.core.HttpHeaders in project cxf by apache.

the class HttpHeadersImplTest method testGetCookiesWithAttributes.

@Test
public void testGetCookiesWithAttributes() throws Exception {
    Message m = createMessage(createHeader(HttpHeaders.COOKIE, "$Version=1;a=b, $Version=1;c=d"));
    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());
}
Also used : Cookie(javax.ws.rs.core.Cookie) HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Example 83 with HttpHeaders

use of javax.ws.rs.core.HttpHeaders in project cxf by apache.

the class HttpHeadersImplTest method testGetHeader2.

@Test
public void testGetHeader2() throws Exception {
    Message m = createMessage(createHeaders());
    HttpHeaders h = new HttpHeadersImpl(m);
    List<String> values = h.getRequestHeader("a");
    assertEquals(2, values.size());
    assertEquals("1", values.get(0));
    assertEquals("2", values.get(1));
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Example 84 with HttpHeaders

use of javax.ws.rs.core.HttpHeaders in project cxf by apache.

the class HttpHeadersImplTest method testGetLanguage.

@Test
public void testGetLanguage() throws Exception {
    Message m = createMessage(createHeader(HttpHeaders.CONTENT_LANGUAGE, "en-US"));
    HttpHeaders h = new HttpHeadersImpl(m);
    assertEquals("en_US", h.getLanguage().toString());
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Example 85 with HttpHeaders

use of javax.ws.rs.core.HttpHeaders in project cxf by apache.

the class HttpHeadersImplTest method testGetMissingContentLength.

@Test
public void testGetMissingContentLength() throws Exception {
    Message m = createMessage(new MetadataMap<String, String>());
    HttpHeaders h = new HttpHeadersImpl(m);
    assertEquals(-1, h.getLength());
}
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