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

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


   {
      seq.bindAction(0, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new InvokeGetResponse(response.createActionURL().toString());
         }
      });
      seq.bindAction(1, UTP3.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
View Full Code Here


   {
      seq.bindAction(0, UTP7.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new InvokeGetResponse(response.createActionURL().toString());
         }
      });

      seq.bindAction(1, UTP7.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws ReadOnlyException, IOException
         {
            // Get prefs
            PortletPreferences prefs = request.getPreferences();

            // Test the initial value is ok
            assertEquals("single_pref_value", prefs.getValue("single_pref", "other"));
            assertEquals(new String[]{"multi_pref_value_1", "multi_pref_value_2"},
               prefs.getValues("multi_pref", new String[]{"other"}));

            // Set the value to something else
            prefs.setValue("single_pref", "new_single_pref");
            prefs.setValues("multi_pref", new String[]{"new_multi_pref_value_1", "new_multi_pref_value_2"});

            // Trigger store
            try
            {
               prefs.store();
            }
            catch (ValidatorException e)
            {
               // Expected
               assertEquals("message", e.getMessage());
               assertFalse(e.getFailedKeys().hasMoreElements());
            }
         }
      });

      seq.bindAction(1, UTP7.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new InvokeGetResponse(response.createActionURL().toString());
         }
      });

      seq.bindAction(2, UTP7.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
View Full Code Here

            catch (IllegalArgumentException ignore)
            {
            }
            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
View Full Code Here

            PortletURL url = response.createRenderURL();
            url.setParameter("testParamOne", "testValue1");
            url.setParameter("testParameterTwo", "testValue2");


            return new InvokeGetResponse(url.toString());
         }
      });

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            response.setContentType("text/html");
            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().
               getRequestDispatcher("/actionURL.jsp");

            PortletURL pu1 = response.createActionURL();
           
            pu1.setWindowState(WindowState.MAXIMIZED);
            pu1.setPortletMode(PortletMode.EDIT);
            pu1.setSecure(true);
            pu1.setParameter("javax.portlet.action", "testAction");

            // Params from previos request
            pu1.setParameter("testParamOne", "testValue1");
            pu1.setParameter("testParameterTwo", "testValue2");

            PortletURL pu2 = response.createActionURL();
            pu2.setSecure(false);
            pu2.setParameter("javax.portlet.action", "testAction");

            pu2.setParameter("testParam", new String[] {"testParamValue", "testParamValue2"});
            pu2.setParameter("secondParam", "testParamValue");
            pu2.setProperty("testProperty", "testPropValue");
            pu2.setProperty("testProperty", "testPropValue2");
            pu2.setProperty("secondProperty", "testPropValue");

            StringWriter sw = new StringWriter();

            // Create session
            request.getPortletSession();

            // escapeXml=true
            pu1.write(sw, true);
            String url1 = response.encodeURL(sw.toString());

            sw = new StringWriter();
           
            // escapeXml=false
            pu2.write(sw, false);
            String url2 = response.encodeURL(sw.toString());
            sw.flush();


            expectedResults = new String[]{ url1, url1, url2};

            include(dispatcher, request, response);


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

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

      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletURL url = response.createActionURL();
            return new InvokeGetResponse(url.toString());
         }
      });

      seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
View Full Code Here

   {
      seq.bindAction(0, UTP6.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(1, UTP6.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(PortletRequest.ACTION_PHASE, request.getAttribute(PortletRequest.LIFECYCLE_PHASE));

            //
            response.setEvent("Event", null);
         }
      });
      seq.bindAction(1, UTP6.EVENT_JOIN_POINT, new PortletEventTestAction()
      {
         protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(PortletRequest.EVENT_PHASE, request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
         }
      });
      seq.bindAction(1, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(PortletRequest.RENDER_PHASE, request.getAttribute(PortletRequest.LIFECYCLE_PHASE));

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

      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletURL url = response.createActionURL();
            return new InvokeGetResponse(url.toString());
         }
      });

      seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
View Full Code Here

   {
      seq.bindAction(0, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new InvokeGetResponse(response.createActionURL().toString());
         }
      });

      seq.bindAction(1, UTP5.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
View Full Code Here

      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletURL url = response.createActionURL();
            return new InvokeGetResponse(url.toString());
         }
      });

      seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletModeException, IOException
         {
            response.setPortletMode(PortletMode.VIEW);
            try
            {
               response.sendRedirect(request.getContextPath());
               fail();
            }
            catch (IllegalStateException e)
            {
               //expected
            }
         }
      });

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletURL url = response.createActionURL();
            return new InvokeGetResponse(url.toString());
         }
      });

      seq.bindAction(2, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws IOException, WindowStateException
         {
            response.setWindowState(WindowState.NORMAL);
            try
            {
               response.sendRedirect(request.getContextPath());
               fail();
            }
            catch (IllegalStateException e)
            {
               //expected
            }
         }
      });

      seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletURL url = response.createActionURL();
            return new InvokeGetResponse(url.toString());
         }
      });

      seq.bindAction(3, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws IOException
         {
            response.setRenderParameter("key", "value");
            try
            {
               response.sendRedirect(request.getContextPath());
               fail();
            }
            catch (IllegalStateException e)
            {
               //expected
            }
         }
      });

      seq.bindAction(3, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletURL url = response.createActionURL();
            return new InvokeGetResponse(url.toString());
         }
      });

      seq.bindAction(4, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
View Full Code Here

   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new InvokeGetResponse(response.createActionURL().toString());
         }
      });
      seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
         {
            response.setRenderParameter("foo", "foo");
         }
      });
      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            String foo = request.getParameter("foo");
            assertEquals("foo", foo);
            renderCount++;
            PortletURL url = response.createActionURL();
            url.setParameter("foo", "bar");
            return new InvokeGetResponse(url.toString());
         }
      });
      seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
View Full Code Here

TOP

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

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.