Package javax.portlet

Examples of javax.portlet.CacheControl


  @Test
  public void doRenderMarkupCachedContentValidationMethodExpiredTest() throws PortletException, IOException, PortletContainerException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    TestingCacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult> cacheState = new TestingCacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult>();
        CacheControl cacheControl = cacheState.getCacheControl();
    // by setting useCachedContent to true, we are saying even though content is expired, replay it anyways (since etag is still valid)
    cacheControl.setUseCachedContent(true);
    cacheControl.setETag("123456");
    cacheControl.setExpirationTime(300);

       
        final PortletRenderResult portletResult = new PortletRenderResult("title", null, 0, 100);
        final String output = "<p>Some content</p>";
        CachedPortletData<PortletRenderResult> cachedPortletData = new CachedPortletData<PortletRenderResult>(
                portletResult, output, null, null, false, cacheControl.getETag(), 1);
        cacheState.setCachedPortletData(cachedPortletData);
   
        final long expTime = cachedPortletData.getExpirationTime();
       
    setupPortletExecutionMocks(request);
View Full Code Here


  @Test
  public void testDoServeResourceNoCache() throws PortletException, IOException, PortletContainerException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    TestingCacheState<CachedPortletResourceData<Long>, Long> cacheState = new TestingCacheState<CachedPortletResourceData<Long>, Long>();
        CacheControl cacheControl = cacheState.getCacheControl();
    cacheControl.setUseCachedContent(false);
    cacheControl.setExpirationTime(0);
   
    setupPortletExecutionMocks(request);
   

    when(portletCacheControlService.getPortletResourceState(request, portletWindowId)).thenReturn(cacheState);
View Full Code Here

  public void doServeResourceCapture() throws PortletException, IOException, PortletContainerException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    response.setContentType("application/octet-stream");
    TestingCacheState<CachedPortletResourceData<Long>, Long> cacheState = new TestingCacheState<CachedPortletResourceData<Long>, Long>();
        CacheControl cacheControl = cacheState.getCacheControl();
    cacheControl.setUseCachedContent(false);
    cacheControl.setExpirationTime(300);
   
    setupPortletExecutionMocks(request);

    when(portletCacheControlService.getPortletResourceState(request, portletWindowId)).thenReturn(cacheState);
        when(portletCacheControlService.shouldOutputBeCached(cacheControl)).thenReturn(true);
View Full Code Here

  public void doServeResourceMarkupCaptureNegativeExpirationTime() throws PortletException, IOException, PortletContainerException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    response.setContentType("application/octet-stream");
    TestingCacheState<CachedPortletResourceData<Long>, Long> cacheState = new TestingCacheState<CachedPortletResourceData<Long>, Long>();
        CacheControl cacheControl = cacheState.getCacheControl();
    cacheControl.setUseCachedContent(false);
    cacheControl.setExpirationTime(-1);
   
    setupPortletExecutionMocks(request);
   
    when(portletCacheControlService.getPortletResourceState(request, portletWindowId)).thenReturn(cacheState);
    when(portletCacheControlService.shouldOutputBeCached(cacheControl)).thenReturn(true);
View Full Code Here

  @Test
  public void doServeResourceCachedContentExpirationMethodTest() throws PortletException, IOException, PortletContainerException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    TestingCacheState<CachedPortletResourceData<Long>, Long> cacheState = new TestingCacheState<CachedPortletResourceData<Long>, Long>();
        CacheControl cacheControl = cacheState.getCacheControl();
    cacheControl.setUseCachedContent(true);
    cacheControl.setExpirationTime(300);
   
        final String output = "{ \"hello\": \"world\" }";
        final CachedPortletData<Long> cachedPortletData = new CachedPortletData<Long>(
                1000l, output, null, "application/json", false, cacheControl.getETag(), cacheControl.getExpirationTime());
        final CachedPortletResourceData<Long> cachedPortletResourceData = new CachedPortletResourceData<Long>(
                cachedPortletData, Collections.EMPTY_MAP, null, null, null, null);
        final long expirationTime = System.currentTimeMillis() - 60000;
        cachedPortletData.updateExpirationTime(50000);
        cacheState.setCachedPortletData(cachedPortletResourceData);
