[portal-commits] JBoss Portal SVN: r5880 - in trunk/portlet: . src/main/org/jboss/portal/portlet/test src/main/org/jboss/portal/test/portlet/framework src/main/org/jboss/portal/test/portlet/jsr168/ext/common src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache src/resources/test/jsr168/ext/expiringcache-war/WEB-INF src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Fri Dec 15 20:44:50 EST 2006


Author: julien at jboss.com
Date: 2006-12-15 20:44:37 -0500 (Fri, 15 Dec 2006)
New Revision: 5880

Added:
   trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/UTP11.java
Modified:
   trunk/portlet/build.xml
   trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java
   trunk/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml
   trunk/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml
Log:
JBPORTAL-1163 : cache test cover window state and portlet mode

Modified: trunk/portlet/build.xml
===================================================================
--- trunk/portlet/build.xml	2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/build.xml	2006-12-16 01:44:37 UTC (rev 5880)
@@ -459,7 +459,6 @@
          <x-test>
 
             <!--Spec TCK Assertions tests-->
-<!--
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.DispatcherTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.PortletConfigTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.PortletContextTestCase"/>
@@ -471,10 +470,8 @@
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.PortletURLTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.PreferencesTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.WindowStatesTestCase"/>
--->
 
             <!--API Tests-->
-<!--
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.ActionRequestTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.ActionResponseTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.PortalContextTestCase"/>
@@ -488,10 +485,8 @@
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.RenderRequestTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.RenderResponseTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.WindowStateTestCase"/>
--->
 
             <!--Ext Tests-->
-<!--
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.DispatcherTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.PortletConfigTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.PortletModeTestCase"/>
@@ -499,13 +494,12 @@
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.PortletResponsesTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.PreferencesTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.SessionTestCase"/>
--->
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.ExpiringCacheTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.NeverExpiringCacheTestCase"/>
-            <!--<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.NoCacheTestCase"/>-->
+            <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.NoCacheTestCase"/>
 
             <!--Misc Tests-->
-            <!--<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.misc.Log4jTestCase"/>-->
+            <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.misc.Log4jTestCase"/>
 
          </x-test>
          <x-classpath>

Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java	2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java	2006-12-16 01:44:37 UTC (rev 5880)
@@ -230,16 +230,20 @@
                invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext().getId(), decoder.getNavigationalstate());
 
                //
-               if (decoder.getMode() != null)
+               Mode mode = decoder.getMode();
+               if (mode == null)
                {
-                  invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_mode", decoder.getMode());
+                  mode = Mode.VIEW;
                }
+               invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_mode", mode);
 
                //
-               if (decoder.getWindowState() != null)
+               WindowState windowState = decoder.getWindowState();
+               if (windowState == null)
                {
-                  invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_windowstate", decoder.getWindowState());
+                  windowState = WindowState.NORMAL;
                }
+               invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_windowstate", windowState);
             }
 
          }

Added: trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/UTP11.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/UTP11.java	2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/UTP11.java	2006-12-16 01:44:37 UTC (rev 5880)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.framework;
+
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.Joinpoint;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5568 $
+ */
+public class UTP11 extends AbstractUniversalTestPortlet
+{
+   public static ThreadLocal local = new ThreadLocal();
+
+   public static Object holder;
+
+   public static String NAME = "Portlet11";
+
+   public final static Joinpoint RENDER_JOINPOINT = new Joinpoint(NAME, Joinpoint.PORTLET_RENDER);
+
+   public final static Joinpoint ACTION_JOINPOINT = new Joinpoint(NAME, Joinpoint.PORTLET_ACTION);
+
+   protected String createComponentId()
+   {
+      return NAME;
+   }
+
+   /** Resets helper variables */
+   public void reset()
+   {
+      local = new ThreadLocal();
+      holder = null;
+   }
+}

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java	2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java	2006-12-16 01:44:37 UTC (rev 5880)
@@ -41,6 +41,10 @@
 import javax.portlet.RenderRequest;
 import javax.portlet.PortletException;
 import javax.portlet.ActionRequest;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
 import java.util.Set;
 import java.util.HashSet;
 import java.io.IOException;
@@ -66,6 +70,34 @@
       }
    };
 
