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

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


   })
public class CrossContextSessionAttribute
{
   public CrossContextSessionAttribute(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();
            System.out.println(session.getId());
View Full Code Here


@TestCase({Assertion.API286_WINDOW_STATE_6})
public class HashCode
{
   public HashCode(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            WindowState ws1 = new WindowState("TestState");
            WindowState ws2 = new WindowState("teststate");
View Full Code Here

   })
public class PreferencesMap
{
   public PreferencesMap(PortletTestCase seq)
   {
      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 ReadOnlyException
         {
            // Get prefs map
            PortletPreferences prefs = request.getPreferences();
            Map map = prefs.getMap();

            //
            assertEquals(2, map.size());
            assertTrue(map.containsKey("single_pref"));
            assertTrue(map.containsValue(new String[]{"single_pref_value"}));
            assertEquals(new String[]{"single_pref_value"}, (Object[])map.get("single_pref"));
            assertTrue(map.containsKey("multi_pref"));
            assertTrue(map.containsValue(new String[]{"multi_pref_value_1", "multi_pref_value_2"}));
            assertEquals(new String[]{"multi_pref_value_1", "multi_pref_value_2"}, (Object[])map.get("multi_pref"));

            // Modify prefs
            prefs.setValue("single_pref", "new_single_pref_value");
            prefs.setValues("multi_pref", new String[]{"new_multi_pref_value_1", "new_multi_pref_value_2"});

            //
            map = prefs.getMap();
            assertEquals(2, map.size());
            assertTrue(map.containsKey("single_pref"));
            assertTrue(map.containsValue(new String[]{"new_single_pref_value"}));
            assertEquals(new String[]{"new_single_pref_value"}, (Object[])map.get("single_pref"));
            assertTrue(map.containsKey("multi_pref"));
            assertTrue(map.containsValue(new String[]{"new_multi_pref_value_1", "new_multi_pref_value_2"}));
            assertEquals(new String[]{"new_multi_pref_value_1", "new_multi_pref_value_2"}, (Object[])map.get("multi_pref"));

            // Modify prefs
            prefs.setValue("single_pref", null);
            prefs.setValues("multi_pref", null);

            //
            map = prefs.getMap();
            assertEquals(2, map.size());
            assertTrue(map.containsKey("single_pref"));
            assertTrue(map.containsValue(new String[]{null}));
            assertEquals(new String[]{null}, (Object[])map.get("single_pref"));
            assertTrue(map.containsKey("multi_pref"));
            assertEquals(new String[]{null}, (Object[])map.get("multi_pref"));
         }
      });

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

   /** . */
   private String sessionId;

   public ObtainNonNullSessionUsingCreateEqualsFalse(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();
            assertNotNull(session);
            sessionId = session.getId();
            session.setAttribute("foo_1", "bar_1");
            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
         {
            PortletSession session = request.getPortletSession(false);
            assertNotNull(session);
            assertEquals(sessionId, session.getId());
            assertEquals("bar_1", session.getAttribute("foo_1"));
            session.setAttribute("foo_2", "bar_2");
         }
      });
      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletSession session = request.getPortletSession(false);
            assertNotNull(session);
View Full Code Here

   })
