[portal-commits] JBoss Portal SVN: r5857 - in branches/JBoss_Portal_Branch_2_4: portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests server/src/main/org/jboss/portal/server/servlet

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Thu Dec 14 14:39:42 EST 2006


Author: julien at jboss.com
Date: 2006-12-14 14:39:34 -0500 (Thu, 14 Dec 2006)
New Revision: 5857

Modified:
   branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/PortletInterfaceSequenceBuilder.java
   branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests/PortletRequestsSequenceBuilder.java
   branches/JBoss_Portal_Branch_2_4/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
Log:
fixed failing portlet container test cases in 2.4 branch

Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/PortletInterfaceSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/PortletInterfaceSequenceBuilder.java	2006-12-14 14:51:47 UTC (rev 5856)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/PortletInterfaceSequenceBuilder.java	2006-12-14 19:39:34 UTC (rev 5857)
@@ -167,6 +167,7 @@
    {
       Sequence seq = new Sequence();
       registry.addSequence("InvokeActionFirst", seq);
+      final Boolean[] actionInvoked= new Boolean[1];
 
       seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
       {
@@ -180,7 +181,7 @@
       {
          protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response)
          {
-            UTP1.local.set(Boolean.TRUE);
+            actionInvoked[0] = Boolean.TRUE;
             return null;
          }
       });
@@ -189,7 +190,7 @@
       {
          protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
          {
-            assertEquals(Boolean.TRUE, (Boolean)UTP1.local.get());
+            assertEquals(Boolean.TRUE, actionInvoked[0]);
             return new EndTestResult();
          }
       });
@@ -205,6 +206,7 @@
    {
       Sequence seq = new Sequence();
       registry.addSequence("InvokeRenderAfterActionURL", seq);
+      final Boolean[] actionInvoked= new Boolean[1];
 
       seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
       {
@@ -239,7 +241,7 @@
          protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response)
          {
             //mark action phase invokation
-            UTP2.local.set(Boolean.TRUE);
+            actionInvoked[0] = Boolean.TRUE;
             return null;
          }
       });
@@ -249,7 +251,7 @@
          protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
          {
             //assert that render is after Portlet B action
-            assertEquals(Boolean.TRUE, (Boolean)UTP2.local.get());
+            assertEquals(Boolean.TRUE, actionInvoked[0]);
             return null;
          }
       });
@@ -259,7 +261,7 @@
          protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
          {
             //assert that render is after Portlet B action
-            assertEquals(Boolean.TRUE, (Boolean)UTP2.local.get());
+            assertEquals(Boolean.TRUE, actionInvoked[0]);
             //and reinvoke itself
             return new InvokeGetResult(response.createRenderURL().toString());
          }

Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests/PortletRequestsSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests/PortletRequestsSequenceBuilder.java	2006-12-14 14:51:47 UTC (rev 5856)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests/PortletRequestsSequenceBuilder.java	2006-12-14 19:39:34 UTC (rev 5857)
@@ -149,7 +149,10 @@
       {
          protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
          {
-            UTP2.holder = response.createRenderURL();
+            PortletURL url = response.createRenderURL();
+            url.setParameter("portlet2key1", "p2k1value1");
+            url.setParameter("portlet2key2", new String[]{"p2k2value1", "p2k2value2", "p2k2value3"});
+            UTP2.holder = url.toString();
             return null;
          }
       });
@@ -173,9 +176,7 @@
          protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
          {
             //invoke render url from different portlet to be able to pass some params to it
-            PortletURL url = (PortletURL)UTP2.holder;
-            url.setParameter("portlet2key1", "p2k1value1");
-            url.setParameter("portlet2key2", new String[]{"p2k2value1", "p2k2value2", "p2k2value3"});
+            String url = (String)UTP2.holder;
             return new InvokeGetResult(url.toString());
          }
       });

Modified: branches/JBoss_Portal_Branch_2_4/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java	2006-12-14 14:51:47 UTC (rev 5856)
+++ branches/JBoss_Portal_Branch_2_4/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java	2006-12-14 19:39:34 UTC (rev 5857)
@@ -424,13 +424,21 @@
    public class ServerResponseContextImpl implements ServerResponseContext
    {
 
-      private HttpServletRequest req;
-      private HttpServletResponse resp;
+      private final HttpServletResponse resp;
+      private final String contextPath;
+      private final String scheme;
+      private final String serverName;
+      private final int serverPort;
+      private final boolean secure;
 
       public ServerResponseContextImpl(HttpServletRequest req, HttpServletResponse resp)
       {
-         this.req = req;
          this.resp = resp;
+         this.contextPath = req.getContextPath();
+         this.scheme = req.getScheme();
+         this.serverName = req.getServerName();
+         this.serverPort = req.getServerPort();
+         this.secure = req.isSecure();
       }
 
       public HttpServletResponse getClientResponse()
@@ -440,138 +448,131 @@
 
       public String encodeURL(ServerURL url, URLContext context, URLFormat format)
       {
-         Buffer buffer = new Buffer(req, resp, context, format);
+         Buffer buffer = new Buffer(context, format);
          return buffer.toString(url);
       }
-   }
 