+   protected final AbstractCacheSequenceBuilder.NavigationalStateConfigurator windowStateConfigurator = new AbstractCacheSequenceBuilder.NavigationalStateConfigurator()
+   {
+      public PortletURL createPortletURL(RenderResponse resp) throws WindowStateException
+      {
+         PortletURL url = resp.createRenderURL();
+         url.setWindowState(WindowState.MAXIMIZED);
+         return url;
+      }
+      public void configureNavigationalState(ActionResponse resp) throws WindowStateException
+      {
+         resp.setWindowState(WindowState.MAXIMIZED);
+      }
+   };
+
+   protected final AbstractCacheSequenceBuilder.NavigationalStateConfigurator portletModeConfigurator = new AbstractCacheSequenceBuilder.NavigationalStateConfigurator()
+   {
+      public PortletURL createPortletURL(RenderResponse resp) throws PortletModeException
+      {
+         PortletURL url = resp.createRenderURL();
+         url.setPortletMode(PortletMode.EDIT);
+         return url;
+      }
+      public void configureNavigationalState(ActionResponse resp) throws PortletModeException
+      {
+         resp.setPortletMode(PortletMode.EDIT);
+      }
+   };
+
    /**
     * Overriding the expiration cache to 0 disable the cache on a render or an action/render.
     */
@@ -131,188 +163,10 @@
       });
    }
 
