[portal-commits] JBoss Portal SVN: r8833 - in modules/portlet/trunk/portlet/src: main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher and 1 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Tue Nov 6 09:04:11 EST 2007


Author: julien at jboss.com
Date: 2007-11-06 09:04:11 -0500 (Tue, 06 Nov 2007)
New Revision: 8833

Added:
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatchedRequestTestCase.java
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ErrorHandlingTestCase.java
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/GETMethodTestCase.java
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/IncludedRequestAttributesTestCase.java
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/IncludedRequestParametersTestCase.java
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ObtainingDispatcherTestCase.java
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/QueryStringInRequestDispatcherTestCase.java
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/RequestObjectTestCase.java
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ResponseObjectTestCase.java
Removed:
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java
Modified:
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestSuite.java
   modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherTestSuite.java
   modules/portlet/trunk/portlet/src/resources/test/jsr168/tck/dispatcher-war/WEB-INF/web.xml
Log:
- started to uncluster the portlet container test cases by using one single class for a portlet container test case, for now only the TCK request dispatcher tests have been migrated as proof of concept
- current implementation not yet using annotations

Modified: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestSuite.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestSuite.java	2007-11-06 10:17:40 UTC (rev 8832)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestSuite.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -24,6 +24,9 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.unit.remote.driver.RemoteTestDriverServer;
+import org.jboss.portal.common.net.URLNavigator;
+import org.jboss.portal.common.net.URLVisitor;
+import org.jboss.portal.common.net.URLFilter;
 
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
@@ -32,10 +35,17 @@
 import javax.servlet.ServletContext;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.lang.reflect.Constructor;
 import java.util.Arrays;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.Iterator;
 import java.util.regex.Pattern;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.io.IOException;
+import java.io.File;
 
 /**
  * Builder is invoked when web application initialization process is starting. It builds sequence of tests for this
@@ -44,7 +54,7 @@
  * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
  * @version $Revision: 6989 $
  */
-public abstract class PortletTestSuite implements ServletContextListener, ServletContextAttributeListener
+public class PortletTestSuite implements ServletContextListener, ServletContextAttributeListener
 {
 
    /** . */
@@ -56,7 +66,10 @@
    /** . */
    private PortletTestDriver driver;
 
-   protected PortletTestSuite()
+   /** . */
+   private ClassLoader loader;
+
+   public PortletTestSuite()
    {
    }
 
@@ -81,7 +94,7 @@
          }
          catch (Exception e)
          {
-            log.info("Cannot get application context path", e);
+            log.error("Cannot get application context path", e);
          }
 
          //
@@ -109,6 +122,30 @@
             }
 
             //
+            try
+            {
+               for (Class clazz : getClasses(event.getServletContext()))
+               {
+                  try
+                  {
+                     Constructor ctor = clazz.getConstructor(PortletTest.class);
+                     PortletTest testCase = new PortletTest();
+                     ctor.newInstance(testCase);
+                     String testCaseName = clazz.getSimpleName();
+                     driver.addSequence(testCaseName, testCase);
+                  }
+                  catch (Exception e)
+                  {
+                     log.error("Cannot obtain test case constructor " + clazz, e);
+                  }
+               }
+            }
+            catch (IOException e)
+            {
+               log.error("Cannot get load test cases", e);
+            }
+
+            //
             driver.start();
 
             //
@@ -117,6 +154,98 @@
       }
    }
 
+   protected List<Class> getClasses(ServletContext ctx) throws IOException
+   {
+      ClassCollector collector = new ClassCollector(loader, ctx);
+      collector.collect();
+      return collector.classes;
+   }
+
+   private static class ClassCollector implements URLVisitor, URLFilter
+   {
+
+      /** . */
+      private List<Class> classes = new ArrayList<Class>();
+
+      /** . */
+      private LinkedList<String> packages = new LinkedList<String>();
+
+      /** . */
+      private ClassLoader loader;
+
+      /** . */
+      private URL classesURL;
+
+      public ClassCollector(ClassLoader loader, ServletContext ctx) throws MalformedURLException
+      {
+         this.loader = loader;
+
+         // Need to use that because tomcat use a jndi based implementation for resources that will not
+         // be accepted by the URLNavigator. 2 solutions either rely on JBoss new VFS or implement jndi
+         // in URLNavigator
+         this.classesURL = new File(ctx.getRealPath("/WEB-INF/classes/")).toURL();
+      }
+
+      public void collect() throws IOException
+      {
+         URLNavigator.visit(classesURL, this, this);
+      }
+
+      public void startDir(URL url, String name)
+      {
+         packages.addLast(name);
+      }
+
+      public void endDir(URL url, String name)
+      {
+         packages.removeLast();
+      }
+
+      public void file(URL url, String name)
+      {
+         try
+         {
+            StringBuffer tmp = new StringBuffer();
+            Iterator<String> i = packages.iterator();
+
+            // Skip "classes"
+            i.next();
+
+            // Iterate package names
+            while (i.hasNext())
+            {
+               tmp.append(i.next());
+               tmp.append('.');
+            }
+
+            // Append class name
+            tmp.append(name.substring(0, name.length() - ".class".length()));
+
+
+            System.out.println("tmp = " + tmp);
+
+            //
+            String classname = tmp.toString();
+            Class clazz = loader.loadClass(classname);
+            classes.add(clazz);
+         }
+         catch (ClassNotFoundException e)
+         {
+            e.printStackTrace();
+         }
+      }
+
+      public boolean acceptFile(URL url)
+      {
+         return url.getFile().endsWith("TestCase.class");
+      }
+
+      public boolean acceptDir(URL url)
+      {
+         return true;
+      }
+   }
+
    public void attributeRemoved(ServletContextAttributeEvent event)
    {
 
@@ -129,6 +258,7 @@
 
    public void contextInitialized(ServletContextEvent sce)
    {
+      loader = Thread.currentThread().getContextClassLoader();
    }
 
    public void contextDestroyed(ServletContextEvent sce)

Added: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatchedRequestTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatchedRequestTestCase.java	                        (rev 0)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatchedRequestTestCase.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * 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.jsr168.tck.dispatcher;
+
+import org.jboss.portal.test.framework.portlet.PortletTest;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.assertEquals;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @portlet.specification assert="SPEC:124 - To include a servlet or a JSP, a portlet calls the include method of the
+ * PortletRequestDispatcher interface. The parameters to these methods must be the request and response arguments
+ * that were passed in via the render method of the Portlet interface."
+ * @portlet.specification assert="SPEC:125 - The portlet container must ensure that the servlet or JSP called through
+ * a PortletRequestDispatcher is called in the same thread as the PortletRequestDispatcher include invocation."
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DispatchedRequestTestCase
+{
+   public DispatchedRequestTestCase(PortletTest seq)
+   {
+      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
+            assertNotNull(dispatcher);
+            try
+            {
+               dispatcher.include(request, response);
+               Object o = UTP1.local.get();
+               assertEquals(Boolean.TRUE, o);
+            }
+            finally
+            {
+               UTP1.local.set(null);
+            }
+            return new EndTestResponse();
+         }
+      });
+
+      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            StringBuffer buffer = request.getRequestURL();
+            UTP1.local.set(buffer == null ? Boolean.TRUE : Boolean.FALSE);
+            return null;
+         }
+      });
+   }
+}

