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;
}
}
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);
}
Aggregations