-   /**
-    * Caching happens after a render with the same render parameters for at most 5 seconds
-    * Calling render on the portlet with different render parameters invalidates the cache
-    */
-//   public void createExpiringCache(SequenceRegistry registry)
-//   {
-//      final Set calls = new HashSet();
-//      final String[] url = new String[1];
-//      Sequence seq = new Sequence();
-//      registry.addSequence("ExpiringCache", seq);
-//
-//      //
-//      seq.addAction(0, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-//         {
-//            // Content is not cached
-//            calls.add("0");
-//
-//            // Refresh
-//            url[0] = response.createRenderURL().toString();
-//            return new InvokeGetResponse(url[0]);
-//         }
-//      });
-//
-//      //
-//      seq.addAction(1, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-//         {
-//            // Should not be called
-//            calls.add("1");
-//            return null;
-//         }
-//      });
-//      seq.addAction(1, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-//         {
-//            // Refresh
-//            return new InvokeGetResponse(url[0]);
-//         }
-//      });
-//
-//      //
-//      seq.addAction(2, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse 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.addAction(2, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse 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[0]);
-//            }
-//            catch (InterruptedException e)
-//            {
-//               return new ErrorResponse(e);
-//            }
-//         }
-//      });
-//
-//      //
-//      seq.addAction(3, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse 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[0] = tmp.toString();
-//            return new InvokeGetResponse(url[0]);
-//         }
-//      });
-//
-//      //
-//      seq.addAction(4, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-//         {
-//            // Should be called
-//            calls.add("4");
-//
-//            // Refresh
-//            return new InvokeGetResponse(url[0]);
-//         }
-//      });
-//
-//      //
-//      seq.addAction(5, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-//         {
-//            // Should not be called
-//            calls.add("5");
-//            return null;
-//         }
-//      });
-//      seq.addAction(5, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-//         {
-//            // Refresh
-//            return new InvokeGetResponse(url[0]);
-//         }
-//      });
-//
-//      //
-//      seq.addAction(6, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse 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.addAction(6, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse 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[0]);
-//            }
-//            catch (InterruptedException e)
-//            {
-//               return new ErrorResponse(e);
-//            }
-//         }
-//      });
-//
-//      //
-//      seq.addAction(7, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-//      {
-//         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-//         {
-//            // Should be called
-//            calls.add("7");
-//
-//            //
-//            Set expected = new CollectionBuilder().add("0").add("3").add("4").add("7").toHashSet();
-//            assertEquals(expected, calls);
-//
-//            // Refresh
-//            return new EndTestResponse();
-//         }
-//      });
-//   }
-
    protected interface NavigationalStateConfigurator
    {
-      PortletURL createPortletURL(RenderResponse resp);
-      void configureNavigationalState(ActionResponse resp);
+      PortletURL createPortletURL(RenderResponse resp) throws PortletException;
+      void configureNavigationalState(ActionResponse resp) throws PortletException;
    }
 
    /**

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java	2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java	2006-12-16 01:44:37 UTC (rev 5880)
@@ -23,13 +23,36 @@
 package org.jboss.portal.test.portlet.jsr168.ext.expiringcache;
 
 import org.jboss.portal.test.framework.portlet.SequenceRegistry;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.Sequence;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.driver.http.response.InvokeGetResponse;
 import org.jboss.portal.test.portlet.framework.UTP1;
 import org.jboss.portal.test.portlet.framework.UTP2;
 import org.jboss.portal.test.portlet.framework.UTP3;
 import org.jboss.portal.test.portlet.framework.UTP4;
 import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.portal.test.portlet.framework.UTP6;
+import org.jboss.portal.test.portlet.framework.UTP7;
+import org.jboss.portal.test.portlet.framework.UTP8;
+import org.jboss.portal.test.portlet.framework.UTP9;
+import org.jboss.portal.test.portlet.framework.UTP10;
+import org.jboss.portal.test.portlet.framework.UTP11;
 import org.jboss.portal.test.portlet.jsr168.ext.common.AbstractCacheSequenceBuilder;
+import org.jboss.portal.common.test.driver.DriverResponse;
+import org.jboss.portal.common.test.driver.response.ErrorResponse;
+import org.jboss.portal.common.test.driver.response.EndTestResponse;
+import org.jboss.portal.common.util.CollectionBuilder;
 
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletURL;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision: 1.1 $
@@ -42,13 +65,201 @@
       createDisableDuringRender("DisableDuringRenderExpiringCache", registry, UTP1.RENDER_JOINPOINT, UTP1.ACTION_JOINPOINT);
    }
 
-   public void createExpiringCache(SequenceRegistry registry)
+   public void createActionInvalidatesExpiringCache(SequenceRegistry registry)
    {
-      createCacheMarkup("ExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT, renderParameterConfigurator);
+      createActionInvalidates("ActionInvalidatesExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT);
    }
 
-   public void createActionInvalidatesExpiringCache(SequenceRegistry registry)
+   public void createExpiringCacheWithRenderParameters(SequenceRegistry registry)
    {
-      createActionInvalidates("ActionInvalidatesExpiringCache", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT);
+      createCacheMarkup("ExpiringCacheWithRenderParameters", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT, renderParameterConfigurator);
    }
+
+   public void createExpiringCacheWithWindowState(SequenceRegistry registry)
+   {
+      createCacheMarkup("ExpiringCacheWithWindowState", registry, UTP6.RENDER_JOINPOINT, UTP6.ACTION_JOINPOINT, UTP7.RENDER_JOINPOINT, windowStateConfigurator);
+   }
+
+   public void createExpiringCacheWithPortletMode(SequenceRegistry registry)
+   {
+      createCacheMarkup("ExpiringCacheWithPortletMode", registry, UTP8.RENDER_JOINPOINT, UTP8.ACTION_JOINPOINT, UTP9.RENDER_JOINPOINT, portletModeConfigurator);
+   }
+
+   /**
+    * Check that content is cached for at most 5 seconds in various situations. 
+    */
+   public void createExpiringCache(SequenceRegistry registry)
+   {
+      final Set calls = new HashSet();
+      final String[] url = new String[1];
+      Sequence seq = new Sequence();
+      registry.addSequence("ExpiringCache", seq);
+
+      //
+      seq.addAction(0, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            // Content is not cached
+            calls.add("0");
+
+            // Refresh
+            url[0] = response.createRenderURL().toString();
+            return new InvokeGetResponse(url[0]);
+         }
+      });
+
+      //
+      seq.addAction(1, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            // Should not be called
+            calls.add("1");
+            return null;
+         }
+      });
+      seq.addAction(1, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            // Refresh
+            return new InvokeGetResponse(url[0]);
+         }
+      });
+
+      //
+      seq.addAction(2, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse 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.addAction(2, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse 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[0]);
+            }
+            catch (InterruptedException e)
+            {
+               return new ErrorResponse(e);
+            }
+         }
+      });
+
+      //
+      seq.addAction(3, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse 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[0] = tmp.toString();
+            return new InvokeGetResponse(url[0]);
+         }
+      });
+
+      //
+      seq.addAction(4, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            // Should be called
+            calls.add("4");
+
+            // Refresh
+            return new InvokeGetResponse(url[0]);
+         }
+      });
+
+      //
+      seq.addAction(5, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            // Should not be called
+            calls.add("5");
+            return null;
+         }
+      });
+      seq.addAction(5, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            // Refresh
+            return new InvokeGetResponse(url[0]);
+         }
+      });
+
+      //
+      seq.addAction(6, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse 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.addAction(6, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse 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[0]);
+            }
+            catch (InterruptedException e)
+            {
+               return new ErrorResponse(e);
+            }
+         }
+      });
+
+      //
+      seq.addAction(7, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            // Should be called
+            calls.add("7");
+
+            //
+            Set expected = new CollectionBuilder().add("0").add("3").add("4").add("7").toHashSet();
+            assertEquals(expected, calls);
+
+            // Refresh
+            return new EndTestResponse();
+         }
+      });
+   }
+
 }

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java	2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java	2006-12-16 01:44:37 UTC (rev 5880)
@@ -28,6 +28,10 @@
 import org.jboss.portal.test.portlet.framework.UTP3;
 import org.jboss.portal.test.portlet.framework.UTP4;
 import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.portal.test.portlet.framework.UTP6;