Deleted: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java	2007-11-06 10:17:40 UTC (rev 8832)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -1,751 +0,0 @@
-/******************************************************************************
- * 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.jsr168.tck.dispatcher;
-
-import org.jboss.portal.test.framework.portlet.PortletTest;
-import org.jboss.portal.test.framework.portlet.PortletTestDriver;
-import org.jboss.portal.test.framework.portlet.PortletTestSuite;
-import org.jboss.portal.test.framework.portlet.PortletTestContext;
-import org.jboss.portal.test.framework.portlet.actions.PortletActionTestAction;
-import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
-import org.jboss.portal.test.framework.portlet.actions.ServletServiceTestAction;
-import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
-import org.jboss.portal.test.portlet.framework.UTP1;
-import org.jboss.portal.test.portlet.framework.UTS1;
-import org.jboss.unit.driver.DriverResponse;
-import org.jboss.unit.driver.response.EndTestResponse;
-import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
-
-import static org.jboss.unit.api.Assert.*;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.Portlet;
-import javax.portlet.PortletException;
-import javax.portlet.PortletRequestDispatcher;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 7954 $
- */
-public class DispatcherSequenceBuilder extends PortletTestSuite
-{
-
-   public static final String SERVLET_A_URI = "/test-jsr168-dispatcher/universalServletA";
-   public static final String SERVLET_B_URI = "/test-jsr168-dispatcher/universalServletB";
-
-   /**
-    * @portlet.specification assert="SPEC:121 - The getRequestDispatcher method takes a String argument describing a
-    * path within the scope of the PortletContext of a portlet application. This path must begin with a ‘/’ and it is
-    * relative to the PortletContext root."
-    * @portlet.specification assert="SPEC:122 - The getNamedDispatcher method takes a String argument indicating the
-    * name of a servlet known to the PortletContext of the portlet application. If no resource can be resolved based on
-    * the given path or name the methods must return null"
-    */
-   public void createObtainingDispatcherCase(PortletTestDriver registry)
-   {
-      PortletTest seq = new PortletTest();
-      registry.addSequence("ObtainingDispatcher", seq);
-      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
-         {
-            UTP1 p = (UTP1)portlet;
-            //correct
-            PortletRequestDispatcher dispatcher = p.getPortletContext().getNamedDispatcher("UniversalServletA");
-            assertNotNull(dispatcher);
-
-            //incorrect
-            dispatcher = p.getPortletContext().getNamedDispatcher("FAKE_NAME_SERVLET");
-            assertNull(dispatcher);
-
-            //incorrect
-            dispatcher = p.getPortletContext().getNamedDispatcher("/");
-            assertNull(dispatcher);
-
-            //incorrect
-            dispatcher = p.getPortletContext().getNamedDispatcher("/universalServletA");
-            assertNull(dispatcher);
-
-            //incorrect
-            dispatcher = p.getPortletContext().getRequestDispatcher("UniversalServletA");
-            assertNull(dispatcher);
-
-            //incorrect
-            dispatcher = p.getPortletContext().getRequestDispatcher("universalServletA");
-            assertNull(dispatcher);
-
-            //incorrect
-            //dispatcher = getPortletContext().getRequestDispatcher("/UniversalServletA");
-            //assertNull(dispatcher);
-
-            //incorrect
-            //dispatcher = getPortletContext().getRequestDispatcher("/");
-            //assertNull(dispatcher);
-
-            //correct
-            dispatcher = p.getPortletContext().getRequestDispatcher("/universalServletA");
-            assertNotNull(dispatcher);
-            return new EndTestResponse();
-         }
-      });
-   }
-
-   /**
-    * @portlet.specification assert="SPEC:123 - The parameters associated with a PortletRequestDispatcher are scoped to
-    * apply only for the duration of the include call."
-    */
-   public void createQueryStringInRequestDispatcherCase(PortletTestDriver registry)
-   {
-      PortletTest seq = new PortletTest();
-      registry.addSequence("QueryStringInRequestDispatcher", seq);
-
-      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
-         {
-            return new InvokeGetResponse(response.createActionURL().toString());
-         }
-      });
-
-      seq.addAction(1, UTP1.ACTION_JOINPOINT, new PortletActionTestAction()
-      {
-         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context)
-         {
-            //set some render params to test them in dispatcher include (precedense)
-            response.setRenderParameter("key1", "differentValue");
-            response.setRenderParameter("key3", "k3value1");
-         }
-      });
-
-      seq.addAction(1, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-         {
-            String path = "/universalServletA";
-            path += "?key1=k1value1&key2=k2value1";
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher(path);
-            assertNotNull(dispatcher);
-
-            dispatcher.include(request, response);
-
-            //assert that params from query string doesn't last longer then in include call
-            assertEquals("differentValue", request.getParameter("key1"));
-            assertNull(request.getParameter("key2"));
-            return new EndTestResponse();
-         }
-      });
-
-      seq.addAction(1, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            assertEquals("k1value1", request.getParameter("key1"));
-            assertEquals("k2value1", request.getParameter("key2"));
-            assertEquals("k3value1", request.getParameter("key3"));
-            return null;
-         }
-      });
-   }
-
-   /**
-    * @portlet.specification assert="SPEC:124 - To include a servlet or a JSP, a portlet calls the include method of the
-    * PortletRequestDispatcher interface. The parameters to these methods must be the request and response arguments
-    * that were passed in via the render method of the Portlet interface."
-    * @portlet.specification assert="SPEC:125 - The portlet container must ensure that the servlet or JSP called through
-    * a PortletRequestDispatcher is called in the same thread as the PortletRequestDispatcher include invocation."
-    */
-   public void createDispatchedRequestCase(PortletTestDriver registry)
-   {
-      PortletTest seq = new PortletTest();
-      registry.addSequence("DispatchedRequest", seq);
-
-      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-         {
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
-            assertNotNull(dispatcher);
-            try
-            {
-               dispatcher.include(request, response);
-               Object o = UTP1.local.get();
-               assertEquals(Boolean.TRUE, o);
-            }
-            finally
-            {
-               UTP1.local.set(null);
-            }
-            return new EndTestResponse();
-         }
-      });
-
-      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            StringBuffer buffer = request.getRequestURL();
-            UTP1.local.set(buffer == null ? Boolean.TRUE : Boolean.FALSE);
-            return null;
-         }
-      });
-   }
-
-
-   /**
-    * @portlet.specification assert="SPEC:126 - Servlets and JSPs included from portlets must be handled as HTTP GET
-    * requests."
-    */
-   public void createGETMethodCase(PortletTestDriver registry)
-   {
-      PortletTest seq = new PortletTest();
-      registry.addSequence("GETMethod", seq);
-
-      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-         {
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
-            assertNotNull(dispatcher);
-
-
-            dispatcher.include(request, response);
-
-            //assert that servlet handle this as GET
-            assertEquals(Boolean.TRUE, (Boolean)UTP1.local.get());
-            return new EndTestResponse();
-         }
-      });
-
-      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            if (request.getMethod().equals("GET"))
-            {
-               UTP1.local.set(Boolean.TRUE);
-            }
-            return null;
-         }
-      });
-   }
-
-   /**
-    * @portlet.specification assert="SPEC:127 - Except for servlets obtained by using the getNamedDispatcher method, a
-    * servlet or JSP being used from within an include call has access to the path used to obtain the
-    * PortletRequestDispatcher. The following request attributes must be set: javax.servlet.include.request_uri,
-    * javax.servlet.include.context_path javax.servlet.include.servlet_path, javax.servlet.include.path_info,
-    * javax.servlet.include.query_string"
-    */
-   public void createIncludedRequestParametersCase(PortletTestDriver registry)
-   {
-      PortletTest seq = new PortletTest();
-      registry.addSequence("IncludedRequestParameters", seq);
-      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-         {
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA/pathinfo?foo=bar");
-            assertNotNull(dispatcher);
-
-            //assert that servlet HAS access to specific request attributes
-            try
-            {
-               dispatcher.include(request, response);
-               assertEquals("/test-jsr168-dispatcher/universalServletA/pathinfo", UTP1.local1.get());
-               assertEquals("/test-jsr168-dispatcher", UTP1.local2.get());
-               assertEquals("/universalServletA", UTP1.local3.get());
-               assertEquals("/pathinfo", UTP1.local4.get());
-               assertEquals("foo=bar", UTP1.local5.get());
-            }
-            finally
-            {
-               UTP1.local1.set(null);
-               UTP1.local2.set(null);
-               UTP1.local3.set(null);
-               UTP1.local4.set(null);
-               UTP1.local5.set(null);
-            }
-
-            //
-            dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
-            assertNotNull(dispatcher);
-
-            // Assert that servlet has NO access to specific request attributes
-            // it shouldn't access that attributes because getNamedDispatcher was used
-            try
-            {
-               dispatcher.include(request, response);
-               assertNull(UTP1.local1.get());
-               assertNull(UTP1.local2.get());
-               assertNull(UTP1.local3.get());
-               assertNull(UTP1.local4.get());
-               assertNull(UTP1.local5.get());
-            }
-            finally
-            {
-               UTP1.local1.set(null);
-               UTP1.local2.set(null);
-               UTP1.local3.set(null);
-               UTP1.local4.set(null);
-               UTP1.local5.set(null);
-            }
-
-            return new EndTestResponse();
-         }
-      });
-
-      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            UTP1.local1.set(request.getAttribute("javax.servlet.include.request_uri"));
-            UTP1.local2.set(request.getAttribute("javax.servlet.include.context_path"));
-            UTP1.local3.set(request.getAttribute("javax.servlet.include.servlet_path"));
-            UTP1.local4.set(request.getAttribute("javax.servlet.include.path_info"));
-            UTP1.local5.set(request.getAttribute("javax.servlet.include.query_string"));
-            return null;
-         }
-      });
-
-   }
-
-   /**
-    * @portlet.specification assert="SPEC:128 - javax.portlet.config, javax.portlet.request, javax.portlet.response.
-    * These attributes must be the same Portlet API objects accessible to the portlet doing the include call."
-    */
-   public void createIncludedRequestAttributesCase(PortletTestDriver registry)
-   {
-      PortletTest seq = new PortletTest();
-      registry.addSequence("IncludedRequestAttributes", seq);
-      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-         {
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA");
-            assertNotNull(dispatcher);
-            dispatcher.include(request, response);
-            //assert that servlet has access to correct objects via attributes
-            assertAttributes((AbstractUniversalTestPortlet)portlet, request, response);
-
-            dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
-            assertNotNull(dispatcher);
-            dispatcher.include(request, response);
-            //assert that servlet has access to correct objects via attributes
-            assertAttributes((AbstractUniversalTestPortlet)portlet, request, response);
-
-            return new EndTestResponse();
-
-         }
-
-         public void assertAttributes(AbstractUniversalTestPortlet portlet, RenderRequest request, RenderResponse response)
-         {
-            try
-            {
-               assertNotNull(UTP1.local1.get());
-               assertNotNull(UTP1.local2.get());
-               assertNotNull(UTP1.local3.get());
-
-               assertEquals(UTP1.local1.get(), portlet.getPortletConfig());
-               assertEquals(UTP1.local2.get(), request);
-               assertEquals(UTP1.local3.get(), response);
-
-            }
-            finally
-            {
-               UTP1.local1.set(null);
-               UTP1.local2.set(null);
-               UTP1.local3.set(null);
-            }
-         }
-      });
-
-      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            UTP1.local1.set(request.getAttribute("javax.portlet.config"));
-            UTP1.local2.set(request.getAttribute("javax.portlet.request"));
-            UTP1.local3.set(request.getAttribute("javax.portlet.response"));
-            return null;
-         }
-      });
-   }
-
-   /**
-    * @portlet.specification assert="SPEC:129 - The following methods of the HttpServletRequest must return null:
-    * getProtocol, getRemoteAddr, getRemoteHost, getRealPath, and getRequestURL."
-    * @portlet.specification assert="SPEC:130 - The following methods of the HttpServletRequest must return the path and
-    * query string information used to obtain the PortletRequestDispatcher object: getPathInfo, getPathTranslated,
-    * getQueryString, getRequestURI and getServletPath"
-    * @portlet.specification assert="SPEC:131 - The following methods of the HttpServletRequest must be equivalent to
-    * the methods of the PortletRequest of similar name: getScheme, getServerName,getServerPort, getAttribute,
-    * getAttributeNames, setAttribute,removeAttribute, getLocale, getLocales, isSecure, getAuthType, getContextPath,
-    * getRemoteUser, getUserPrincipal, getRequestedSessionId, isRequestedSessionIdValid"
-    * @portlet.specification assert="SPEC:132 - The following methods of the HttpServletRequest must be equivalent to
-    * the methods of the PortletRequest of similar name with the provision defined in PLT.16.1.1 Query Strings in
-    * Request Dispatcher Paths Section: getParameter, getParameterNames, getParameterValues and getParameterMap."
-    * @portlet.specification assert="SPEC:133 - The following methods of the HttpServletRequest must do no operations
-    * and return null: getCharacterEncoding, setCharacterEncoding, getContentType, getInputStream and getReader."
-    * @portlet.specification assert="SPEC:134 - The getContentLength method of the HttpServletRequest must return 0."
-    * @portlet.specification assert="SPEC:137 - The getMethod method of the HttpServletRequest must always return
-    * ‘GET’"
-    */
-   public void createRequestObjectCase(PortletTestDriver registry)
-   {
-      PortletTest seq = new PortletTest();
-      registry.addSequence("RequestObject", seq);
-      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-         {
-            //we dispatch to servlet and assertions will be done there
-            String queryString = "?key1=k1value1&key2=k2value1";
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA" + queryString);
-            response.setContentType("text/html");
-            dispatcher.include(request, response);
-            return null;
-         }
-      });
-
-
-      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            //we get this object to assert some of it's method compare wieth http request methods
-            RenderRequest portletRequest = (RenderRequest)request.getAttribute("javax.portlet.request");
-
-            assertNotNull(portletRequest);
-
-            //SPEC:129
-            assertNull(request.getProtocol());
-            assertNull(request.getRemoteAddr());
-            assertNull(request.getRemoteHost());
-            assertNull(request.getRealPath("blah"));
-            assertNull(request.getRequestURL());
-
-            //SPEC:130
-            assertEquals(null, request.getPathInfo());
-            //TODO:I'm not sure what this should return - but it's not implemented now so it fails
-            //assertEquals("",request.getPathTranslated());
-            assertEquals("key1=k1value1&key2=k2value1", request.getQueryString());
-            //assertEquals("/requestObjectServlet",request.getRequestURI());
-            assertEquals("/universalServletA", request.getServletPath());
-
-            //SPEC:131
-            assertEquals(portletRequest.getScheme(), request.getScheme());
-            assertEquals(portletRequest.getServerName(), request.getServerName());
-            assertEquals(portletRequest.getServerPort(), request.getServerPort());
-
-            request.setAttribute("key1", "k1atrr1");
-            request.setAttribute("key2", "k2attr2");
-            List attrNames = new LinkedList();
-            Enumeration attrEnum = request.getAttributeNames();
-            while (attrEnum.hasMoreElements())
-            {
-               attrNames.add(attrEnum.nextElement());
-            }
-            assertNotNull(request.getAttribute("key1"));
-            assertNotNull(request.getAttribute("key2"));
-
-            assertTrue(attrNames.contains("key1"));
-            assertTrue(attrNames.contains("key2"));
-
-            request.removeAttribute("key1");
-            assertNull(request.getAttribute("key1"));
-            assertNotNull(request.getAttribute("key2"));
-
-            assertEquals(portletRequest.getLocale(), request.getLocale());
-
-            List portletLocales = new LinkedList();
-            List servletLocales = new LinkedList();
-            Enumeration pl = portletRequest.getLocales();
-            while (pl.hasMoreElements())
-            {
-               portletLocales.add(pl.nextElement());
-            }
-            Enumeration sl = request.getLocales();
-            while (sl.hasMoreElements())
-            {
-               servletLocales.add(sl.nextElement());
-            }
-
-            assertTrue(portletLocales.equals(servletLocales));
-
-            assertEquals(portletRequest.isSecure(), request.isSecure());
-            assertEquals(portletRequest.getAuthType(), request.getAuthType());
-            assertEquals(portletRequest.getContextPath(), request.getContextPath());
-            assertEquals(portletRequest.getRemoteUser(), request.getRemoteUser());
-            assertEquals(portletRequest.getUserPrincipal(), request.getUserPrincipal());
-            assertEquals(portletRequest.getRequestedSessionId(), request.getRequestedSessionId());
-            assertEquals(portletRequest.isRequestedSessionIdValid(), request.isRequestedSessionIdValid());
-
-            //SPEC:132
-            //in this assertions we use parameters passed in query string of dispatcher
-            List paramNames = new LinkedList();
-            Enumeration paramEnum = request.getParameterNames();
-            while (paramEnum.hasMoreElements())
-            {
-               paramNames.add(paramEnum.nextElement());
-            }
-            assertTrue(paramNames.contains("key1"));
-            assertTrue(paramNames.contains("key2"));
-
-            assertEquals("k1value1", request.getParameter("key1"));
-            assertEquals(new String[]{"k1value1"}, request.getParameterValues("key1"));
-
-            Map paramNamesMap = request.getParameterMap();
-            assertTrue(paramNamesMap.containsKey("key1"));
-            assertTrue(paramNamesMap.containsKey("key2"));
-
-            //SPEC:133
-            request.setCharacterEncoding("utf8");
-            assertNull(request.getCharacterEncoding());
-            assertNull(request.getContentType());
-            assertNull(request.getInputStream());
-            assertNull(request.getReader());
-
-            //SPEC:134
-            assertEquals(0, request.getContentLength());
-
-            //SPEC:137
-            assertEquals("GET", request.getMethod());
-            return new EndTestResponse();
-         }
-      });
-   }
-
-   /**
-    * @portlet.specification assert="SPEC:138 - The following methods of the HttpServletResponse must return
-    * null:encodeRedirectURL and encodeRedirectUrl"
-    * @portlet.specification assert="SPEC:141 - The getLocale method of the HttpServletResponse must be based on the
-    * getLocale method of the RenderResponse."
-    */
-   public void createResponseObjectCase(PortletTestDriver registry)
-   {
-      PortletTest seq = new PortletTest();
-      registry.addSequence("ResponseObject", seq);
-      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-         {
-            //we dispatch to servlet and assertions will be done there
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA");
-            //hack for testing dispatched servlet
-            response.setContentType("text/html");
-            dispatcher.include(request, response);
-            return null;
-         }
-      });
-
-      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            //we get this object to assert some of it's method compare wieth http request methods
-            RenderResponse portletResponse = (RenderResponse)request.getAttribute("javax.portlet.response");
-
-            assertNotNull(portletResponse);
-
-            //SPEC:138
-            assertNull(response.encodeRedirectURL("blah"));
-            assertNull(response.encodeRedirectUrl("blah"));
-
-            //not defined spec assert
-            assertEquals(false, response.containsHeader("blah"));
-
-            //SPEC:141
-            assertEquals(portletResponse.getLocale(), response.getLocale());
-            return new EndTestResponse();
-         }
-      });
-   }
-
-   /**
-    * @portlet.specification assert="SPEC:142 - If the servlet or JSP that is the target of a request dispatcher throws
-    * a runtime exception or a checked exception of type IOException, it must be propagated to the calling portlet."
-    * @portlet.specification assert="SPEC:143 - All other exceptions, including a ServletException, must be wrapped with
-    * a PortletException. The root cause of the exception must be set to the original exception before being
-    * propagated."
-    */
-   public void createErrorHandlingCase(PortletTestDriver registry)
-   {
-      PortletTest seq = new PortletTest();
-      registry.addSequence("ErrorHandling", seq);
-
-      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-         {
-
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
-            assertNotNull(dispatcher);
-            try
-            {
-               dispatcher.include(request, response);
-               fail();
-            }
-            catch (RuntimeException e)
-            {
-               //expected
-            }
-
-            return new InvokeGetResponse(response.createRenderURL().toString());
-         }
-      });
-
-      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            return null;
-         }
-
-         public DriverResponse execute(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            //SPEC:142 - RuntimeException
-            throw new RuntimeException();
-         }
-      });
-
-      seq.addAction(1, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException
-         {
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
-            assertNotNull(dispatcher);
-            try
-            {
-               dispatcher.include(request, response);
-               fail();
-            }
-            catch (IOException e)
-            {
-               //expected
-            }
-
-            return new InvokeGetResponse(response.createRenderURL().toString());
-         }
-      });
-
-      seq.addAction(1, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            return null;
-         }
-
-         public DriverResponse execute(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            //SPEC:142 - checked exception of type IOException
-            throw new IOException();
-         }
-      });
-
-      seq.addAction(2, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException
-         {
-
-            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
-            assertNotNull(dispatcher);
-            try
-            {
-               dispatcher.include(request, response);
-               fail();
-            }
-            catch (PortletException e)
-            {
-               //expected
-               if (!(e.getCause() instanceof ServletException))
-               {
-                  fail();
-               }
-            }
-            return new InvokeGetResponse(response.createRenderURL().toString());
-         }
-      });
-
-      seq.addAction(2, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            return null;
-         }
-
-         public DriverResponse execute(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            //SPEC:143 - ServletException
-            throw new ServletException();
-         }
-      });
-
-      seq.addAction(3, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
-      {
-         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException
-         {
-            /*PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
-               assertNotNull(dispatcher);
-               try
-               {
-                  dispatcher.include(request,response);
-                  fail();
-               }
-               catch(Error e)
-               {
-                  //expected
-               }*/
-
-            return new EndTestResponse();
-         }
-      });
-
-      seq.addAction(3, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
-      {
-         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            return null;
-         }
-
-         public DriverResponse execute(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
-         {
-            //SPEC:143 - 'other' exception
-            throw new Error();
-         }
-      });
-
-   }
-
-}

