Search in sources :

Example 6 with NewCookie

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

the class JAXRSClientIT method parseTest1.

/*
   * @testName: parseTest1
   * 
   * @assertion_ids: JAXRS:JAVADOC:111; 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 Cookie instance by Parsing a String
   */
@Test
public void parseTest1() throws Fault {
    String NewCookie_toParse = "NAME_1=Value_1;";
    String name = "name_1";
    String value = "value_1";
    String path = "";
    String domain = "";
    int version = 1;
    NewCookie nck26 = jakarta.ws.rs.core.NewCookie.valueOf(NewCookie_toParse);
    verifyNewCookie(nck26, name, value, path, domain, version, "", -1, false);
}
Also used : NewCookie(jakarta.ws.rs.core.NewCookie) Test(org.junit.jupiter.api.Test)

Example 7 with NewCookie

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

the class JAXRSClientIT method headerTest.

/*
   * @testName: headerTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:139; JAXRS:JAVADOC:141; JAXRS:JAVADOC:148;
   * JAXRS:JAVADOC:123; JAXRS:JAVADOC:124; JAXRS:JAVADOC:125; JAXRS:JAVADOC:97;
   * 
   * @test_Strategy: Create an instance of Response using
   * Response.ResponseBuilder.header(String, Object).build() verify that correct
   * status code is returned
   */
@Test
public void headerTest() throws Fault {
    VerificationResult result;
    int status = 200;
    List<String> type = Arrays.asList("text/plain", "text/html");
    List<String> encoding = Arrays.asList("gzip", "compress");
    String name = "name_1";
    String value = "value_1";
    Cookie ck1 = new Cookie(name, value);
    NewCookie nck1 = new NewCookie(ck1);
    List<String> cookies = Arrays.asList(nck1.toString().toLowerCase());
    Response resp = Response.status(status).header(HttpHeaders.CONTENT_ENCODING, encoding.get(0)).header(HttpHeaders.CONTENT_ENCODING, encoding.get(1)).header("Content-Language", "en-US").header("Content-Language", "en-GB").header("Content-Language", "zh-CN").header("Cache-Control", "no-transform").header("Set-Cookie", "name_1=value_1;version=1").header(HttpHeaders.CONTENT_TYPE, type.get(0)).header(HttpHeaders.CONTENT_TYPE, type.get(1)).build();
    result = verifyStatus(resp, status);
    result.append(verifyEncoding(resp, encoding));
    result.append(verifyLanguage(resp, getLangList()));
    result.append(verifyContentType(resp, type));
    result.append(verifyCookies(resp, cookies));
    logMsg(result);
    assertResultTrue(result);
}
Also used : Cookie(jakarta.ws.rs.core.Cookie) NewCookie(jakarta.ws.rs.core.NewCookie) Response(jakarta.ws.rs.core.Response) NewCookie(jakarta.ws.rs.core.NewCookie) Test(org.junit.jupiter.api.Test)

Example 8 with NewCookie

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

the class JAXRSClientIT method cloneTest.

/*
   * @testName: cloneTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:139; JAXRS:JAVADOC:141; JAXRS:JAVADOC:143;
   * JAXRS:JAVADOC:123; JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
   * 
   * @test_Strategy: Create an instance of Response using
   * Response.ResponseBuilder.clone() verify that correct status code is
   * returned
   */
@Test
public void cloneTest() throws Fault {
    VerificationResult result;
    int status = 200;
    List<String> type = Arrays.asList("text/plain", "text/html");
    List<String> encoding = Arrays.asList("gzip");
    List<String> lang = getLangList();
    String name = "name_1";
    String value = "value_1";
    Cookie ck1 = new Cookie(name, value);
    NewCookie nck1 = new NewCookie(ck1);
    List<String> cookies = Arrays.asList(nck1.toString().toLowerCase());
    Response.ResponseBuilder respb1 = Response.status(status).header("Content-type", "text/plain").header("Content-type", "text/html").header("Content-Language", "en-US").header("Content-Language", "en-GB").header("Content-Language", "zh-CN").header("Cache-Control", "no-transform").header("Set-Cookie", "name_1=value_1;version=1").header(HttpHeaders.CONTENT_ENCODING, "gzip");
    Response.ResponseBuilder respb2;
    respb2 = respb1.clone();
    Response resp2 = respb2.build();
    result = verifyStatus(resp2, status);
    result.append(verifyEncoding(resp2, encoding));
    result.append(verifyLanguage(resp2, lang));
    result.append(verifyContentType(resp2, type));
    result.append(verifyCookies(resp2, cookies));
    String content = "TestOnly";
    Response resp1 = respb1.entity(content).cookie((NewCookie[]) null).build();
    result.append(verifyContent(resp1, content));
    result.append(verifyStatus(resp1, status));
    result.append(verifyEncoding(resp1, encoding));
    result.append(verifyLanguage(resp1, lang));
    result.append(verifyContentType(resp1, type));
    MultivaluedMap<java.lang.String, java.lang.Object> mvp = resp1.getMetadata();
    if (mvp.containsKey("Set-Cookie")) {
        result.pass = false;
        result.message.append("Response contains unexpected Set-Cookie: ").append(mvp.getFirst("Set-Cookie").toString()).append(newline);
    }
    logMsg(result);
    assertResultTrue(result);
}
Also used : Cookie(jakarta.ws.rs.core.Cookie) NewCookie(jakarta.ws.rs.core.NewCookie) Response(jakarta.ws.rs.core.Response) NewCookie(jakarta.ws.rs.core.NewCookie) Test(org.junit.jupiter.api.Test)

Example 9 with NewCookie

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

the class JAXRSClientIT method constructorTest1.

/*
   * @testName: constructorTest1
   * 
   * @assertion_ids: JAXRS:JAVADOC:107; JAXRS:JAVADOC:100; JAXRS:JAVADOC:101;
   * JAXRS:JAVADOC:103; JAXRS:JAVADOC:51; JAXRS:JAVADOC:53; JAXRS:JAVADOC:54;
   * JAXRS:JAVADOC:55; JAXRS:JAVADOC:56;
   * 
   * @test_Strategy: Create a NewCookie instance using constructor
   * Cookie(String, String) NewCookie(Cookie)
   */
@Test
public void constructorTest1() 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;
    Cookie ck1 = new Cookie(name, value);
    NewCookie nck1 = new NewCookie(ck1);
    verifyNewCookie(nck1, 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 10 with NewCookie

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

the class JAXRSClientIT method constructorTest17.

/*
   * @testName: constructorTest17
   * 
   * @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 constructorTest17() throws Fault {
    // ToDo: Create a list of name, value, path, domain
    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 = 123456;
    boolean secure = true;
    NewCookie nck17 = new NewCookie(name, value, path, domain, version, comment, maxage, secure);
    verifyNewCookie(nck17, name, value, path, domain, version, comment, maxage, secure);
}
Also used : 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