Search in sources :

Example 21 with Cookie

use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method cookieCookieTest.

/*
   * @testName: cookieCookieTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:535;
   * 
   * @test_Strategy: Add a cookie to be set.
   */
@Test
public void cookieCookieTest() throws Fault {
    String error = "Unexpected response returned:";
    Invocation.Builder builder = createBuilderForMethod("cookie");
    Cookie cookie = new Cookie("tck", "cts");
    String response = builder.cookie(cookie).buildGet().invoke(String.class);
    assertContainsIgnoreCase(response, "cts", error, response);
}
Also used : Cookie(jakarta.ws.rs.core.Cookie) Invocation(jakarta.ws.rs.client.Invocation) Test(org.junit.jupiter.api.Test)

Example 22 with Cookie

use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.

the class RequestFilter method getCookiesIsReadOnly.

public void getCookiesIsReadOnly() {
    Map<String, Cookie> cookies = requestContext.getCookies();
    int length = cookies.size();
    try {
        cookies.put("key", new Cookie("coo", "kie"));
    } catch (Exception e) {
    // expected, but optional
    }
    cookies = requestContext.getCookies();
    if (assertTrue(cookies.size() == length, "Cookie was added present"))
        return;
    abortWithEntity("#getCookies is read-only as expected");
}
Also used : Cookie(jakarta.ws.rs.core.Cookie) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 23 with Cookie

use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorTest20.

/*
   * @testName: constructorTest20
   *
   * @assertion_ids: JAXRS:JAVADOC:108; JAXRS:JAVADOC:100; JAXRS:JAVADOC:101;
   * JAXRS:JAVADOC:103; JAXRS:JAVADOC:50; JAXRS:JAVADOC:53; JAXRS:JAVADOC:54;
   * JAXRS:JAVADOC:55; JAXRS:JAVADOC:56;
   *
   * @test_Strategy: Create a NewCookie instance using constructor
   * Cookie(String, String, String, String) NewCookie(Cookie, String comment,
   * int maxAge, boolean secure)
   */
@Test
public void constructorTest20() throws Fault {
    String name = "name_1";
    String value = "value_1";
    String path = "";
    String domain = "y.x.foo.com";
    String comment = "";
    int maxage = jakarta.ws.rs.core.NewCookie.DEFAULT_MAX_AGE;
    int version = 1;
    boolean secure = false;
    Cookie ck20 = new Cookie(name, value, path, domain);
    NewCookie nck20 = new NewCookie(ck20, comment, maxage, secure);
    verifyNewCookie(nck20, name, value, path, domain, version, comment, maxage, secure);
}
Also used : Cookie(jakarta.ws.rs.core.Cookie) NewCookie(jakarta.ws.rs.core.NewCookie) NewCookie(jakarta.ws.rs.core.NewCookie) Test(org.junit.jupiter.api.Test)

Example 24 with Cookie

use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorTest25.

/*
   * @testName: constructorTest25
   * 
   * @assertion_ids: JAXRS:JAVADOC:108; JAXRS:JAVADOC:100; JAXRS:JAVADOC:101;
   * JAXRS:JAVADOC:103; JAXRS:JAVADOC:49; JAXRS:JAVADOC:53; JAXRS:JAVADOC:54;
   * JAXRS:JAVADOC:55; JAXRS:JAVADOC:56;
   * 
   * @test_Strategy: Create a version 1 NewCookie instance using constructor
   * Cookie(String, String, String, String, int) NewCookie(Cookie, String
   * comment, int maxAge, boolean secure)
   */
@Test
public void constructorTest25() throws Fault {
    String name = "name_1";
    String value = "value_1";
    String path = "/acme";
    String domain = "y.x.foo.com";
    int version = 1;
    String comment = "cts test comment";
    int maxage = 12345;
    boolean secure = false;
    Cookie ck25 = new Cookie(name, value, path, domain, version);
    NewCookie nck25 = new NewCookie(ck25, comment, maxage, secure);
    verifyNewCookie(nck25, name, value, path, domain, version, comment, maxage, secure);
}
Also used : Cookie(jakarta.ws.rs.core.Cookie) NewCookie(jakarta.ws.rs.core.NewCookie) NewCookie(jakarta.ws.rs.core.NewCookie) Test(org.junit.jupiter.api.Test)

Example 25 with Cookie

use of jakarta.ws.rs.core.Cookie in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorTest24.

/*
   * @testName: constructorTest24
   * 
   * @assertion_ids: JAXRS:JAVADOC:108; JAXRS:JAVADOC:100; JAXRS:JAVADOC:101;
   * JAXRS:JAVADOC:103; JAXRS:JAVADOC:49; JAXRS:JAVADOC:53; JAXRS:JAVADOC:54;
   * JAXRS:JAVADOC:55; JAXRS:JAVADOC:56;
   * 
   * @test_Strategy: Create a version 1 NewCookie instance using constructor
   * Cookie(String, String, String, String, int) NewCookie(Cookie, String
   * comment, int maxAge, boolean secure)
   */
@Test
public void constructorTest24() throws Fault {
    String name = "name_1";
    String value = "value_1";
    String path = "/acme";
    String domain = "y.x.foo.com";
    int version = 1;
    String comment = "cts test comment";
    int maxage = jakarta.ws.rs.core.NewCookie.DEFAULT_MAX_AGE;
    boolean secure = true;
    Cookie ck24 = new Cookie(name, value, path, domain, version);
    NewCookie nck24 = new NewCookie(ck24, comment, maxage, secure);
    verifyNewCookie(nck24, name, value, path, domain, version, comment, maxage, secure);
}
Also used : Cookie(jakarta.ws.rs.core.Cookie) NewCookie(jakarta.ws.rs.core.NewCookie) NewCookie(jakarta.ws.rs.core.NewCookie) Test(org.junit.jupiter.api.Test)

Aggregations

Cookie (jakarta.ws.rs.core.Cookie)36 Test (org.junit.jupiter.api.Test)31 NewCookie (jakarta.ws.rs.core.NewCookie)21 Response (jakarta.ws.rs.core.Response)7 Invocation (jakarta.ws.rs.client.Invocation)3 ParamEntityWithFromString (ee.jakarta.tck.ws.rs.ee.rs.ParamEntityWithFromString)2 GET (jakarta.ws.rs.GET)2 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)2 Path (jakarta.ws.rs.Path)1 Client (jakarta.ws.rs.client.Client)1 WebTarget (jakarta.ws.rs.client.WebTarget)1 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ThrottledClient (jaxrs.examples.client.custom.ThrottledClient)1