Modified: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherTestSuite.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherTestSuite.java	2007-11-06 10:17:40 UTC (rev 8832)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherTestSuite.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -22,106 +22,13 @@
  ******************************************************************************/
 package org.jboss.portal.test.portlet.jsr168.tck.dispatcher;
 
+import org.jboss.portal.test.framework.portlet.PortletTestSuite;
+
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
  * @version $Revision: 5510 $
  */
-public class DispatcherTestSuite
+public class DispatcherTestSuite extends PortletTestSuite
 {
-   public static void suite()
-   {
-//      TestSuite suite = new TestSuite("test-jsr168-dispatcher.war");
-//
-//      /**
-//       * SPEC:121 Testable=true Section=PLT.16.1
-//       * SPEC:122 Testable=true Section=PLT.16.1
-//       * - ObtainingDispatcherPortlet
-//       * - ObtainingDispatcherServlet
-//       */
-//      suite.addTest(new TestCase("ObtainingDispatcher"));
-//
-//      /**
-//       * SPEC:123 Testable= true Section=PLT.16.1.1
-//       * - QueryStringInRequestDispatcherPortlet
-//       * - QueryStringInRequestDispatcherServlet
-//       */
-//      suite.addTest(new TestCase("QueryStringInRequestDispatcher"));
-//
-//      /**
-//       * SPEC:124 Testable=true Section=PLT.16.2
-//       * SPEC:125 Testable=true Section=PLT.16.2
-//       * - DispatchedRequestPortlet
-//       * - DispatchedRequestServlet
-//       */
-//      suite.addTest(new TestCase("DispatchedRequest"));
-//
-//      /**
-//       * SPEC:126 Testable=true Section=PLT.16.3
-//       * - GETMethodPortlet
-//       * - GETMethodServlet
-//       */
-//      suite.addTest(new TestCase("GETMethod"));
-//
-//      /**
-//       * SPEC:127 Testable=true Section=PLT.16.3.1
-//       * - IncludedRequestParametersPortlet
-//       * - IncludedRequestParametersDispatchedServlet
-//       * - IncludedRequestParametersNamedDispatchedServlet
-//       */
-//      suite.addTest(new TestCase("IncludedRequestParameters"));
-//
-//      /**
-//       * SPEC:128 Testable=true Section=PLT.16.3.2
-//       * - IncludedRequestAttributesPortlet
-//       * - IncludedRequestAttributesDispatchedServlet
-//       */
-//      suite.addTest(new TestCase("IncludedRequestAttributes"));
-//
-//      /**
-//       * SPEC:129 Testable=true Section=PLT.16.3.3
-//       * SPEC:130 Testable=true Section=PLT.16.3.3
-//       * SPEC:131 Testable=true Section=PLT.16.3.3
-//       * SPEC:132 Testable=true Section=PLT.16.3.3
-//       * SPEC:133 Testable=true Section=PLT.16.3.3
-//       * SPEC:134 Testable=true Section=PLT.16.3.3
-//       * SPEC:137 Testable=true Section=PLT.16.3.3
-//       * - RequestObjectPortlet
-//       * - RequestObjectServlet
-//       */
-//      suite.addTest(new TestCase("RequestObject"));
-//
-//      /**
-//       * SPEC:135 Testable=true Section=PLT.16.3.3
-//       * SPEC:136 Testable=true Section=PLT.16.3.3
-//       * POSTPONED
-//       */
-//
-//      /**
-//       * SPEC:138 Testable=true Section= PLT.16.3.3
-//       * SPEC:141 Testable=true Section= PLT.16.3.3
-//       */
-//      suite.addTest(new TestCase("ResponseObject"));
-//
-//      /**
-//       * SPEC:139 Testable=true Section= PLT.16.3.3
-//       * NOT DONE YET
-//       */
-//
-//      /**
-//       * SPEC:140 Testable=false(impl) Section= PLT.16.3.3
-//       * Testable=false(impl)!
-//       */
-//
-//      /**
-//       * SPEC:142 Testable=true Section=PLT.16.3.4
-//       * SPEC:143 Testable=true Section=PLT.16.3.4
-//       * - ErrorHandlingPortlet
-//       * - ErrorHandlingServlet
-//       * - SampleException
-//       */
-//      suite.addTest(new TestCase("ErrorHandling"));
-//
-//      return suite;
-   }
 }

