Package org.gatein.pc.test.unit.actions

Examples of org.gatein.pc.test.unit.actions.PortletResourceTestAction


            //
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });
      seq.bindAction(6, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            response.setProperty("Foo", "Bar_resource");
            return new InvokeGetResponse(response.createRenderURL().toString());
View Full Code Here


            //
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });
      seq.bindAction(4, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String> cookieMap = createCookieMap(request);
            assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
View Full Code Here

            //
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });
      seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            response.getWriter();

            //
            response.setContentType("text/html");

            //
            assertNull(response.getContentType());

            //
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });
      seq.bindAction(3, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            response.getPortletOutputStream();
View Full Code Here

            ResourceURL resourceURL = response.createResourceURL();
            resourceURL.setParameter("foo", new String[]{"resource_foo_value1","resource_foo_value2"});
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(2, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedPageParameters = new HashMap<String, String[]>();
            expectedPageParameters.put("foo", new String[]{"resource_foo_value1","resource_foo_value2","render_foo_value1","render_foo_value2"});
            assertParameterMap(expectedPageParameters, request);

            //
            ResourceURL resourceURL = response.createResourceURL();
            resourceURL.setCacheability(ResourceURL.PORTLET);
            resourceURL.setParameter("foo", new String[]{"resource_foo_value3","resource_foo_value4"});
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(3, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedPageParameters = new HashMap<String, String[]>();
            expectedPageParameters.put("foo", new String[]{"resource_foo_value3","resource_foo_value4","render_foo_value1","render_foo_value2"});
View Full Code Here

            Object bar = request.getAttribute("foo");
            assertEquals("bar", bar);
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });
      seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(scopeId, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
            Object bar = request.getAttribute("foo");
            assertEquals("bar", bar);

            //
            ResourceURL url = response.createResourceURL();
            url.setCacheability(ResourceURL.PORTLET);
            return new InvokeGetResponse(url.toString());
         }
      });
      seq.bindAction(3, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(scopeId, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
            Object bar = request.getAttribute("foo");
View Full Code Here

            InvokeGetResponse get = new InvokeGetResponse(response.createResourceURL().toString());
            get.addHeader("Cookie", "foo=foo_value5; bar=bar_value6");
            return get;
         }
      });
      seq.bindAction(3, UTP5.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String> cookieMap = createCookieMap(request);
            assertEquals("foo_value5", cookieMap.get("foo"));
View Full Code Here

            render.addHeader("myheader", "resource-value");
            return render;
         }
      });

      seq.bindAction(3, UTP6.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertHeader(request, "resource-value");
View Full Code Here

           
            //
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });
      seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            PortletRequestDispatcher dispatcher = assertNotNull(((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/file.html"));
            dispatcher.include(request, response);

            //
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });
      seq.bindAction(3, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            String body = new String(context.getResponseBody(), "UTF-8");
View Full Code Here

            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });

      //
      seq.bindAction(1, 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));
            }
         }
      });

      // 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
View Full Code Here

TOP

Related Classes of org.gatein.pc.test.unit.actions.PortletResourceTestAction

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.