Java 类javax.portlet.filter.RenderResponseWrapper 实例源码

项目:portals-pluto    文件:AddlFilterTests_SPEC2_20_Filter.java   
@Override
public void doFilter(RenderRequest portletReq, RenderResponse portletResp, FilterChain chain)
    throws IOException, PortletException {
  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);
  JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();

  /* TestCase: V2AddlFilterTests_SPEC2_20_Render_filterWrapper6 */
  /* Details: "An RENDER_PHASE filter can wrap the RenderResponse */
  /* object with a custom wrapper" */
  RenderResponseWrapper renderResp = new RenderResponseWrapper(portletResp);
  PrintWriter writer = renderResp.getWriter();
  TestResult tr12 = tcd.getTestResultFailed(V2ADDLFILTERTESTS_SPEC2_20_RENDER_FILTERWRAPPER6);
  tr12.setTcSuccess(true);
  tr12.writeTo(writer);

  // Create result objects for the tests

  /* TestCase: V2AddlFilterTests_SPEC2_20_Render_filterWrapper5 */
  /* Details: "An RENDER_PHASE filter can wrap the RenderRequest object */
  /* with a custom wrapper" */
  TestResult tr11 = tcd.getTestResultFailed(V2ADDLFILTERTESTS_SPEC2_20_RENDER_FILTERWRAPPER5);
  RenderRequestWrapper renderReq = new RenderRequestWrapper(portletReq);
  if (renderReq.getParameter("tr11") != null && renderReq.getParameter("tr11").equals("true")) {
    tr11.setTcSuccess(true);
  } else {
    tr11.appendTcDetail("Render Parameter tr11 is not found in the wrapper");
  }
  tr11.writeTo(writer);

  /* TestCase: V2AddlFilterTests_SPEC2_20_Render_filter3 */
  /* Details: "If the filter declaration specifies the */
  /* <lifecycle> tag value RENDER_PHASE, the */
  /* RenderFilter.doFilter method is called" */
  TestResult tr13 = tcd.getTestResultFailed(V2ADDLFILTERTESTS_SPEC2_20_RENDER_FILTER3);
  tr13.setTcSuccess(true);
  tr13.writeTo(writer);

  chain.doFilter(portletReq, portletResp);
}