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

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


@TestCase({Assertion.JSR168_100})
public class DynamicPreferenceTreatedLikeModifiablePreference
{
   public DynamicPreferenceTreatedLikeModifiablePreference(PortletTestCase seq)
   {
      seq.bindAction(0, UTP4.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, UTP4.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws ReadOnlyException, IOException, ValidatorException
         {
            // Get prefs
            PortletPreferences prefs = request.getPreferences();

            // Test the initial values does not exist
            assertEquals("other", prefs.getValue("single_pref", "other"));
            assertEquals(new String[]{"other"}, prefs.getValues("multi_pref", new String[]{"other"}));

            // Set with new values
            prefs.setValue("single_pref", "new_single_pref");
            prefs.setValues("multi_pref", new String[]{"new_multi_pref_value_1", "new_multi_pref_value_2"});

            // Test the values are good
            assertEquals("new_single_pref", prefs.getValue("single_pref", "other"));
            assertEquals(new String[]{"new_multi_pref_value_1", "new_multi_pref_value_2"}, prefs.getValues("multi_pref", new String[]{"other"}));

            // Trigger store
            prefs.store();

            // Test the value are good after store
            assertEquals("new_single_pref", prefs.getValue("single_pref", "other"));
            assertEquals(new String[]{"new_multi_pref_value_1", "new_multi_pref_value_2"}, prefs.getValues("multi_pref", new String[]{"other"}));
         }
      });

      seq.bindAction(1, UTP4.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, UTP4.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws ReadOnlyException, IOException, ValidatorException
         {
            // Get prefs
            PortletPreferences prefs = request.getPreferences();

            // Test the values have been store in the persistent store
            assertEquals("new_single_pref", prefs.getValue("single_pref", "other"));
            assertEquals(new String[]{"new_multi_pref_value_1", "new_multi_pref_value_2"}, prefs.getValues("multi_pref", new String[]{"other"}));

            // Reset
            prefs.reset("single_pref");
            prefs.reset("multi_pref");

            // Test does not exist
            assertEquals("other", prefs.getValue("single_pref", "other"));
            assertEquals(new String[]{"other"}, prefs.getValues("multi_pref", new String[]{"other"}));

            // Trigger store
            prefs.store();

            // Test does not exist after store
            assertEquals("other", prefs.getValue("single_pref", "other"));
            assertEquals(new String[]{"other"}, prefs.getValues("multi_pref", new String[]{"other"}));
         }
      });

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

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

            // Test the values does not exist
            assertEquals("other", prefs.getValue("single_pref", "other"));
            assertEquals(new String[]{"other"}, prefs.getValues("multi_pref", new String[]{"other"}));
         }
      });

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


