Search in sources :

Example 11 with Cookie

use of javax.ws.rs.core.Cookie in project jersey by jersey.

the class CookieParamAsStringTest method testStringPost.

@Test
public void testStringPost() throws ExecutionException, InterruptedException {
    initiateWebApplication(ResourceString.class);
    final ContainerResponse responseContext = apply(RequestContextBuilder.from("/", "POST").cookie(new Cookie("arg1", "a")).cookie(new Cookie("arg2", "b")).cookie(new Cookie("arg3", "c")).entity("content").build());
    assertEquals("content", responseContext.getEntity());
}
Also used : Cookie(javax.ws.rs.core.Cookie) ContainerResponse(org.glassfish.jersey.server.ContainerResponse) Test(org.junit.Test)

Example 12 with Cookie

use of javax.ws.rs.core.Cookie in project jersey by jersey.

the class CookieParamStringConstructorTest method testStringConstructorDefaultOverride.

@Test
public void testStringConstructorDefaultOverride() throws ExecutionException, InterruptedException {
    initiateWebApplication(ResourceStringDefault.class);
    _test("/", new Cookie("args", "2.718"));
}
Also used : Cookie(javax.ws.rs.core.Cookie) Test(org.junit.Test)

Example 13 with Cookie

use of javax.ws.rs.core.Cookie in project jersey by jersey.

the class CookieParamStringConstructorTest method testStringConstructorListGet.

@Test
public void testStringConstructorListGet() throws ExecutionException, InterruptedException {
    initiateWebApplication(ResourceStringList.class);
    _test("/", "application/stringlist", new Cookie("args", "3.145"));
}
Also used : Cookie(javax.ws.rs.core.Cookie) Test(org.junit.Test)

Example 14 with Cookie

use of javax.ws.rs.core.Cookie in project jersey by jersey.

the class CookieParamStringConstructorTest method testStringConstructorListDefaultOverride.

@Test
public void testStringConstructorListDefaultOverride() throws ExecutionException, InterruptedException {
    initiateWebApplication(ResourceStringListDefaultOverride.class);
    _test("/", new Cookie("args", "2.718"));
}
Also used : Cookie(javax.ws.rs.core.Cookie) Test(org.junit.Test)

Example 15 with Cookie

use of javax.ws.rs.core.Cookie in project jersey by jersey.

the class FormResource method processForm.

/**
     * Process the form submission. Produces a table showing the form field
     * values submitted.
     * @return a dynamically generated HTML table.
     * @param formData the data from the form submission
     */
@POST
@Consumes("application/x-www-form-urlencoded")
public String processForm(MultivaluedMap<String, String> formData) {
    StringBuilder buf = new StringBuilder();
    buf.append("<html><head><title>Form results</title></head><body>");
    buf.append("<p>Hello, you entered the following information: </p><table border='1'>");
    for (String key : formData.keySet()) {
        if (key.equals("submit")) {
            continue;
        }
        buf.append("<tr><td>");
        buf.append(key);
        buf.append("</td><td>");
        buf.append(formData.getFirst(key));
        buf.append("</td></tr>");
    }
    for (Cookie c : headers.getCookies().values()) {
        buf.append("<tr><td>Cookie: ");
        buf.append(c.getName());
        buf.append("</td><td>");
        buf.append(c.getValue());
        buf.append("</td></tr>");
    }
    buf.append("</table></body></html>");
    return buf.toString();
}
Also used : NewCookie(javax.ws.rs.core.NewCookie) Cookie(javax.ws.rs.core.Cookie) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Aggregations

Cookie (javax.ws.rs.core.Cookie)80 Test (org.junit.Test)40 Response (javax.ws.rs.core.Response)18 HashMap (java.util.HashMap)12 WebTarget (javax.ws.rs.client.WebTarget)12 HttpServletResponse (javax.servlet.http.HttpServletResponse)10 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)8 NewCookie (javax.ws.rs.core.NewCookie)7 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)7 Map (java.util.Map)5 Message (org.apache.cxf.message.Message)5 Entitlement (com.sun.identity.entitlement.Entitlement)4 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)4 Privilege (com.sun.identity.entitlement.Privilege)4 PrivilegeManager (com.sun.identity.entitlement.PrivilegeManager)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 HttpHeaders (javax.ws.rs.core.HttpHeaders)4 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)4 BeforeClass (org.testng.annotations.BeforeClass)4 SSOToken (com.iplanet.sso.SSOToken)3