Search in sources :

Example 26 with NewCookie

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

the class JAXRSClientIT method getCookiesTest.

/*
   * @testName: getCookiesTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:844;
   * 
   * @test_Strategy: Get any new cookies set on the response message.
   */
@Test
public void getCookiesTest() throws Fault {
    NewCookie cookie1 = new NewCookie("c1", "v1");
    NewCookie cookie2 = new NewCookie("c2", "v2");
    List<String> cookies = Arrays.asList(cookie1.toString().toLowerCase(), cookie2.toString().toLowerCase());
    Response response = Response.ok().cookie(cookie1).cookie(cookie2).build();
    // verifyCookies style test
    VerificationResult result = verifyCookies(response, cookies);
    logMsg(result);
    assertResultTrue(result);
    // getCookies test
    Map<String, NewCookie> map = response.getCookies();
    for (Entry<String, NewCookie> entry : map.entrySet()) if (entry.getKey().equals("c1"))
        assertTrue(entry.getValue().equals(cookie1), cookie1.toString() + "not match" + entry.getValue());
    else if (entry.getKey().equals("c2"))
        assertTrue(entry.getValue().equals(cookie2), cookie2.toString() + "not match" + entry.getValue());
    else
        assertTrue(false, "Got unknown cookie" + entry.getKey());
    logMsg("#getCookies returned expected cookies");
}
Also used : Response(jakarta.ws.rs.core.Response) NewCookie(jakarta.ws.rs.core.NewCookie) Test(org.junit.jupiter.api.Test)

Example 27 with NewCookie

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

the class JAXRSClientIT method checkCreatedHeaderDelegateNewCookieTest.

/*
   * @testName: checkCreatedHeaderDelegateNewCookieTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:287; JAXRS:JAVADOC:294; JAXRS:JAVADOC:296;
   * 
   * @test_Strategy: Check that RuntimeDelegate.createHeaderDelegate<NewCookie>
   * makes no exception and is not null
   * 
   */
@Test
public void checkCreatedHeaderDelegateNewCookieTest() throws Fault {
    String cookieName = "cookieName";
    String cookieValue = "cookieValue";
    HeaderDelegate<NewCookie> hdnc = delegate.createHeaderDelegate(NewCookie.class);
    assertTrue(hdnc != null, "HeaderDelegate<NewCookie> has not been created");
    NewCookie cookie = new NewCookie(cookieName, cookieValue);
    String result = hdnc.toString(cookie);
    NewCookie serialized = hdnc.fromString(result);
    assertTrue(cookieName.equals(serialized.getName()), "HeaderDelegate<NewCookie> fromString(),toString() failed");
}
Also used : NewCookie(jakarta.ws.rs.core.NewCookie) Test(org.junit.jupiter.api.Test)

Example 28 with NewCookie

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

the class JAXRSClientIT method constructorTest15.

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

Example 29 with NewCookie

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

the class JAXRSClientIT method constructorTest6.

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

Example 30 with NewCookie

use of jakarta.ws.rs.core.NewCookie 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)

Aggregations

NewCookie (jakarta.ws.rs.core.NewCookie)48 Test (org.junit.jupiter.api.Test)41 Cookie (jakarta.ws.rs.core.Cookie)20 Response (jakarta.ws.rs.core.Response)13 Path (jakarta.ws.rs.Path)4 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)4 GET (jakarta.ws.rs.GET)3 CacheControl (jakarta.ws.rs.core.CacheControl)3 Date (java.util.Date)3 ParamEntityWithFromString (ee.jakarta.tck.ws.rs.ee.rs.ParamEntityWithFromString)2 POST (jakarta.ws.rs.POST)2 IOException (java.io.IOException)2 Consumes (jakarta.ws.rs.Consumes)1 ProcessingException (jakarta.ws.rs.ProcessingException)1 Produces (jakarta.ws.rs.Produces)1 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)1 ClientResponseContext (jakarta.ws.rs.client.ClientResponseContext)1 URISyntaxException (java.net.URISyntaxException)1