Search in sources :

Example 16 with CacheControl

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

the class JAXRSClientIT method emptyConstructorTest.

/*
     * @testName: emptyConstructorTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:24; JAXRS:JAVADOC:28; JAXRS:JAVADOC:29;
     * JAXRS:JAVADOC:32; JAXRS:JAVADOC:33; JAXRS:JAVADOC:34; JAXRS:JAVADOC:35;
     * JAXRS:JAVADOC:36; JAXRS:JAVADOC:37;
     * 
     * @test_Strategy: Client instantiate a CacheControl instance using Constructor
     * CacheControl(). Verify all values are set correctly.
     */
@Test
public void emptyConstructorTest() throws Fault {
    boolean pass = true;
    StringBuffer sb = new StringBuffer();
    CacheControl ccl = new CacheControl();
    pass = verifyList(expected, ccl, sb);
    assertTrue(pass, "At least one assertion failed: " + sb);
}
Also used : CacheControl(jakarta.ws.rs.core.CacheControl) Test(org.junit.jupiter.api.Test)

Example 17 with CacheControl

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

the class JAXRSClientIT method noTransformTest.

/*
     * @testName: noTransformTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:24; JAXRS:JAVADOC:28; JAXRS:JAVADOC:29;
     * JAXRS:JAVADOC:32; JAXRS:JAVADOC:33; JAXRS:JAVADOC:34; JAXRS:JAVADOC:35;
     * JAXRS:JAVADOC:36; JAXRS:JAVADOC:37; JAXRS:JAVADOC:42;
     * 
     * @test_Strategy: Client instantiate a CacheControl instance using Constructor
     * CacheControl(). Verify all values are set correctly.
     */
@Test
public void noTransformTest() throws Fault {
    boolean pass = true;
    StringBuffer sb = new StringBuffer();
    boolean notransform = false;
    expected[4] = notransform;
    CacheControl ccl4 = new CacheControl();
    ccl4.setNoTransform(notransform);
    pass = verifyList(expected, ccl4, sb);
    notransform = true;
    expected[4] = notransform;
    ccl4.setNoTransform(notransform);
    pass &= verifyList(expected, ccl4, sb);
    assertTrue(pass, "At least one assertion failed: " + sb);
}
Also used : CacheControl(jakarta.ws.rs.core.CacheControl) Test(org.junit.jupiter.api.Test)

Example 18 with CacheControl

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

the class JAXRSClientIT method cacheControlTest.

/*
   * @testName: cacheControlTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:533;
   * 
   * @test_Strategy: Set the cache control data of the message.
   */
@Test
public void cacheControlTest() throws Fault {
    String error = "Unexpected response returned:";
    Invocation.Builder builder = createBuilderForMethod("headerstostring");
    CacheControl control = new CacheControl();
    control.setMaxAge(2);
    String response = builder.cacheControl(control).buildGet().invoke(String.class).toLowerCase();
    assertContainsIgnoreCase(response, "max-age", error, response);
}
Also used : Invocation(jakarta.ws.rs.client.Invocation) CacheControl(jakarta.ws.rs.core.CacheControl) Test(org.junit.jupiter.api.Test)

Example 19 with CacheControl

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

the class ResponseTest method getHeaders.

@POST
@Path("headers")
public Response getHeaders(String headers) {
    CacheControl ccl = new CacheControl();
    NewCookie cookie = new NewCookie("cookie", "eikooc");
    String encoding = "gzip";
    Date date = Calendar.getInstance().getTime();
    ResponseBuilder builder = Response.ok();
    if (headers != null && headers.length() != 0) {
        builder = builder.cacheControl(ccl).cookie(cookie).encoding(encoding).expires(date).language(Locale.CANADA_FRENCH);
    }
    return builder.build();
}
Also used : CacheControl(jakarta.ws.rs.core.CacheControl) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Date(java.util.Date) NewCookie(jakarta.ws.rs.core.NewCookie) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Aggregations

CacheControl (jakarta.ws.rs.core.CacheControl)19 Test (org.junit.jupiter.api.Test)18 NewCookie (jakarta.ws.rs.core.NewCookie)3 Response (jakarta.ws.rs.core.Response)3 Date (java.util.Date)3 POST (jakarta.ws.rs.POST)1 Path (jakarta.ws.rs.Path)1 Invocation (jakarta.ws.rs.client.Invocation)1 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)1 HashMap (java.util.HashMap)1