* @author Marc Hadley
*/
public class CacheControlImplTest {
@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);
}