Added: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ErrorHandlingTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ErrorHandlingTestCase.java	                        (rev 0)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ErrorHandlingTestCase.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -0,0 +1,205 @@
+/******************************************************************************
+ * 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.jsr168.tck.dispatcher;
+
+import org.jboss.portal.test.framework.portlet.PortletTest;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.fail;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @portlet.specification assert="SPEC:142 - If the servlet or JSP that is the target of a request dispatcher throws
+ * a runtime exception or a checked exception of type IOException, it must be propagated to the calling portlet."
+ * @portlet.specification assert="SPEC:143 - All other exceptions, including a ServletException, must be wrapped with
+ * a PortletException. The root cause of the exception must be set to the original exception before being
+ * propagated."
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ErrorHandlingTestCase
+{
+
+   public ErrorHandlingTestCase(PortletTest seq)
+   {
+      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
+            assertNotNull(dispatcher);
+            try
+            {
+               dispatcher.include(request, response);
+               fail();
+            }
+            catch (RuntimeException e)
+            {
+               //expected
+            }
+
+            return new InvokeGetResponse(response.createRenderURL().toString());
+         }
+      });
+
+      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            return null;
+         }
+
+         public DriverResponse execute(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            //SPEC:142 - RuntimeException
+            throw new RuntimeException();
+         }
+      });
+
+      seq.addAction(1, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException
+         {
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
+            assertNotNull(dispatcher);
+            try
+            {
+               dispatcher.include(request, response);
+               fail();
+            }
+            catch (IOException e)
+            {
+               //expected
+            }
+
+            return new InvokeGetResponse(response.createRenderURL().toString());
+         }
+      });
+
+      seq.addAction(1, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            return null;
+         }
+
+         public DriverResponse execute(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            //SPEC:142 - checked exception of type IOException
+            throw new IOException();
+         }
+      });
+
+      seq.addAction(2, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException
+         {
+
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
+            assertNotNull(dispatcher);
+            try
+            {
+               dispatcher.include(request, response);
+               fail();
+            }
+            catch (PortletException e)
+            {
+               //expected
+               if (!(e.getCause() instanceof ServletException))
+               {
+                  fail();
+               }
+            }
+            return new InvokeGetResponse(response.createRenderURL().toString());
+         }
+      });
+
+      seq.addAction(2, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            return null;
+         }
+
+         public DriverResponse execute(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            //SPEC:143 - ServletException
+            throw new ServletException();
+         }
+      });
+
+      seq.addAction(3, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException
+         {
+            /*PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
+               assertNotNull(dispatcher);
+               try
+               {
+                  dispatcher.include(request,response);
+                  fail();
+               }
+               catch(Error e)
+               {
+                  //expected
+               }*/
+
+            return new EndTestResponse();
+         }
+      });
+
+      seq.addAction(3, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            return null;
+         }
+
+         public DriverResponse execute(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            //SPEC:143 - 'other' exception
+            throw new Error();
+         }
+      });
+   }
+}

