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

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


         {
            ResourceURL resourceURL = response.createResourceURL();
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals("GET", request.getMethod());
            ResourceURL resourceURL = response.createResourceURL();
            InvokePostResponse post = new InvokePostResponse(resourceURL.toString());
            post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
            post.setBody(new Body.Form());
            return post;
         }
      });
      seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals("POST", request.getMethod());
            return new EndTestResponse();
View Full Code Here


         {
            ResourceURL resourceURL = response.createResourceURL();
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertNull(request.getResourceID());
            ResourceURL resourceURL = response.createResourceURL();
            resourceURL.setResourceID("foo_resource_id");
            return new InvokeGetResponse(resourceURL.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("foo_resource_id", request.getResourceID());
            return new EndTestResponse();
View Full Code Here

            //
            return new InvokeGetResponse(resp.createResourceURL().toString());
         }
      });
      seq.bindAction(2, UTP3.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest req, ResourceResponse resp, PortletTestContext context) throws PortletException, IOException
         {
            assertSame(PropagateDoFilterArgsFilter1.publishedResourceRequest, PropagateDoFilterArgsFilter2.consumedResourceRequest);
            assertSame(PropagateDoFilterArgsFilter1.publishedResourceResponse, PropagateDoFilterArgsFilter2.consumedResourceResponse);
View Full Code Here

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

            //
            return new InvokeGetResponse(url.toString());
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedParameters = Collections.singletonMap("resource", new String[]{"resource_value"});
            assertParameterMap(expectedParameters, request);
            assertParameterMap(expectedParameters, request.getPrivateParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPrivateRenderParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());

            //
            ResourceURL url = response.createResourceURL();

            //
            url.setParameter("resource", new String[]{"resource_value"});
            url.setParameter("resource_form", new String[]{"resource_form_value1"});

            //
            InvokePostResponse post = new InvokePostResponse(url.toString());
            post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
            Body.Form form = new Body.Form();
            form.addParameter("form", new String[]{"form_value"});
            form.addParameter("resource_form", new String[]{"resource_form_value2"});
            post.setBody(form);

            //
            return post;
         }
      });
      seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
            expectedParameters.put("resource", new String[]{"resource_value"});
            expectedParameters.put("resource_form", new String[]{"resource_form_value1", "resource_form_value2"});
            expectedParameters.put("form", new String[]{"form_value"});
            assertParameterMap(expectedParameters, request);
            assertParameterMap(expectedParameters, request.getPrivateParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPrivateRenderParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());

            //
            PortletURL renderURL = response.createRenderURL();
            renderURL.setParameter("render", "render_value");
            renderURL.setParameter("resource_render", "resource_render_value2");
            renderURL.setParameter("form_render", "form_render_value2");
            renderURL.setParameter("resource_form_render", "resource_form_render_value3");

            //
            return new InvokeGetResponse(renderURL.toString());
         }
      });
      seq.bindAction(3, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            ResourceURL url = response.createResourceURL();

            //
            url.setParameter("resource", new String[]{"resource_value"});
            url.setParameter("resource_render", new String[]{"resource_render_value1"});

            //
            return new InvokeGetResponse(url.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[]> expectedParameters = new HashMap<String, String[]>();
            expectedParameters.put("resource", new String[]{"resource_value"});
            expectedParameters.put("resource_render", new String[]{"resource_render_value1","resource_render_value2"});
            expectedParameters.put("render", new String[]{"render_value"});
            expectedParameters.put("form_render", new String[]{"form_render_value2"});
            expectedParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
            Map<String, String[]> expectedPrivateRenderParameters = new HashMap<String, String[]>();
            expectedPrivateRenderParameters.put("render", new String[]{"render_value"});
            expectedPrivateRenderParameters.put("resource_render", new String[]{"resource_render_value2"});
            expectedPrivateRenderParameters.put("form_render", new String[]{"form_render_value2"});
            expectedPrivateRenderParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
            assertParameterMap(expectedParameters, request);
            assertParameterMap(expectedParameters, request.getPrivateParameterMap());
            assertParameterMap(expectedPrivateRenderParameters, request.getPrivateRenderParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());

            //
            ResourceURL url = response.createResourceURL();

            //
            url.setParameter("resource", new String[]{"resource_value"});
            url.setParameter("resource_form", new String[]{"resource_form_value1"});
            url.setParameter("resource_render", new String[]{"resource_render_value1"});
            url.setParameter("resource_form_render", new String[]{"resource_form_render_value1"});

            //
            InvokePostResponse post = new InvokePostResponse(url.toString());
            post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
            Body.Form form = new Body.Form();
            form.addParameter("form", new String[]{"form_value"});
            form.addParameter("resource_form", new String[]{"resource_form_value2"});
            form.addParameter("form_render", new String[]{"form_render_value1"});
            form.addParameter("resource_form_render", new String[]{"resource_form_render_value2"});
            post.setBody(form);

            //
            return post;
         }
      });
      seq.bindAction(5, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
            expectedParameters.put("resource", new String[]{"resource_value"});
            expectedParameters.put("resource_form", new String[]{"resource_form_value1","resource_form_value2"});
            expectedParameters.put("resource_render", new String[]{"resource_render_value1","resource_render_value2"});
            expectedParameters.put("resource_form_render", new String[]{"resource_form_render_value1","resource_form_render_value2","resource_form_render_value3"});
            expectedParameters.put("form", new String[]{"form_value"});
            expectedParameters.put("form_render", new String[]{"form_render_value1","form_render_value2"});
            expectedParameters.put("render", new String[]{"render_value"});
            Map<String, String[]> expectedPrivateRenderParameters = new HashMap<String, String[]>();
            expectedPrivateRenderParameters.put("render", new String[]{"render_value"});
            expectedPrivateRenderParameters.put("resource_render", new String[]{"resource_render_value2"});
            expectedPrivateRenderParameters.put("form_render", new String[]{"form_render_value2"});
            expectedPrivateRenderParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
            assertParameterMap(expectedParameters, request);
            assertParameterMap(expectedParameters, request.getPrivateParameterMap());
            assertParameterMap(expectedPrivateRenderParameters, request.getPrivateRenderParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());

            //
            PortletURL renderURL = response.createRenderURL();
            renderURL.setParameter("render", "render_value");
            renderURL.setParameter("resource_render", "resource_render_value2");
            renderURL.setParameter("form_render", "form_render_value2");
            renderURL.setParameter("resource_form_render", "resource_form_render_value3");
            renderURL.setParameter("public", "public_value");
            renderURL.setParameter("resource_public", "resource_public_value2");
            renderURL.setParameter("form_public", "form_public_value2");
            renderURL.setParameter("resource_form_public", "resource_form_public_value3");

            //
            return new InvokeGetResponse(renderURL.toString());
         }
      });
      seq.bindAction(6, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            //
            ResourceURL url = response.createResourceURL();

            //
            url.setParameter("resource", new String[]{"resource_value"});
            url.setParameter("resource_form", new String[]{"resource_form_value1"});
            url.setParameter("resource_render", new String[]{"resource_render_value1"});
            url.setParameter("resource_form_render", new String[]{"resource_form_render_value1"});
            url.setParameter("resource_public", new String[]{"resource_public_value1"});
            url.setParameter("resource_form_public", new String[]{"resource_form_public_value1"});

            //
            InvokePostResponse post = new InvokePostResponse(url.toString());
            post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
            Body.Form form = new Body.Form();
            form.addParameter("form", new String[]{"form_value"});
            form.addParameter("resource_form", new String[]{"resource_form_value2"});
            form.addParameter("form_render", new String[]{"form_render_value1"});
            form.addParameter("resource_form_render", new String[]{"resource_form_render_value2"});
            form.addParameter("form_public", new String[]{"form_public_value1"});
            form.addParameter("resource_form_public", new String[]{"resource_form_public_value2"});
            post.setBody(form);

            //
            return post;
         }
      });
      seq.bindAction(7, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
            expectedParameters.put("resource", new String[]{"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 IOException, PortletException
         {
            response.setContentType("text/html");
            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/defineObjects.jsp");
View Full Code Here

            resourceURL.setParameter("foo", "bar");
            String s = resourceURL.toString();
            return new InvokeGetResponse(s);
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals("blah", request.getResourceID());
            assertEquals("bar", request.getParameter("foo"));
View Full Code Here

            resourceURL.setCacheability(ResourceURL.PORTLET);
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(ResourceURL.PORTLET, request.getCacheability());

            //
            try
            {
               response.createActionURL();
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }

            //
            try
            {
               response.createRenderURL();
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }

            //
            ResourceURL resourceURL = response.createResourceURL();
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());

            //
            try
            {
               resourceURL.setCacheability(ResourceURL.PAGE);
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());

            //
            resourceURL.setCacheability(ResourceURL.PORTLET);
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());

            //
            return new InvokeGetResponse(resourceURL.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(ResourceURL.PORTLET, request.getCacheability());
            ResourceURL resourceURL = response.createResourceURL();
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
            resourceURL.setCacheability(ResourceURL.FULL);
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
            return new InvokeGetResponse(resourceURL.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(ResourceURL.FULL, request.getCacheability());

            //
            try
            {
               response.createActionURL();
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }

            //
            try
            {
               response.createRenderURL();
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }

            //
            ResourceURL resourceURL = response.createResourceURL();
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());

            //
            try
            {
               resourceURL.setCacheability(ResourceURL.PORTLET);
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());

            //
            try
            {
               resourceURL.setCacheability(ResourceURL.PAGE);
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());

            //
            resourceURL.setCacheability(ResourceURL.FULL);
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());

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

            //
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });
      seq.bindAction(2, UTP6.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(PortletRequest.RESOURCE_PHASE, request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
View Full Code Here

            assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.RENDER));
            assertFalse((TraceFilter.isActive("PartialWildcardFilter", TraceFilter.RENDER)));
            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
         {
            assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.RESOURCE));
            assertFalse((TraceFilter.isActive("PartialWildcardFilter", TraceFilter.RESOURCE)));
            return new InvokeGetResponse(response.createRenderURL().toString());
         }
      });
      seq.bindAction(3, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            return new InvokeGetResponse(response.createActionURL().toString());
         }
      });
      seq.bindAction(4, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.ACTION));
            assertTrue(TraceFilter.isActive("PartialWildcardFilter", TraceFilter.ACTION));
            response.setEvent("Event", null);
         }
      });
      seq.bindAction(4, UTP2.EVENT_JOIN_POINT, new PortletEventTestAction()
      {
         protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.EVENT));
            assertTrue(TraceFilter.isActive("PartialWildcardFilter", TraceFilter.EVENT));
         }
      });
      seq.bindAction(4, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.RENDER));
            assertTrue(TraceFilter.isActive("PartialWildcardFilter", TraceFilter.RENDER));
            return new InvokeGetResponse(response.createResourceURL().toString());
         }
      });
      seq.bindAction(5, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.RESOURCE));
            assertTrue(TraceFilter.isActive("PartialWildcardFilter", TraceFilter.RESOURCE));
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.