Search in sources :

Example 11 with CacheControl

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

the class JAXRSClientIT method noCacheTest.

/*
     * @testName: noCacheTest
     * 
     * @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:40;
     * 
     * @test_Strategy: Client instantiate a CacheControl instance using Constructor
     * CacheControl(). Verify all values are set correctly.
     */
@Test
public void noCacheTest() throws Fault {
    boolean pass = true;
    StringBuffer sb = new StringBuffer();
    boolean nocache = false;
    expected[2] = nocache;
    CacheControl ccl3 = new CacheControl();
    ccl3.setNoCache(nocache);
    pass = verifyList(expected, ccl3, sb);
    nocache = true;
    expected[2] = nocache;
    ccl3.setNoCache(nocache);
    pass &= verifyList(expected, ccl3, sb);
    assertTrue(pass, "At least one assertion failed: " + sb);
}
Also used : CacheControl(jakarta.ws.rs.core.CacheControl) Test(org.junit.jupiter.api.Test)

Example 12 with CacheControl

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

the class JAXRSClientIT method toStringTest.

/*
     * @testName: toStringTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:24; JAXRS:JAVADOC:38; JAXRS:JAVADOC:39;
     * JAXRS:JAVADOC:40; JAXRS:JAVADOC:41; JAXRS:JAVADOC:42; JAXRS:JAVADOC:43;
     * JAXRS:JAVADOC:44; JAXRS:JAVADOC:45; JAXRS:JAVADOC:46;
     * 
     * @test_Strategy: Client instantiate a CacheControl instance using Constructor
     * CacheControl(). Setting all their properties verify toString method work
     * correctly and accordingly.
     */
@Test
public void toStringTest() throws Fault {
    boolean pass = true;
    StringBuffer sb = new StringBuffer();
    CacheControl ccl8 = new CacheControl();
    ccl8.setProxyRevalidate(true);
    ccl8.setPrivate(true);
    ccl8.setNoTransform(true);
    ccl8.setNoStore(true);
    ccl8.setNoCache(true);
    ccl8.setMustRevalidate(false);
    ccl8.setSMaxAge(-1);
    ccl8.setMaxAge(200);
    String value = ccl8.toString().toLowerCase();
    sb.append(value + newline);
    if (!value.contains("private")) {
        pass = false;
        sb.append("ToString test failed in Private" + newline);
    }
    if (!value.contains("no-cache")) {
        pass = false;
        sb.append("ToString test failed in no-cache" + newline);
    }
    if (!value.contains("no-store")) {
        pass = false;
        sb.append("ToString test failed in no-store" + newline);
    }
    if (!value.contains("no-transform")) {
        pass = false;
        sb.append("ToString test failed in no-transform" + newline);
    }
    if (!value.contains("proxy-revalidate")) {
        pass = false;
        sb.append("ToString test failed in proxy-revalidate" + newline);
    }
    if (!value.contains("max-age=200")) {
        pass = false;
        sb.append("ToString test failed in max-age=200" + newline);
    }
    if (value.contains("s-maxage")) {
        pass = false;
        sb.append("ToString test failed in s-maxage" + newline);
    }
    if (value.contains("must-revalidate")) {
        pass = false;
        sb.append("ToString test failed in must-revalidate" + newline);
    }
    assertTrue(pass, "At least one assertion failed: " + sb);
}
Also used : CacheControl(jakarta.ws.rs.core.CacheControl) Test(org.junit.jupiter.api.Test)

Example 13 with CacheControl

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

the class JAXRSClientIT method privateTest.

/*
     * @testName: privateTest
     * 
     * @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:43;
     * 
     * @test_Strategy: Client instantiate a CacheControl instance using Constructor
     * CacheControl(). Verify all values are set correctly.
     */
@Test
public void privateTest() throws Fault {
    boolean pass = true;
    StringBuffer sb = new StringBuffer();
    boolean _private = false;
    expected[1] = _private;
    CacheControl ccl5 = new CacheControl();
    ccl5.setPrivate(_private);
    pass = verifyList(expected, ccl5, sb);
    _private = true;
    expected[1] = _private;
    ccl5.setPrivate(_private);
    pass &= verifyList(expected, ccl5, sb);
    assertTrue(pass, "At least one assertion failed: " + sb);
}
Also used : CacheControl(jakarta.ws.rs.core.CacheControl) Test(org.junit.jupiter.api.Test)

Example 14 with CacheControl

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

the class JAXRSClientIT method revalidateTest.

/*
     * @testName: revalidateTest
     *
     * @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:39;
     *
     * @test_Strategy: Client instantiate a CacheControl instance using Constructor
     * CacheControl(). Verify all values are set correctly.
     */
@Test
public void revalidateTest() throws Fault {
    boolean pass = true;
    StringBuffer sb = new StringBuffer();
    boolean revalidate = false;
    expected[5] = revalidate;
    CacheControl ccl2 = new CacheControl();
    ccl2.setMustRevalidate(revalidate);
    pass = verifyList(expected, ccl2, sb);
    sb.append("Finished the first round");
    revalidate = true;
    expected[5] = revalidate;
    ccl2.setMustRevalidate(revalidate);
    pass &= verifyList(expected, ccl2, sb);
    assertTrue(pass, "At least one assertion failed: " + sb);
}
Also used : CacheControl(jakarta.ws.rs.core.CacheControl) Test(org.junit.jupiter.api.Test)

Example 15 with CacheControl

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

the class JAXRSClientIT method equalsTest.

