use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.
the class CachingStAXPipelineComponentTest method testCacheHit.
@Test
public void testCacheHit() {
final MockHttpServletRequest mockReq = new MockHttpServletRequest();
final MockHttpServletResponse mockRes = new MockHttpServletResponse();
final CacheKey cacheKey = CacheKey.build("testCacheKey");
final CachedEventReader<XMLEvent> eventReader = new CachedEventReader<XMLEvent>(Collections.EMPTY_LIST, Collections.EMPTY_MAP);
final Element cacheElement = new Element(cacheKey, eventReader);
final Ehcache cache = createMock(Ehcache.class);
final StAXPipelineComponent targetComponent = createMock(StAXPipelineComponent.class);
final ResourcesElementsProvider elementsProvider = createMock(ResourcesElementsProvider.class);
expect(elementsProvider.getDefaultIncludedType()).andReturn(Included.AGGREGATED);
expect(targetComponent.getCacheKey(mockReq, mockRes)).andReturn(cacheKey);
expect(cache.get(cacheKey)).andReturn(cacheElement);
replay(cache, targetComponent, elementsProvider);
final CachingStAXPipelineComponent cachingComponent = new CachingStAXPipelineComponent();
cachingComponent.setCache(cache);
cachingComponent.setWrappedComponent(targetComponent);
cachingComponent.setResourcesElementsProvider(elementsProvider);
final PipelineEventReader<XMLEventReader, XMLEvent> actualEventReader = cachingComponent.getEventReader(mockReq, mockRes);
Assert.assertNotNull(actualEventReader);
Assert.assertNotNull(actualEventReader.getEventReader());
Assert.assertFalse(actualEventReader.getEventReader().hasNext());
verify(cache, targetComponent, elementsProvider);
}
use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.
the class LayoutCachingService method cacheLayout.
@Override
public void cacheLayout(IPerson owner, IUserProfile profile, DistributedUserLayout layout) {
final CacheKey cacheKey = this.getCacheKey(owner, profile);
this.layoutCache.put(new Element(cacheKey, layout));
}
use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.
the class LayoutCachingService method removeCachedLayout.
@Override
public void removeCachedLayout(IPerson owner, IUserProfile profile) {
final CacheKey cacheKey = this.getCacheKey(owner, profile);
this.layoutCache.remove(cacheKey);
}
use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.
the class StAXAttributeIncorporationComponent method getCacheKey.
/* (non-Javadoc)
* @see org.apereo.portal.rendering.PipelineComponent#getCacheKey(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
final CacheKey parentKey = this.wrappedComponent.getCacheKey(request, response);
final CacheKey attributeKey = this.attributeSource.getCacheKey(request, response);
return CacheKey.build(this.beanName, parentKey, attributeKey);
}
use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.
the class XSLTComponent method getCacheKey.
@Override
public CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
final CacheKey parentCacheKey = this.wrappedComponent.getCacheKey(request, response);
final CacheKey transformerKey;
if (transformerSource != null) {
transformerKey = this.transformerSource.getCacheKey(request, response);
} else {
transformerKey = null;
}
final CacheKey transformerConfigurationKey;
if (this.xsltParameterSource != null) {
transformerConfigurationKey = this.xsltParameterSource.getCacheKey(request, response);
} else {
transformerConfigurationKey = null;
}
return CacheKey.build(this.beanName, parentCacheKey, transformerKey, transformerConfigurationKey);
}
Aggregations