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

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


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


         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()
      {
View Full Code Here

      {
         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()
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();
            InvokeGetResponse result = new InvokeGetResponse(url.toString());
            return result;
         }
      });

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

            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()
      {
View Full Code Here

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

      seq.bindAction(0, UTP4.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, 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();

            // Check the initial value are good
            assertEquals("static_single_pref_value", prefs.getValue("static_single_pref", "other"));
            assertEquals(new String[]{"static_multi_pref_value_1", "static_multi_pref_value_2"}, prefs.getValues("static_multi_pref", new String[]{"other"}));
            assertEquals("other", prefs.getValue("dynamic_single_pref", "other"));
            assertEquals(new String[]{"other"}, prefs.getValues("dynamic_multi_pref", new String[]{"other"}));

            // Set values
            prefs.setValue("static_single_pref", "new_static_single_pref_value");
            prefs.setValues("static_multi_pref", new String[]{"new_static_multi_pref_value_1", "new_static_multi_pref_value_2"});
            prefs.setValue("dynamic_single_pref", "new_dynamic_single_pref_value");
            prefs.setValues("dynamic_multi_pref", new String[]{"new_dynamic_multi_pref_value_1", "new_dynamic_multi_pref_value_2"});

            // Store
            prefs.store();
         }
      });

      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()
      {
View Full Code Here

            // Should be called
            calls.add("0");

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

      //
      seq.bindAction(1, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should be called
            calls.add("1");
            response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");

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

      //
      seq.bindAction(2, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should be called
            calls.add("2");
            response.setProperty(RenderResponse.EXPIRATION_CACHE, "5");
            response.setProperty(RenderResponse.ETAG, "xyz");

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

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

      //
      seq.bindAction(4, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Could be called or not depending on the page rendering ordre
            return null;
         }
      });
      seq.bindAction(4, p2renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            try
            {
               // 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(5, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            assertEquals("xyz", request.getETag());
            assertTrue(Tools.toSet(request.getPropertyNames()).contains(RenderRequest.ETAG));
            assertEquals("xyz", request.getProperty(RenderRequest.ETAG));

            // Record we were called
            calls.add("5");

            // Revalidate existing content
            response.setProperty(RenderResponse.EXPIRATION_CACHE, "5");
            response.setProperty(RenderResponse.USE_CACHED_CONTENT, "foo");

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

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

      //
      seq.bindAction(7, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Could be called or not depending on the page rendering ordre
            return null;
         }
      });
      seq.bindAction(7, p2renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            try
            {
               // 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(8, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            assertEquals("xyz", request.getETag());
            assertTrue(Tools.toSet(request.getPropertyNames()).contains(RenderRequest.ETAG));
            assertEquals("xyz", request.getProperty(RenderRequest.ETAG));

            // Record we were called
            calls.add("8");

            url = response.createActionURL().toString();
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(9, p1actionjp, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
         {
            // Should be called
            calls.add("9_action");
         }
      });
      seq.bindAction(9, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should be called
            calls.add("9_render");
            return new InvokeGetResponse(response.createRenderURL().toString());
         }
      });

      //
      seq.bindAction(10, p1renderjp, 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

         {
            PortletURL url = response.createActionURL();
            //set some parameters for testing
            url.setParameter("key1", "k1value1");
            url.setParameter("key2", new String[]{"k2value1", "k2value2", "k2value3"});
            return new InvokeGetResponse(url.toString());
         }
      });

      seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
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.