/*
     * @testName: equalsTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:24; JAXRS:JAVADOC:25; JAXRS:JAVADOC:31;
     * JAXRS:JAVADOC:38; JAXRS:JAVADOC:39; JAXRS:JAVADOC:40; JAXRS:JAVADOC:41;
     * JAXRS:JAVADOC:42; JAXRS:JAVADOC:43; JAXRS:JAVADOC:44; JAXRS:JAVADOC:45;
     * 
     * @test_Strategy: Client instantiate two CacheControl instance using
     * Constructor CacheControl(). Setting all their properties one by one, verify
     * hashCode and equals methods work correctly and accordingly.
     */
@Test
public void equalsTest() throws Fault {
    boolean pass = true;
    StringBuffer sb = new StringBuffer();
    CacheControl ccl6 = new CacheControl();
    CacheControl ccl7 = new CacheControl();
    ccl6.setProxyRevalidate(false);
    ccl7.setProxyRevalidate(true);
    if (ccl6.equals(ccl7)) {
        pass = false;
        sb.append("UnEqual Test setProxyRevalidate failed." + newline);
    }
    if (ccl6.hashCode() == ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setProxyRevalidate failed." + newline);
    }
    ccl7.setProxyRevalidate(false);
    if (!ccl6.equals(ccl7)) {
        pass = false;
        sb.append("Equal Test setProxyRevalidate failed." + newline);
    }
    if (ccl6.hashCode() != ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode Equal Test setProxyRevalidate failed." + newline);
    }
    ccl6.setPrivate(true);
    ccl7.setPrivate(false);
    if (ccl6.equals(ccl7)) {
        pass = false;
        sb.append("UnEqual Test setPrivate failed." + newline);
    }
    if (ccl6.hashCode() == ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setPrivate failed." + newline);
    }
    ccl7.setPrivate(true);
    if (!ccl6.equals(ccl7)) {
        pass = false;
        sb.append("Equal Test setPrivate failed." + newline);
    }
    if (ccl6.hashCode() != ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode Equal Test setPrivate failed." + newline);
    }
    ccl6.setNoTransform(true);
    ccl7.setNoTransform(false);
    if (ccl6.equals(ccl7)) {
        pass = false;
        sb.append("UnEqual Test setNoTransform failed." + newline);
    }
    if (ccl6.hashCode() == ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setNoTransform failed." + newline);
    }
    ccl7.setNoTransform(true);
    if (!ccl6.equals(ccl7)) {
        pass = false;
        sb.append("Equal Test setNoTransform failed." + newline);
    }
    if (ccl6.hashCode() != ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode Equal Test setNoTransform failed." + newline);
    }
    ccl6.setNoStore(true);
    ccl7.setNoStore(false);
    if (ccl6.equals(ccl7)) {
        pass = false;
        sb.append("UnEqual Test setNoStore failed." + newline);
    }
    if (ccl6.hashCode() == ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setNoStore failed." + newline);
    }
    ccl7.setNoStore(true);
    if (!ccl6.equals(ccl7)) {
        pass = false;
        sb.append("Equal Test setNoStore failed." + newline);
    }
    if (ccl6.hashCode() != ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode Equal Test setNoStore failed." + newline);
    }
    ccl6.setNoCache(true);
    ccl7.setNoCache(false);
    if (ccl6.equals(ccl7)) {
        pass = false;
        sb.append("UnEqual Test setNoCache failed." + newline);
    }
    if (ccl6.hashCode() == ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setNoCache failed." + newline);
    }
    ccl7.setNoCache(true);
    if (!ccl6.equals(ccl7)) {
        pass = false;
        sb.append("Equal Test setNoCache failed." + newline);
    }
    if (ccl6.hashCode() != ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode Equal Test setNoCache failed." + newline);
    }
    ccl6.setMustRevalidate(true);
    ccl7.setMustRevalidate(false);
    if (ccl6.equals(ccl7)) {
        pass = false;
        sb.append("UnEqual Test setMustRevalidate failed." + newline);
    }
    if (ccl6.hashCode() == ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setMustRevalidate failed." + newline);
    }
    ccl7.setMustRevalidate(true);
    if (!ccl6.equals(ccl7)) {
        pass = false;
        sb.append("Equal Test setMustRevalidate failed." + newline);
    }
    if (ccl6.hashCode() != ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode Equal Test setMustRevalidate failed." + newline);
    }
    ccl6.setSMaxAge(-1);
    ccl7.setSMaxAge(200);
    if (ccl6.equals(ccl7)) {
        pass = false;
        sb.append("UnEqual Test setSMaxAge failed." + newline);
    }
    if (ccl6.hashCode() == ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setSMaxAge failed." + newline);
    }
    ccl7.setSMaxAge(-1);
    if (!ccl6.equals(ccl7)) {
        pass = false;
        sb.append("Equal Test setSMaxAge failed." + newline);
    }
    if (ccl6.hashCode() != ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setSMaxAge failed." + newline);
    }
    ccl6.setMaxAge(-1);
    ccl7.setMaxAge(200);
    if (ccl6.equals(ccl7)) {
        pass = false;
        sb.append("UnEqual Test setMaxAge failed." + newline);
    }
    if (ccl6.hashCode() == ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setMaxAge failed." + newline);
    }
    ccl7.setMaxAge(-1);
    if (!ccl6.equals(ccl7)) {
        pass = false;
        sb.append("Equal Test setMaxAge failed." + newline);
    }
    if (ccl6.hashCode() != ccl7.hashCode()) {
        pass = false;
        sb.append("HashCode UnEqual Test setMaxAge failed." + newline);
    }
    assertTrue(pass, "At least one assertion failed: " + sb);
}
Also used : CacheControl(jakarta.ws.rs.core.CacheControl) Test(org.junit.jupiter.api.Test)

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