@TestCase({Assertion.API286_PORTLET_SESSION_6})
public class CreationTime
{
   public CreationTime(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletSession session = request.getPortletSession();
View Full Code Here

public class NonDeclaredEventPublicationDuringEvent
{

   public NonDeclaredEventPublicationDuringEvent(PortletTestCase seq)
   {
      seq.bindAction(0, UTP8.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, UTP8.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
         {
            // Use a declared event to jump to the process event
            response.setEvent("Bar", null);
         }
      });
      seq.bindAction(1, UTP8.EVENT_JOIN_POINT, new PortletEventTestAction()
      {
         protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
         {
            // We test that we can publish it
            try
            {
               response.setEvent("SomeNonDeclaredString", null);
            }
            catch (IllegalArgumentException e)
            {
               fail(e);
            }

            // We test that we can publish it with a payload
            try
            {
               response.setEvent("SomeNonDeclaredString", "Payload");
            }
            catch (IllegalArgumentException e)
            {
               fail(e);
            }
         }
      });
      seq.bindAction(1, UTP8.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 PublishingProcessingEvent
{
   public PublishingProcessingEvent(PortletTestCase seq)
   {
      seq.bindAction(0, UTP4.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

@TestCase({Assertion.JSR286_133})
public class GetEventWithNoValue
{
   public GetEventWithNoValue(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, IOException
         {
            response.setEvent(new QName("urn:explicit-namespace", "Foo"), null);
         }
      });
      seq.bindAction(1, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
      {
         protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Event event = request.getEvent();
            assertEquals(new QName("urn:explicit-namespace", "Foo"), event.getQName());
            assertEquals(null, event.getValue());
         }
      });
      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 ResourceID
{
   public ResourceID(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

@TestCase(Assertion.JSR286_296)
public class PropagateDoFilterArgs
{
   public PropagateDoFilterArgs(PortletTestCase seq)
   {
      seq.bindAction(0, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest req, RenderResponse resp, PortletTestContext context) throws PortletException, IOException
         {
            return new InvokeGetResponse(resp.createActionURL().toString());
         }
      });
      seq.bindAction(1, UTP3.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest req, ActionResponse resp, PortletTestContext context) throws PortletException, IOException
         {
            assertSame(PropagateDoFilterArgsFilter1.publishedActionRequest, PropagateDoFilterArgsFilter2.consumedActionRequest);
            assertSame(PropagateDoFilterArgsFilter1.publishedActionResponse, PropagateDoFilterArgsFilter2.consumedActionResponse);
            assertSame(PropagateDoFilterArgsFilter2.publishedActionRequest, req);
            assertSame(PropagateDoFilterArgsFilter2.publishedActionResponse, resp);

            //
            resp.setEvent("Event", null);
         }
      });
      seq.bindAction(1, UTP3.EVENT_JOIN_POINT, new PortletEventTestAction()
      {
         protected void run(Portlet portlet, EventRequest req, EventResponse resp, PortletTestContext context) throws PortletException, IOException
         {
            assertSame(PropagateDoFilterArgsFilter1.publishedEventRequest, PropagateDoFilterArgsFilter2.consumedEventRequest);
            assertSame(PropagateDoFilterArgsFilter1.publishedEventResponse, PropagateDoFilterArgsFilter2.consumedEventResponse);
            assertSame(PropagateDoFilterArgsFilter2.publishedEventRequest, req);
            assertSame(PropagateDoFilterArgsFilter2.publishedEventResponse, resp);
         }
      });
      seq.bindAction(1, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest req, RenderResponse resp, PortletTestContext context) throws PortletException, IOException
         {
            assertSame(PropagateDoFilterArgsFilter1.publishedRenderRequest, PropagateDoFilterArgsFilter2.consumedRenderRequest);
            assertSame(PropagateDoFilterArgsFilter1.publishedRenderResponse, PropagateDoFilterArgsFilter2.consumedRenderResponse);
View Full Code Here

@TestCase({Assertion.API286_PORTLET_SESSION_11})
public class Invalidate
{
   public Invalidate(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletSession session = request.getPortletSession();
View Full Code Here

   /** . */
   private Object _response;

   public IncludedRequestAttributes(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            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
         {
            dispatch(portlet, request, response);

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

View Full Code Here

   })
public class Value
{
   public Value(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 ReadOnlyException
         {
            PortletPreferences prefs = request.getPreferences();

            //correct
            try
            {
               prefs.getValue("name", null);

            }
            catch (IllegalArgumentException e)
            {
               fail();
            }

            try
            {
               prefs.getValues("name", null);
            }
            catch (IllegalArgumentException e)
            {
               fail();
            }

            //wrong
            try
            {
               prefs.getValue(null, "val");
               fail();
            }
            catch (IllegalArgumentException e)
            {
               //
            }

            try
            {
               prefs.getValues(null, new String[]{"val"});
               fail();
            }
            catch (IllegalArgumentException e)
            {
               //
            }

            //and the "set" ones

            //correct
            //(need user auth)
            /*try
            {
               prefs.setValue("name", null);
            }
            catch (IllegalArgumentException e)
            {
               fail();
            }

            try
            {
               prefs.setValues("name", null);
            }
            catch (IllegalArgumentException e)
            {
               fail();
            }*/

            //wrong
            try
            {
               prefs.setValue(null, null);
               fail();
            }
            catch (IllegalArgumentException e)
            {
               //
            }

            try
            {
               prefs.setValues(null, null);
               fail();
            }
            catch (IllegalArgumentException e)
            {
               //
            }
         }
      });

      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

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.