public class RequestParameter
{
   public RequestParameter(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();
            url.setParameter("foo1", "bar1");
            url.setParameter("foo2", new String[]{"bar2_1", "bar2_2"});
            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)
         {
            // The expected map
            Map expectedParameterMap = new HashMap();
            expectedParameterMap.put("foo1", Tools.toSet(new String[]{"bar1"}));
            expectedParameterMap.put("foo2", Tools.toSet(new String[]{"bar2_1", "bar2_2"}));

            // Transform the map to be comparable
            Map parameterMap = new HashMap(request.getParameterMap());
            for (Iterator i = parameterMap.entrySet().iterator(); i.hasNext();)
            {
               Map.Entry entry = (Map.Entry)i.next();
               String[] values = (String[])entry.getValue();
               entry.setValue(Tools.toSet(values));
            }

            // Compare both
            assertEquals(expectedParameterMap, parameterMap);

            //
            Set enumeration = Tools.toSet(request.getParameterNames());
            Set expectedEnumeration = Tools.toSet(new Object[]{"foo1", "foo2"});
            assertEquals(expectedEnumeration, enumeration);
         }
      });

      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 ActionWithPortletMode
{
   public ActionWithPortletMode(PortletTestCase seq)
   {
      seq.bindAction(0, TestActionWithPortletModePortlet.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletModeException
         {
            PortletURL url = response.createActionURL();
            url.setPortletMode(PortletMode.EDIT);
            InvokeGetResponse result = new InvokeGetResponse(url.toString());
            return result;
         }
      });

      seq.bindAction(1, TestActionWithPortletModePortlet.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context)
         {
            assertEquals(PortletMode.EDIT, request.getPortletMode());
         }
      });

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

//Assertion.EXT_PORTLET_MODE_2
public class DuringAction
{
   public DuringAction(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();
            InvokeGetResponse result = new InvokeGetResponse(url.toString());
            return result;
         }
      });

      seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletModeException
         {
            // Test we can set null portlet mode
            response.setPortletMode(null);
         }
      });

      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 IsReadOnly
{
   public IsReadOnly(PortletTestCase seq)
   {
      seq.bindAction(0, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            // Get prefs
            PortletPreferences prefs = request.getPreferences();

            //assert that isReadOnly returns correct values
            assertEquals(true, prefs.isReadOnly("static_single_pref"));
            assertEquals(false, prefs.isReadOnly("static_multi_pref"));
            return new InvokeGetResponse(response.createActionURL().toString());
         }
      });

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

            //assert that isReadOnly returns correct values
            assertEquals(true, prefs.isReadOnly("static_single_pref"));
            assertEquals(false, prefs.isReadOnly("static_multi_pref"));
         }
      });

      seq.bindAction(1, UTP2.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 DuringRender
{
   public DuringRender(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletModeException
         {
            // Test null returns false
            assertFalse(request.isPortletModeAllowed(null));
View Full Code Here

   String url;

   public ExpiringCache(PortletTestCase seq)
   {
      //
      seq.bindAction(0, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Content is not cached
            calls.add("0");

            // Refresh
            url = response.createRenderURL().toString();
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(1, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should not be called
            calls.add("1");
            return null;
         }
      });
      seq.bindAction(1, UTP11.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Refresh
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(2, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Could be called depending on whether the portal
            // decides to invoke UTP2 or UTP3 first
            // so if it's called we need to disable cache otherwise the next
            // render will probably not be called
            response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
            return null;
         }
      });
      seq.bindAction(2, UTP11.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            try
            {
               assertFalse(calls.contains("1"));

               // Wait 5 seconds for the cache entry to be invalid
               Thread.sleep(5 * 1000);

               // Refresh
               return new InvokeGetResponse(url);
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }
         }
      });

      //
      seq.bindAction(3, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should be called
            calls.add("3");

            // Invoke the same but with different render parameter
            PortletURL tmp = response.createRenderURL();
            tmp.setParameter("abc", "def");
            url = tmp.toString();
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(4, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should be called
            calls.add("4");

            // Refresh
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(5, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should not be called
            calls.add("5");
            return null;
         }
      });
      seq.bindAction(5, UTP11.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Refresh
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(6, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Could be called depending on whether the portal
            // decides to invoke UTP2 or UTP3 first
            // so if it's called we need to disable cache otherwise the next
            // render will probably not be called
            response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
            return null;
         }
      });
      seq.bindAction(6, UTP11.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            try
            {
               assertFalse(calls.contains("5"));

               // Wait 5 seconds for the cache entry to be invalid
               Thread.sleep(5 * 1000);

               // Refresh
               return new InvokeGetResponse(url);
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }
         }
      });

      //
      seq.bindAction(7, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should be called
            calls.add("7");
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.