Search in sources :

Example 1 with CacheControlProvider

use of org.glassfish.jersey.message.internal.CacheControlProvider in project jersey by jersey.

the class CacheControlImplTest method checkRoundTrip.

private void checkRoundTrip(String s) {
    CacheControlProvider p = new CacheControlProvider();
    CacheControl cc1 = p.fromString(s);
    CacheControl cc2 = p.fromString(cc1.toString());
    cc2.toString();
    cc1.equals(cc2);
    try {
        assertEquals(cc1, cc2);
    } catch (RuntimeException ex) {
        throw ex;
    }
}
Also used : CacheControl(javax.ws.rs.core.CacheControl) CacheControlProvider(org.glassfish.jersey.message.internal.CacheControlProvider)

Example 2 with CacheControlProvider

use of org.glassfish.jersey.message.internal.CacheControlProvider in project jersey by jersey.

the class CacheControlImplTest method testToString.

@Test
public void testToString() {
    CacheControlProvider p = new CacheControlProvider();
    CacheControl instance = new CacheControl();
    instance.setNoCache(true);
    String expResult = "no-cache, no-transform";
    String result = p.toString(instance);
    assertEquals(expResult, result);
    instance.setNoStore(true);
    expResult = "no-cache, no-store, no-transform";
    result = p.toString(instance);
    assertEquals(expResult, result);
    instance.setPrivate(true);
    expResult = "private, no-cache, no-store, no-transform";
    result = p.toString(instance);
    assertEquals(expResult, result);
    instance.getPrivateFields().add("Fred");
    expResult = "private=\"Fred\", no-cache, no-store, no-transform";
    result = p.toString(instance);
    assertEquals(expResult, result);
    instance.getPrivateFields().add("Bob");
    expResult = "private=\"Fred, Bob\", no-cache, no-store, no-transform";
    result = p.toString(instance);
    assertEquals(expResult, result);
    instance = new CacheControl();
    instance.getCacheExtension().put("key1", "value1");
    expResult = "no-transform, key1=value1";
    result = p.toString(instance);
    assertEquals(expResult, result);
    instance.getCacheExtension().put("key1", "value1 with spaces");
    expResult = "no-transform, key1=\"value1 with spaces\"";
    result = p.toString(instance);
    assertEquals(expResult, result);
    instance.setNoStore(true);
    expResult = "no-store, no-transform, key1=\"value1 with spaces\"";
    result = p.toString(instance);
    assertEquals(expResult, result);
    instance = new CacheControl();
    instance.getCacheExtension().put("key1", null);
    expResult = "no-transform, key1";
    result = p.toString(instance);
    assertEquals(expResult, result);
}
Also used : CacheControl(javax.ws.rs.core.CacheControl) CacheControlProvider(org.glassfish.jersey.message.internal.CacheControlProvider) Test(org.junit.Test)

Aggregations

CacheControl (javax.ws.rs.core.CacheControl)2 CacheControlProvider (org.glassfish.jersey.message.internal.CacheControlProvider)2 Test (org.junit.Test)1