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

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


public class ExceptionsOnInit
{
   public ExceptionsOnInit(PortletTestCase seq)
   {
      //PortletExceptionDuringInitPortlet
      seq.bindAction(0, PortletExceptionDuringInitPortlet.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletExceptionDuringInitPortlet.rendered = true;
            return null;
         }
      });

      //RuntimeExceptionDuringInitPortlet
      seq.bindAction(0, RuntimeExceptionDuringInitPortlet.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            RuntimeExceptionDuringInitPortlet.rendered = true;
            return null;
         }
      });

      //UnavailableExceptionDuringInitPortlet
      seq.bindAction(0, UnavailableExceptionDuringInitPortlet.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            UnavailableExceptionDuringInitPortlet.rendered = true;
            return null;
         }
      });

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

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

      seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            //portlets shouldn't render itself
            assertEquals(false, PortletExceptionDuringInitPortlet.rendered);
View Full Code Here


   boolean actionInvoked;

   public InvokeActionFirst(PortletTestCase seq)
   {
      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)
         {
            actionInvoked = true;
         }
      });

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            assertEquals(true, actionInvoked);
            return new EndTestResponse();
View Full Code Here

   boolean actionInvoked;

   public InvokeRenderAfterActionURL(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new InvokeGetResponse(response.createRenderURL().toString());
         }
      });

      seq.bindAction(0, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            //pass action url
            UTP2.holder = response.createActionURL().toString();
            return null;
         }
      });

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            //get portlet b action url and invoke
            assertNotNull(UTP2.holder);
            return new InvokeGetResponse((String)UTP2.holder);
         }
      });

      seq.bindAction(2, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context)
         {
            //mark action phase invokation
            actionInvoked = true;
         }
      });

      seq.bindAction(2, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            //assert that render is after Portlet B action
             assertEquals(true, actionInvoked);
            return null;
         }
      });

      seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            //assert that render is after Portlet B action
            assertEquals(true, actionInvoked);
            //and reinvoke itself
            return new InvokeGetResponse(response.createRenderURL().toString());
         }
      });

      seq.bindAction(3, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new EndTestResponse();
         }
View Full Code Here

         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
         {
            throw new AssertionError();
         }
      });
      seq.bindAction(new JoinPoint(MinimizedStateDontRenderPortlet.NAME, JoinPointType.PORTLET_RENDER), new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            throw new AssertionError();
         }
View Full Code Here

@TestCase({Assertion.JSR168_12})
public class SendRedirectDuringAction
{
   public SendRedirectDuringAction(PortletTestCase seq)
   {
      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, PortletSecurityException, IOException
         {
            String path = request.getContextPath() + "/universalServletA";
            response.sendRedirect(path);
         }
      });

      seq.bindAction(1, UTS1.SERVICE_JOIN_POINT, new ServletServiceTestAction()
      {
         protected Response run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
         {
            return new EndTestResponse();
         }
      });

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

@TestCase({Assertion.JSR168_11})
public class InvokeRenderAfterRenderURL
{
   public InvokeRenderAfterRenderURL(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new InvokeGetResponse(response.createRenderURL().toString());
         }
      });

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

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            //mark that Portlet B was invoked after portlet A render url
            UTP2.holder = Boolean.TRUE;
            return null;
         }
      });

      seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            //assert Portlet B was invoked
            assertEquals(Boolean.TRUE, (Object)UTP2.holder);
View Full Code Here

@TestCase(Assertion.JSR168_61)
public class ContentType
{
   public ContentType(PortletTestCase seq)
   {
      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)
         {
            Enumeration types = request.getResponseContentTypes();

            //assert that first element is retrieved as defined in spec
            assertEquals((String)types.nextElement(), request.getResponseContentType());
         }
      });

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new EndTestResponse();
         }
View Full Code Here

   })
public class HTTPMethod
{
   public HTTPMethod(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            ResourceURL resourceURL = response.createResourceURL();
            return new InvokeGetResponse(resourceURL.toString());
View Full Code Here

   })
public class ZeroLengthArrayValue
{
   public ZeroLengthArrayValue(PortletTestCase seq)
   {
      seq.bindAction(0, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletPreferences prefs = request.getPreferences();

            // With the default value coming from the portlet.xml descriptor
            String value = prefs.getValue("empty", "other");
            assertEquals("other", value);
            assertEquals(new String[]{"other"}, prefs.getValues("empty", new String[]{"other"}));

            //
            PortletURL url = response.createActionURL();
            return new InvokeGetResponse(url.toString());
         }
      });
      seq.bindAction(1, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws ReadOnlyException, IOException, ValidatorException
         {
            PortletPreferences prefs = request.getPreferences();

            // Check it does not exist yet
            assertEquals("other", prefs.getValue("dynamic", "other"));
            assertEquals(new String[]{"other"}, prefs.getValues("dynamic", new String[]{"other"}));

            // Set the value to the empty array and check we get the other value
            prefs.setValues("dynamic", new String[0]);
            assertEquals("other", prefs.getValue("dynamic", "other"));
            assertEquals(new String[]{"other"}, prefs.getValues("dynamic", new String[]{"other"}));

            // Commit change
            prefs.store();

            // Check we still have the other value
            assertEquals("other", prefs.getValue("dynamic", "other"));
            assertEquals(new String[]{"other"}, prefs.getValues("dynamic", new String[]{"other"}));
         }
      });
      seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletPreferences prefs = request.getPreferences();
View Full Code Here

   })
public class NoEvent
{
   public NoEvent(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletConfig cfg = ((AbstractUniversalTestPortlet)portlet).getPortletConfig();
View Full Code Here

TOP

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

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.