use of org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheKey in project scout.rt by eclipse.
the class HttpCacheControlTest method testCheckAndSet_DisableCaching.
@Test
public void testCheckAndSet_DisableCaching() throws Exception {
Mockito.when(req.getPathInfo()).thenReturn("/");
BinaryResource res = BinaryResources.create().withFilename("a.html").withContent("<html></html>".getBytes("UTF-8")).withCachingAllowed(false).build();
HttpCacheObject obj = new HttpCacheObject(new HttpCacheKey("/"), res);
boolean b = cc.checkAndSetCacheHeaders(req, resp, obj);
Assert.assertFalse(b);
Mockito.verify(req, ANY_TIMES).getPathInfo();
Mockito.verify(req, ANY_TIMES).getAttribute("javax.servlet.forward.path_info");
Mockito.verify(resp, ONCE).setHeader(HttpCacheControl.CACHE_CONTROL, "private, no-store, no-cache, max-age=0");
}
use of org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheKey in project scout.rt by eclipse.
the class HttpCacheKeyTest method testAttributeWithNullValue.
@Test
public void testAttributeWithNullValue() throws Exception {
Map<String, String> atts = Collections.singletonMap("a", (String) null);
HttpCacheKey key = new HttpCacheKey("/", atts);
Assert.assertNull(key.getAttribute(null));
Assert.assertNull(key.getAttribute("a"));
Assert.assertEquals("/".hashCode() + atts.hashCode(), key.hashCode());
}
use of org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheKey in project scout.rt by eclipse.
the class HttpCacheKeyTest method testAttributeWithNullKey.
@Test
public void testAttributeWithNullKey() throws Exception {
Map<String, String> atts = Collections.singletonMap((String) null, "v");
HttpCacheKey key = new HttpCacheKey("/", atts);
Assert.assertEquals("v", key.getAttribute(null));
Assert.assertNull(key.getAttribute("a"));
Assert.assertEquals("/".hashCode() + atts.hashCode(), key.hashCode());
}
use of org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheKey in project scout.rt by eclipse.
the class HttpCacheKeyTest method testNoAttributes.
@Test
public void testNoAttributes() throws Exception {
HttpCacheKey key = new HttpCacheKey("/");
Assert.assertNull(key.getAttribute("a"));
}
use of org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheKey in project scout.rt by eclipse.
the class HttpCacheKeyTest method testAttribute.
@Test
public void testAttribute() throws Exception {
Map<String, String> atts = Collections.singletonMap("a", "v");
HttpCacheKey key = new HttpCacheKey("/", atts);
Assert.assertNull(key.getAttribute(null));
Assert.assertEquals("v", key.getAttribute("a"));
Assert.assertNull(key.getAttribute("b"));
Assert.assertEquals("/".hashCode() + atts.hashCode(), key.hashCode());
}
Aggregations