View Full Code Here

  @Test
  public void doServeResourceCachedContentValidationMethodTest() throws PortletException, IOException, PortletContainerException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    TestingCacheState<CachedPortletResourceData<Long>, Long> cacheState = new TestingCacheState<CachedPortletResourceData<Long>, Long>();
        CacheControl cacheControl = cacheState.getCacheControl();
    cacheControl.setUseCachedContent(true);
    cacheControl.setExpirationTime(300);
    cacheControl.setETag("123456");
       
        final String output = "{ \"hello\": \"world\" }";
        final CachedPortletData<Long> cachedPortletData = new CachedPortletData<Long>(
                1000l, output, null, "application/json", false, cacheControl.getETag(), cacheControl.getExpirationTime());
        final CachedPortletResourceData<Long> cachedPortletResourceData = new CachedPortletResourceData<Long>(
                cachedPortletData, Collections.EMPTY_MAP, null, null, null, null);
        cacheState.setCachedPortletData(cachedPortletResourceData);
   
    setupPortletExecutionMocks(request);
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader("If-None-Match", "123456");
    MockHttpServletResponse response = new MockHttpServletResponse();
    TestingCacheState<CachedPortletResourceData<Long>, Long> cacheState = new TestingCacheState<CachedPortletResourceData<Long>, Long>();
    cacheState.setUseBrowserData(true);
        CacheControl cacheControl = cacheState.getCacheControl();
    cacheControl.setUseCachedContent(true);
    cacheControl.setExpirationTime(300);
    cacheControl.setETag("123456");
       
        final String output = "{ \"hello\": \"world\" }";
        final CachedPortletData<Long> cachedPortletData = new CachedPortletData<Long>(
                1000l, output, null, "application/json", false, cacheControl.getETag(), cacheControl.getExpirationTime());
        final CachedPortletResourceData<Long> cachedPortletResourceData = new CachedPortletResourceData<Long>(
                cachedPortletData, Collections.EMPTY_MAP, null, null, null, null);
        cacheState.setCachedPortletData(cachedPortletResourceData);
   
    setupPortletExecutionMocks(request);
View Full Code Here

        MockHttpServletRequest request = new MockHttpServletRequest();
        request.addHeader("If-None-Match", "123456");
        MockHttpServletResponse response = new MockHttpServletResponse();
        TestingCacheState<CachedPortletResourceData<Long>, Long> cacheState = new TestingCacheState<CachedPortletResourceData<Long>, Long>();
        cacheState.setBrowserSetEtag(true);
        CacheControl cacheControl = cacheState.getCacheControl();
        cacheControl.setUseCachedContent(true);
        cacheControl.setExpirationTime(300);
        cacheControl.setETag("123456");
       
        final String output = "{ \"hello\": \"world\" }";
        final CachedPortletData<Long> cachedPortletData = new CachedPortletData<Long>(
                1000l, output, null, "application/json", false, cacheControl.getETag(), cacheControl.getExpirationTime());
        final CachedPortletResourceData<Long> cachedPortletResourceData = new CachedPortletResourceData<Long>(
                cachedPortletData, Collections.EMPTY_MAP, null, null, null, null);
        cacheState.setCachedPortletData(cachedPortletResourceData);
       
        setupPortletExecutionMocks(request);
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader("If-None-Match", "123456");
    MockHttpServletResponse response = new MockHttpServletResponse();
    TestingCacheState<CachedPortletResourceData<Long>, Long> cacheState = new TestingCacheState<CachedPortletResourceData<Long>, Long>();
    cacheState.setUseCachedData(true);
        CacheControl cacheControl = cacheState.getCacheControl();
    cacheControl.setUseCachedContent(true);
    cacheControl.setExpirationTime(300);
    cacheControl.setETag("123457");
       
        final String output = "{ \"hello\": \"world\" }";
        final CachedPortletData<Long> cachedPortletData = new CachedPortletData<Long>(
                1000l, output, null, "application/json", false, cacheControl.getETag(), cacheControl.getExpirationTime());
        final CachedPortletResourceData<Long> cachedPortletResourceData = new CachedPortletResourceData<Long>(
                cachedPortletData, Collections.EMPTY_MAP, null, null, null, null);
        cacheState.setCachedPortletData(cachedPortletResourceData);
   
    setupPortletExecutionMocks(request);
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader("If-None-Match", "123456");
    MockHttpServletResponse response = new MockHttpServletResponse();
    TestingCacheState<CachedPortletResourceData<Long>, Long> cacheState = new TestingCacheState<CachedPortletResourceData<Long>, Long>();
    cacheState.setBrowserSetEtag(true);
        CacheControl cacheControl = cacheState.getCacheControl();
    cacheControl.setUseCachedContent(true);
    cacheControl.setExpirationTime(300);
    cacheControl.setETag("123456");
       
        final String output = "{ \"hello\": \"world\" }";
        final CachedPortletData<Long> cachedPortletData = new CachedPortletData<Long>(
                1000l, output, null, "application/json", false, cacheControl.getETag(), cacheControl.getExpirationTime());
        final CachedPortletResourceData<Long> cachedPortletResourceData = new CachedPortletResourceData<Long>(
                cachedPortletData, Collections.EMPTY_MAP, null, null, null, null);
        cacheState.setCachedPortletData(cachedPortletResourceData);
   
    setupPortletExecutionMocks(request);
View Full Code Here

TOP

Related Classes of javax.portlet.CacheControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.