-   public static class Buffer
-   {
+      public class Buffer
+      {
 
-      private HttpServletRequest req;
+         private URLContext context;
+         private URLFormat format;
+         private char[] buffer = new char[256];
+         private int len = 0;
 
-      private HttpServletResponse resp;
+         public Buffer(URLContext context, URLFormat format)
+         {
+            this.context = context;
+            this.format = format;
 
-      private URLContext context;
+            //
+            init();
+         }
 
-      private URLFormat format;
-
-      private char[] buffer = new char[256];
-
-      private int len = 0;
-
-
-      public Buffer(HttpServletRequest req, HttpServletResponse resp, URLContext context, URLFormat format)
-      {
-         this.req = req;
-         this.resp = resp;
-         this.context = context;
-         this.format = format;
-         init();
-      }
-
-      private void init()
-      {
-         //
-         if (!format.isRelative())
+          private void init()
          {
-            append(req.getScheme());
-            append("://");
-            append(req.getServerName());
 
             //
-            int port = req.getServerPort();
-            if (req.isSecure())
+            if (!format.isRelative())
             {
-               if (port != 443)
+               append(scheme);
+               append("://");
+               append(serverName);
+
+               //
+               int port = serverPort;
+               if (secure)
                {
+                  if (port != 443)
+                  {
+                     append(":");
+                     append(Integer.toString(port));
+                  }
+               }
+               else if (port != 80)
+               {
                   append(":");
                   append(Integer.toString(port));
                }
             }
-            else if (port != 80)
-            {
-               append(":");
-               append(Integer.toString(port));
-            }
-         }
 
-         // Append the context path
-         append(req.getContextPath());
+            // Append the context path
+            append(contextPath);
 
-         // Append the servlet path
-         if (context.isAuthenticated())
-         {
-            if (context.getSecure())
+            // Append the servlet path
+            if (context.isAuthenticated())
             {
-               append("/authsec");
+               if (context.getSecure())
+               {
+                  append("/authsec");
+               }
+               else
+               {
+                  append("/auth");
+               }
             }
             else
             {
-               append("/auth");
+               if (context.getSecure())
+               {
+                  append("/sec");
+               }
+               else
+               {
+                  append("");
+               }
             }
          }
-         else
+
+         public String toString(ServerURL url)
          {
-            if (context.getSecure())
+            // julien : check UTF-8 is ok and should not be dependant on the response charset
+            append(url.getPortalRequestPath());
+
+            //
+            boolean first = true;
+            for (Iterator i = url.getParameters(); i.hasNext();)
             {
-               append("/sec");
+               ServerURL.Parameter parameter = (ServerURL.Parameter)i.next();
+               String name = parameter.getName();
+               for (Iterator j = parameter.getValues(); j.hasNext();)
+               {
+                  String value = (String)j.next();
+                  append(first ? "?" : "&");
+                  append(URLTools.encodeXWWWFormURL(name));
+                  append("=");
+                  append(URLTools.encodeXWWWFormURL(value));
+                  first = false;
+               }
             }
-            else
-            {
-               append("");
-            }
-         }
-      }
 
-      public String toString(ServerURL url)
-      {
-         // julien : check UTF-8 is ok and should not be dependant on the response charset
-         append(url.getPortalRequestPath());
+            //
+            String s = new String(buffer, 0, len);
 
-         //
-         boolean first = true;
-         for (Iterator i = url.getParameters(); i.hasNext();)
-         {
-            ServerURL.Parameter parameter = (ServerURL.Parameter)i.next();
-            String name = parameter.getName();
-            for (Iterator j = parameter.getValues(); j.hasNext();)
+            //
+            if (format.isEncoded())
             {
-               String value = (String)j.next();
-               append(first ? "?" : "&");
-               append(URLTools.encodeXWWWFormURL(name));
-               append("=");
-               append(URLTools.encodeXWWWFormURL(value));
-               first = false;
+               s = resp.encodeURL(s);
             }
-         }
 
-         //
-         String s = new String(buffer, 0, len);
-
-         //
-         if (format.isEncoded())
-         {
-            s = resp.encodeURL(s);
+            //
+            return s;
          }
 
-         //
-         return s;
-      }
-
-      private void append(String arg)
-      {
-         int arglen = arg.length();
-         int buflen = buffer.length;
-         while (len + arglen > buflen)
+         private void append(String arg)
          {
-            char[] tmp = new char[buflen * 2 + 1];
-            System.arraycopy(buffer, 0, tmp, 0, len);
-            buffer = tmp;
-            buflen = tmp.length;
+            int arglen = arg.length();
+            int buflen = buffer.length;
+            while (len + arglen > buflen)
+            {
+               char[] tmp = new char[buflen * 2 + 1];
+               System.arraycopy(buffer, 0, tmp, 0, len);
+               buffer = tmp;
+               buflen = tmp.length;
+            }
+            arg.getChars(0, arglen, buffer, len);
+            len += arglen;
          }
-         arg.getChars(0, arglen, buffer, len);
-         len += arglen;
       }
    }
 




More information about the portal-commits mailing list