Java Code Examples for javax.portlet.RenderResponse#getCacheControl()

The following examples show how to use javax.portlet.RenderResponse#getCacheControl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnvironmentTests_CacheControl_ApiResource2.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);

  PrintWriter writer = portletResp.getWriter();

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  // Create result objects for the tests

  CacheControl chc = portletResp.getCacheControl();

  /* TestCase: V2EnvironmentTests_CacheControl_ApiResource_getExpirationTime3 */
  /* Details: "Method getExpirationTime(): Returns 0 if the expiration */
  /* time has not been set and no default is set in the deployment */
  /* descriptor" */
  TestResult tr2 =
      tcd.getTestResultFailed(V2ENVIRONMENTTESTS_CACHECONTROL_APIRESOURCE_GETEXPIRATIONTIME3);
  int getExpTime = chc.getExpirationTime();
  if (getExpTime == 0) {
    tr2.setTcSuccess(true);
  } else {
    tr2.appendTcDetail("The getExpirationTime did not match the Specified Time :" + getExpTime);
  }
  tr2.writeTo(writer);

  /* TestCase: V2EnvironmentTests_CacheControl_ApiResource_isPublicScope5 */
  /* Details: "Method isPublicScope(): Returns false if the caching */
  /* scope has not been set with the setPublicScope method and has not */
  /* been set in the deployment descriptor" */
  TestResult tr9 =
      tcd.getTestResultFailed(V2ENVIRONMENTTESTS_CACHECONTROL_APIRESOURCE_ISPUBLICSCOPE5);
  if (!chc.isPublicScope()) {
    tr9.setTcSuccess(true);
  } else {
    tr9.appendTcDetail("Failed because isPublicScope() returned true");
  }
  tr9.writeTo(writer);

  /* TestCase: V2EnvironmentTests_CacheControl_ApiResource_useCachedContent3 */
  /* Details: "Method useCachedContent(): Returns false if the use */
  /* cached content indicator has not been set" */
  TestResult tr19 =
      tcd.getTestResultFailed(V2ENVIRONMENTTESTS_CACHECONTROL_APIRESOURCE_USECACHEDCONTENT3);
  if (!chc.useCachedContent()) {
    tr19.setTcSuccess(true);
  }
  tr19.writeTo(writer);

}
 
Example 2
Source File: EnvironmentTests_CacheControl_ApiRender2.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);

  PrintWriter writer = portletResp.getWriter();

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  // Create result objects for the tests

  CacheControl chc = portletResp.getCacheControl();

  /* TestCase: V2EnvironmentTests_CacheControl_ApiRender_getExpirationTime3 */
  /* Details: "Method getExpirationTime(): Returns 0 if the expiration */
  /* time has not been set and no default is set in the deployment */
  /* descriptor" */
  TestResult tr2 =
      tcd.getTestResultFailed(V2ENVIRONMENTTESTS_CACHECONTROL_APIRENDER_GETEXPIRATIONTIME3);
  int getExpTime = chc.getExpirationTime();
  if (getExpTime == 0) {
    tr2.setTcSuccess(true);
  } else {
    tr2.appendTcDetail("The getExpirationTime did not match the Specified Time :" + getExpTime);
  }
  tr2.writeTo(writer);

  /* TestCase: V2EnvironmentTests_CacheControl_ApiRender_isPublicScope5 */
  /* Details: "Method isPublicScope(): Returns false if the caching */
  /* scope has not been set with the setPublicScope method and has not */
  /* been set in the deployment descriptor" */
  TestResult tr9 =
      tcd.getTestResultFailed(V2ENVIRONMENTTESTS_CACHECONTROL_APIRENDER_ISPUBLICSCOPE5);
  if (!chc.isPublicScope()) {
    tr9.setTcSuccess(true);
  } else {
    tr9.appendTcDetail("Failed because isPublicScope() returned true");
  }
  tr9.writeTo(writer);

  /* TestCase: V2EnvironmentTests_CacheControl_ApiRender_useCachedContent3 */
  /* Details: "Method useCachedContent(): Returns false if the use */
  /* cached content indicator has not been set" */
  TestResult tr19 =
      tcd.getTestResultFailed(V2ENVIRONMENTTESTS_CACHECONTROL_APIRENDER_USECACHEDCONTENT3);
  if (!chc.useCachedContent()) {
    tr19.setTcSuccess(true);
  }
  tr19.writeTo(writer);

}