Package org.gatein.pc.test.unit.protocol.response

Examples of org.gatein.pc.test.unit.protocol.response.FailureResponse


            //
            return new EndTestResponse();
         }
         default:
            return new FailureResponse(Failure.createAssertionFailure(""));
      }
   }
View Full Code Here


      seq.bindAction(1, UTS2.SERVICE_JOIN_POINT, new ServletServiceTestAction()
      {
         protected Response run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
         {
            return new FailureResponse(Failure.createAssertionFailure("Redirection shouldn't be made"));
         }
      });

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
View Full Code Here

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new FailureResponse(Failure.createAssertionFailure("Render wasn't expected to be called"));
         }
      });
   }
View Full Code Here

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            //if portlet was invoked we will have failure
            return new FailureResponse(Failure.createAssertionFailure("Render wasn't expected"));
         }
      });

      seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
View Full Code Here

               // Now render the full page
               return new InvokeGetResponse(response.createRenderURL().toString());
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }
         }
      });

      // Now make the request to the full page after one second, the goal is to test also an issue whereby the request
      // to the cached content extends the expiration out of the box, as we will wait after that for one second, if that
      // problem occur, then the revalidation would not occur at all
      seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Set cached to false to make test fail later
            cached = false;
            return null;
         }
      });
      seq.bindAction(2, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Trigger a resource so we are sure that the cached portlet will not be part of the whole request
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });

      //
      seq.bindAction(3, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         @Override
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            // Check caching occurred
            Assert.assertTrue(cached);

            // Check it contains the cached content
            byte[] bytes = (byte[])context.getPayload().get("http.response.body");
            String cachedMarkup = new String(bytes, "UTF-8");
            Assert.assertTrue("Was expected " + cachedMarkup + " to contain foocached", cachedMarkup.contains("foocached"));

            // Wait for one second so the content should have just expired
            try
            {
               Thread.sleep(1000);
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }

            //
            return new InvokeGetResponse(response.createRenderURL().toString());
         }
      });

      // Assert we have the etag and revalidate response for two seconds
      seq.bindAction(4, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Check everything is as espected
            Assert.assertEquals("footag", request.getETag());

            // Revalidate markup for two seconds and invoke again
            response.getCacheControl().setUseCachedContent(true);
            response.getCacheControl().setExpirationTime(2);

            //
            return null;
         }
      });
      seq.bindAction(4, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Trigger a resource so we are sure that the cached portlet will not be part of the whole request
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });

      //
      seq.bindAction(5, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         @Override
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            try
            {
               // Wait for one second so the cached content will be aged of 1 second
               Thread.sleep(1000);

               // Now render the full page
               return new InvokeGetResponse(response.createRenderURL().toString());
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }
         }
      });

      //
      seq.bindAction(6, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Set cached to false to make test fail later
            cached = false;
            return null;
         }
      });
      seq.bindAction(6, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Trigger a resource so we are sure that the cached portlet will not be part of the whole request
            // and we can make the 2 seconds pause without messing with the invalid entry we want to revalidate
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });

      //
      seq.bindAction(7, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         @Override
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            // Check caching occurred
            Assert.assertTrue(cached);

            // Check it contains the cached content
            byte[] bytes = (byte[])context.getPayload().get("http.response.body");
            String cachedMarkup = new String(bytes, "UTF-8");
            Assert.assertTrue("Was expected " + cachedMarkup + " to contain foocached", cachedMarkup.contains("foocached"));

            // Wait for one second so the content should have just expired
            try
            {
               Thread.sleep(1000);
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }

            //
            return new InvokeGetResponse(response.createRenderURL().toString());
         }
View Full Code Here

TOP

Related Classes of org.gatein.pc.test.unit.protocol.response.FailureResponse

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.