Added: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/GETMethodTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/GETMethodTestCase.java	                        (rev 0)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/GETMethodTestCase.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * 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.jsr168.tck.dispatcher;
+
+import org.jboss.portal.test.framework.portlet.PortletTest;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.assertEquals;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @portlet.specification assert="SPEC:126 - Servlets and JSPs included from portlets must be handled as HTTP GET
+ * requests."
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GETMethodTestCase
+{
+
+   public GETMethodTestCase(PortletTest seq)
+   {
+      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
+            assertNotNull(dispatcher);
+
+
+            dispatcher.include(request, response);
+
+            //assert that servlet handle this as GET
+            assertEquals(Boolean.TRUE, (Boolean)UTP1.local.get());
+            return new EndTestResponse();
+         }
+      });
+
+      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            if (request.getMethod().equals("GET"))
+            {
+               UTP1.local.set(Boolean.TRUE);
+            }
+            return null;
+         }
+      });
+   }
+}

Added: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/IncludedRequestAttributesTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/IncludedRequestAttributesTestCase.java	                        (rev 0)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/IncludedRequestAttributesTestCase.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -0,0 +1,112 @@
+/******************************************************************************
+ * 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.jsr168.tck.dispatcher;
+
+import org.jboss.portal.test.framework.portlet.PortletTest;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.assertEquals;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @portlet.specification assert="SPEC:128 - javax.portlet.config, javax.portlet.request, javax.portlet.response.
+ * These attributes must be the same Portlet API objects accessible to the portlet doing the include call."
+ * 
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IncludedRequestAttributesTestCase
+{
+   public IncludedRequestAttributesTestCase(PortletTest seq)
+   {
+      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA");
+            assertNotNull(dispatcher);
+            dispatcher.include(request, response);
+            //assert that servlet has access to correct objects via attributes
+            assertAttributes((AbstractUniversalTestPortlet)portlet, request, response);
+
+            dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
+            assertNotNull(dispatcher);
+            dispatcher.include(request, response);
+            //assert that servlet has access to correct objects via attributes
+            assertAttributes((AbstractUniversalTestPortlet)portlet, request, response);
+
+            return new EndTestResponse();
+
+         }
+
+         public void assertAttributes(AbstractUniversalTestPortlet portlet, RenderRequest request, RenderResponse response)
+         {
+            try
+            {
+               assertNotNull(UTP1.local1.get());
+               assertNotNull(UTP1.local2.get());
+               assertNotNull(UTP1.local3.get());
+
+               assertEquals(UTP1.local1.get(), portlet.getPortletConfig());
+               assertEquals(UTP1.local2.get(), request);
+               assertEquals(UTP1.local3.get(), response);
+
+            }
+            finally
+            {
+               UTP1.local1.set(null);
+               UTP1.local2.set(null);
+               UTP1.local3.set(null);
+            }
+         }
+      });
+
+      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            UTP1.local1.set(request.getAttribute("javax.portlet.config"));
+            UTP1.local2.set(request.getAttribute("javax.portlet.request"));
+            UTP1.local3.set(request.getAttribute("javax.portlet.response"));
+            return null;
+         }
+      });
+   }
+}

Added: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/IncludedRequestParametersTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/IncludedRequestParametersTestCase.java	                        (rev 0)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/IncludedRequestParametersTestCase.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -0,0 +1,130 @@
+/******************************************************************************
+ * 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.jsr168.tck.dispatcher;
+
+import org.jboss.portal.test.framework.portlet.PortletTest;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.assertEquals;
+import static org.jboss.unit.api.Assert.assertNull;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @portlet.specification assert="SPEC:127 - Except for servlets obtained by using the getNamedDispatcher method, a
+ * servlet or JSP being used from within an include call has access to the path used to obtain the
+ * PortletRequestDispatcher. The following request attributes must be set: javax.servlet.include.request_uri,
+ * javax.servlet.include.context_path javax.servlet.include.servlet_path, javax.servlet.include.path_info,
+ * javax.servlet.include.query_string"
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IncludedRequestParametersTestCase
+{
+   public IncludedRequestParametersTestCase(PortletTest seq)
+   {
+      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA/pathinfo?foo=bar");
+            assertNotNull(dispatcher);
+
+            //assert that servlet HAS access to specific request attributes
+            try
+            {
+               dispatcher.include(request, response);
+               assertEquals("/test-jsr168-dispatcher/universalServletA/pathinfo", UTP1.local1.get());
+               assertEquals("/test-jsr168-dispatcher", UTP1.local2.get());
+               assertEquals("/universalServletA", UTP1.local3.get());
+               assertEquals("/pathinfo", UTP1.local4.get());
+               assertEquals("foo=bar", UTP1.local5.get());
+            }
+            finally
+            {
+               UTP1.local1.set(null);
+               UTP1.local2.set(null);
+               UTP1.local3.set(null);
+               UTP1.local4.set(null);
+               UTP1.local5.set(null);
+            }
+
+            //
+            dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
+            assertNotNull(dispatcher);
+
+            // Assert that servlet has NO access to specific request attributes
+            // it shouldn't access that attributes because getNamedDispatcher was used
+            try
+            {
+               dispatcher.include(request, response);
+               assertNull(UTP1.local1.get());
+               assertNull(UTP1.local2.get());
+               assertNull(UTP1.local3.get());
+               assertNull(UTP1.local4.get());
+               assertNull(UTP1.local5.get());
+            }
+            finally
+            {
+               UTP1.local1.set(null);
+               UTP1.local2.set(null);
+               UTP1.local3.set(null);
+               UTP1.local4.set(null);
+               UTP1.local5.set(null);
+            }
+
+            return new EndTestResponse();
+         }
+      });
+
+      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            UTP1.local1.set(request.getAttribute("javax.servlet.include.request_uri"));
+            UTP1.local2.set(request.getAttribute("javax.servlet.include.context_path"));
+            UTP1.local3.set(request.getAttribute("javax.servlet.include.servlet_path"));
+            UTP1.local4.set(request.getAttribute("javax.servlet.include.path_info"));
+            UTP1.local5.set(request.getAttribute("javax.servlet.include.query_string"));
+            return null;
+         }
+      });
+   }
+}

Added: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ObtainingDispatcherTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ObtainingDispatcherTestCase.java	                        (rev 0)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ObtainingDispatcherTestCase.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * 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.jsr168.tck.dispatcher;
+
+import org.jboss.portal.test.framework.portlet.PortletTestDriver;
+import org.jboss.portal.test.framework.portlet.PortletTest;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.assertNull;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletRequestDispatcher;
+
+/**
+ * @portlet.specification assert="SPEC:121 - The getRequestDispatcher method takes a String argument describing a
+ * path within the scope of the PortletContext of a portlet application. This path must begin with a ‘/’ and it is
+ * relative to the PortletContext root."
+ * @portlet.specification assert="SPEC:122 - The getNamedDispatcher method takes a String argument indicating the
+ * name of a servlet known to the PortletContext of the portlet application. If no resource can be resolved based on
+ * the given path or name the methods must return null"
+ * 
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ObtainingDispatcherTestCase
+{
+   public ObtainingDispatcherTestCase(PortletTest seq)
+   {
+      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+         {
+            UTP1 p = (UTP1)portlet;
+            //correct
+            PortletRequestDispatcher dispatcher = p.getPortletContext().getNamedDispatcher("UniversalServletA");
+            assertNotNull(dispatcher);
+
+            //incorrect
+            dispatcher = p.getPortletContext().getNamedDispatcher("FAKE_NAME_SERVLET");
+            assertNull(dispatcher);
+
+            //incorrect
+            dispatcher = p.getPortletContext().getNamedDispatcher("/");
+            assertNull(dispatcher);
+
+            //incorrect
+            dispatcher = p.getPortletContext().getNamedDispatcher("/universalServletA");
+            assertNull(dispatcher);
+
+            //incorrect
+            dispatcher = p.getPortletContext().getRequestDispatcher("UniversalServletA");
+            assertNull(dispatcher);
+
+            //incorrect
+            dispatcher = p.getPortletContext().getRequestDispatcher("universalServletA");
+            assertNull(dispatcher);
+
+            //incorrect
+            //dispatcher = getPortletContext().getRequestDispatcher("/UniversalServletA");
+            //assertNull(dispatcher);
+
+            //incorrect
+            //dispatcher = getPortletContext().getRequestDispatcher("/");
+            //assertNull(dispatcher);
+
+            //correct
+            dispatcher = p.getPortletContext().getRequestDispatcher("/universalServletA");
+            assertNotNull(dispatcher);
+            return new EndTestResponse();
+         }
+      });
+   }
+}

Added: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/QueryStringInRequestDispatcherTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/QueryStringInRequestDispatcherTestCase.java	                        (rev 0)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/QueryStringInRequestDispatcherTestCase.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * 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.jsr168.tck.dispatcher;
+
+import org.jboss.portal.test.framework.portlet.PortletTest;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.actions.PortletActionTestAction;
+import org.jboss.portal.test.framework.portlet.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.assertEquals;
+import static org.jboss.unit.api.Assert.assertNull;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @portlet.specification assert="SPEC:123 - The parameters associated with a PortletRequestDispatcher are scoped to
+ * apply only for the duration of the include call."
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class QueryStringInRequestDispatcherTestCase
+{
+   public QueryStringInRequestDispatcherTestCase(PortletTest seq)
+   {
+      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+         {
+            return new InvokeGetResponse(response.createActionURL().toString());
+         }
+      });
+
+      seq.addAction(1, UTP1.ACTION_JOINPOINT, new PortletActionTestAction()
+      {
+         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context)
+         {
+            //set some render params to test them in dispatcher include (precedense)
+            response.setRenderParameter("key1", "differentValue");
+            response.setRenderParameter("key3", "k3value1");
+         }
+      });
+
+      seq.addAction(1, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            String path = "/universalServletA";
+            path += "?key1=k1value1&key2=k2value1";
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher(path);
+            assertNotNull(dispatcher);
+
+            dispatcher.include(request, response);
+
+            //assert that params from query string doesn't last longer then in include call
+            assertEquals("differentValue", request.getParameter("key1"));
+            assertNull(request.getParameter("key2"));
+            return new EndTestResponse();
+         }
+      });
+
+      seq.addAction(1, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            assertEquals("k1value1", request.getParameter("key1"));
+            assertEquals("k2value1", request.getParameter("key2"));
+            assertEquals("k3value1", request.getParameter("key3"));
+            return null;
+         }
+      });
+   }
+}

Added: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/RequestObjectTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/RequestObjectTestCase.java	                        (rev 0)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/RequestObjectTestCase.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -0,0 +1,200 @@
+/******************************************************************************
+ * 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.jsr168.tck.dispatcher;
+
+import org.jboss.portal.test.framework.portlet.PortletTest;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.assertNull;
+import static org.jboss.unit.api.Assert.assertEquals;
+import static org.jboss.unit.api.Assert.assertTrue;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Enumeration;
+import java.util.Map;
+
+/**
+ * @portlet.specification assert="SPEC:129 - The following methods of the HttpServletRequest must return null:
+ * getProtocol, getRemoteAddr, getRemoteHost, getRealPath, and getRequestURL."
+ * @portlet.specification assert="SPEC:130 - The following methods of the HttpServletRequest must return the path and
+ * query string information used to obtain the PortletRequestDispatcher object: getPathInfo, getPathTranslated,
+ * getQueryString, getRequestURI and getServletPath"
+ * @portlet.specification assert="SPEC:131 - The following methods of the HttpServletRequest must be equivalent to
+ * the methods of the PortletRequest of similar name: getScheme, getServerName,getServerPort, getAttribute,
+ * getAttributeNames, setAttribute,removeAttribute, getLocale, getLocales, isSecure, getAuthType, getContextPath,
+ * getRemoteUser, getUserPrincipal, getRequestedSessionId, isRequestedSessionIdValid"
+ * @portlet.specification assert="SPEC:132 - The following methods of the HttpServletRequest must be equivalent to
+ * the methods of the PortletRequest of similar name with the provision defined in PLT.16.1.1 Query Strings in
+ * Request Dispatcher Paths Section: getParameter, getParameterNames, getParameterValues and getParameterMap."
+ * @portlet.specification assert="SPEC:133 - The following methods of the HttpServletRequest must do no operations
+ * and return null: getCharacterEncoding, setCharacterEncoding, getContentType, getInputStream and getReader."
+ * @portlet.specification assert="SPEC:134 - The getContentLength method of the HttpServletRequest must return 0."
+ * @portlet.specification assert="SPEC:137 - The getMethod method of the HttpServletRequest must always return
+ * ‘GET’"
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RequestObjectTestCase
+{
+   public RequestObjectTestCase(PortletTest seq)
+   {
+      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            //we dispatch to servlet and assertions will be done there
+            String queryString = "?key1=k1value1&key2=k2value1";
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA" + queryString);
+            response.setContentType("text/html");
+            dispatcher.include(request, response);
+            return null;
+         }
+      });
+
+
+      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            //we get this object to assert some of it's method compare wieth http request methods
+            RenderRequest portletRequest = (RenderRequest)request.getAttribute("javax.portlet.request");
+
+            assertNotNull(portletRequest);
+
+            //SPEC:129
+            assertNull(request.getProtocol());
+            assertNull(request.getRemoteAddr());
+            assertNull(request.getRemoteHost());
+            assertNull(request.getRealPath("blah"));
+            assertNull(request.getRequestURL());
+
+            //SPEC:130
+            assertEquals(null, request.getPathInfo());
+            //TODO:I'm not sure what this should return - but it's not implemented now so it fails
+            //assertEquals("",request.getPathTranslated());
+            assertEquals("key1=k1value1&key2=k2value1", request.getQueryString());
+            //assertEquals("/requestObjectServlet",request.getRequestURI());
+            assertEquals("/universalServletA", request.getServletPath());
+
+            //SPEC:131
+            assertEquals(portletRequest.getScheme(), request.getScheme());
+            assertEquals(portletRequest.getServerName(), request.getServerName());
+            assertEquals(portletRequest.getServerPort(), request.getServerPort());
+
+            request.setAttribute("key1", "k1atrr1");
+            request.setAttribute("key2", "k2attr2");
+            List attrNames = new LinkedList();
+            Enumeration attrEnum = request.getAttributeNames();
+            while (attrEnum.hasMoreElements())
+            {
+               attrNames.add(attrEnum.nextElement());
+            }
+            assertNotNull(request.getAttribute("key1"));
+            assertNotNull(request.getAttribute("key2"));
+
+            assertTrue(attrNames.contains("key1"));
+            assertTrue(attrNames.contains("key2"));
+
+            request.removeAttribute("key1");
+            assertNull(request.getAttribute("key1"));
+            assertNotNull(request.getAttribute("key2"));
+
+            assertEquals(portletRequest.getLocale(), request.getLocale());
+
+            List portletLocales = new LinkedList();
+            List servletLocales = new LinkedList();
+            Enumeration pl = portletRequest.getLocales();
+            while (pl.hasMoreElements())
+            {
+               portletLocales.add(pl.nextElement());
+            }
+            Enumeration sl = request.getLocales();
+            while (sl.hasMoreElements())
+            {
+               servletLocales.add(sl.nextElement());
+            }
+
+            assertTrue(portletLocales.equals(servletLocales));
+
+            assertEquals(portletRequest.isSecure(), request.isSecure());
+            assertEquals(portletRequest.getAuthType(), request.getAuthType());
+            assertEquals(portletRequest.getContextPath(), request.getContextPath());
+            assertEquals(portletRequest.getRemoteUser(), request.getRemoteUser());
+            assertEquals(portletRequest.getUserPrincipal(), request.getUserPrincipal());
+            assertEquals(portletRequest.getRequestedSessionId(), request.getRequestedSessionId());
+            assertEquals(portletRequest.isRequestedSessionIdValid(), request.isRequestedSessionIdValid());
+
+            //SPEC:132
+            //in this assertions we use parameters passed in query string of dispatcher
+            List paramNames = new LinkedList();
+            Enumeration paramEnum = request.getParameterNames();
+            while (paramEnum.hasMoreElements())
+            {
+               paramNames.add(paramEnum.nextElement());
+            }
+            assertTrue(paramNames.contains("key1"));
+            assertTrue(paramNames.contains("key2"));
+
+            assertEquals("k1value1", request.getParameter("key1"));
+            assertEquals(new String[]{"k1value1"}, request.getParameterValues("key1"));
+
+            Map paramNamesMap = request.getParameterMap();
+            assertTrue(paramNamesMap.containsKey("key1"));
+            assertTrue(paramNamesMap.containsKey("key2"));
+
+            //SPEC:133
+            request.setCharacterEncoding("utf8");
+            assertNull(request.getCharacterEncoding());
+            assertNull(request.getContentType());
+            assertNull(request.getInputStream());
+            assertNull(request.getReader());
+
+            //SPEC:134
+            assertEquals(0, request.getContentLength());
+
+            //SPEC:137
+            assertEquals("GET", request.getMethod());
+            return new EndTestResponse();
+         }
+      });
+   }
+}

Added: modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ResponseObjectTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ResponseObjectTestCase.java	                        (rev 0)
+++ modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/ResponseObjectTestCase.java	2007-11-06 14:04:11 UTC (rev 8833)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * 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.jsr168.tck.dispatcher;
+
+import org.jboss.portal.test.framework.portlet.PortletTest;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.actions.ServletServiceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTS1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertNotNull;
+import static org.jboss.unit.api.Assert.assertNull;
+import static org.jboss.unit.api.Assert.assertEquals;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @portlet.specification assert="SPEC:138 - The following methods of the HttpServletResponse must return
+ * null:encodeRedirectURL and encodeRedirectUrl"
+ * @portlet.specification assert="SPEC:141 - The getLocale method of the HttpServletResponse must be based on the
+ * getLocale method of the RenderResponse."
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ResponseObjectTestCase
+{
+   public ResponseObjectTestCase(PortletTest seq)
+   {
+      seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
+      {
+         protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+         {
+            //we dispatch to servlet and assertions will be done there
+            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA");
+            //hack for testing dispatched servlet
+            response.setContentType("text/html");
+            dispatcher.include(request, response);
+            return null;
+         }
+      });
+
+      seq.addAction(0, UTS1.SERVICE_JOINPOINT, new ServletServiceTestAction()
+      {
+         protected DriverResponse run(Servlet servlet, HttpServletRequest request, HttpServletResponse response, PortletTestContext context) throws ServletException, IOException
+         {
+            //we get this object to assert some of it's method compare wieth http request methods
+            RenderResponse portletResponse = (RenderResponse)request.getAttribute("javax.portlet.response");
+
+            assertNotNull(portletResponse);
+
+            //SPEC:138
+            assertNull(response.encodeRedirectURL("blah"));
+            assertNull(response.encodeRedirectUrl("blah"));
+
+            //not defined spec assert
+            assertEquals(false, response.containsHeader("blah"));
+
+            //SPEC:141
+            assertEquals(portletResponse.getLocale(), response.getLocale());
+            return new EndTestResponse();
+         }
+      });
+   }
+}

Modified: modules/portlet/trunk/portlet/src/resources/test/jsr168/tck/dispatcher-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/portlet/src/resources/test/jsr168/tck/dispatcher-war/WEB-INF/web.xml	2007-11-06 10:17:40 UTC (rev 8832)
+++ modules/portlet/trunk/portlet/src/resources/test/jsr168/tck/dispatcher-war/WEB-INF/web.xml	2007-11-06 14:04:11 UTC (rev 8833)
@@ -28,7 +28,7 @@
 <web-app>
 
    <listener>
-         <listener-class>org.jboss.portal.test.portlet.jsr168.tck.dispatcher.DispatcherSequenceBuilder</listener-class>
+         <listener-class>org.jboss.portal.test.framework.portlet.PortletTestSuite</listener-class>
    </listener>
 
    <servlet>




More information about the portal-commits mailing list