+import org.jboss.portal.test.portlet.framework.UTP7;
+import org.jboss.portal.test.portlet.framework.UTP8;
+import org.jboss.portal.test.portlet.framework.UTP9;
 import org.jboss.portal.test.framework.portlet.SequenceRegistry;
 
 /**
@@ -42,13 +46,23 @@
       createDisableDuringRender("DisableDuringRenderNeverExpiringCache", registry, UTP1.RENDER_JOINPOINT, UTP1.ACTION_JOINPOINT);
    }
 
-   public void createNeverExpiringCache(SequenceRegistry registry)
+   public void createActionInvalidatesNeverExpiringCache(SequenceRegistry registry)
    {
-      createCacheMarkup("NeverExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT, renderParameterConfigurator);
+      createActionInvalidates("ActionInvalidatesNeverExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT);
    }
 
-   public void createActionInvalidatesNeverExpiringCache(SequenceRegistry registry)
+   public void createNeverExpiringCacheWithRenderParameters(SequenceRegistry registry)
    {
-      createActionInvalidates("ActionInvalidatesNeverExpiringCache", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT);
+      createCacheMarkup("NeverExpiringCacheWithRenderParameters", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT, renderParameterConfigurator);
    }
+
+   public void createNeverExpiringCacheWithWindowState(SequenceRegistry registry)
+   {
+      createCacheMarkup("NeverExpiringCacheWithWindowState", registry, UTP6.RENDER_JOINPOINT, UTP6.ACTION_JOINPOINT, UTP7.RENDER_JOINPOINT, windowStateConfigurator);
+   }
+
+   public void createNeverExpiringCacheWithPortletMode(SequenceRegistry registry)
+   {
+      createCacheMarkup("NeverExpiringCacheWithPortletMode", registry, UTP8.RENDER_JOINPOINT, UTP8.ACTION_JOINPOINT, UTP9.RENDER_JOINPOINT, portletModeConfigurator);
+   }
 }

Modified: trunk/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml	2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml	2006-12-16 01:44:37 UTC (rev 5880)
@@ -85,4 +85,74 @@
       </portlet-info>
    </portlet>
 
+   <portlet>
+      <portlet-name>TestUniversalPortletF</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP6</portlet-class>
+      <expiration-cache>5</expiration-cache>
+      <supports>
+        <mime-type>text/html</mime-type>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
+   <portlet>
+      <portlet-name>TestUniversalPortletG</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP7</portlet-class>
+      <supports>
+        <mime-type>text/html</mime-type>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
+   <portlet>
+      <portlet-name>TestUniversalPortletH</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP8</portlet-class>
+      <expiration-cache>5</expiration-cache>
+      <supports>
+        <mime-type>text/html</mime-type>
+        <portlet-mode>edit</portlet-mode>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
+   <portlet>
+      <portlet-name>TestUniversalPortletI</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP9</portlet-class>
+      <supports>
+        <mime-type>text/html</mime-type>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
+   <portlet>
+      <portlet-name>TestUniversalPortletJ</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP10</portlet-class>
+      <expiration-cache>5</expiration-cache>
+      <supports>
+        <mime-type>text/html</mime-type>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
+   <portlet>
+      <portlet-name>TestUniversalPortletK</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP11</portlet-class>
+      <supports>
+        <mime-type>text/html</mime-type>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
 </portlet-app>

Modified: trunk/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml	2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml	2006-12-16 01:44:37 UTC (rev 5880)
@@ -85,4 +85,51 @@
       </portlet-info>
    </portlet>
 
+   <portlet>
+      <portlet-name>TestUniversalPortletF</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP6</portlet-class>
+      <expiration-cache>-1</expiration-cache>
+      <supports>
+        <mime-type>text/html</mime-type>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
+   <portlet>
+      <portlet-name>TestUniversalPortletG</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP7</portlet-class>
+      <supports>
+        <mime-type>text/html</mime-type>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
+   <portlet>
+      <portlet-name>TestUniversalPortletH</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP8</portlet-class>
+      <expiration-cache>-1</expiration-cache>
+      <supports>
+        <mime-type>text/html</mime-type>
+        <portlet-mode>edit</portlet-mode>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
+   <portlet>
+      <portlet-name>TestUniversalPortletI</portlet-name>
+      <portlet-class>org.jboss.portal.test.portlet.framework.UTP9</portlet-class>
+      <supports>
+        <mime-type>text/html</mime-type>
+      </supports>
+      <portlet-info>
+         <title></title>
+      </portlet-info>
+   </portlet>
+
 </portlet-app>




More information about the portal-commits mailing list