portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msnickl...@apache.org
Subject [18/35] Added new dispatcher tests:
Date Fri, 22 Aug 2014 13:13:56 GMT
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2a619ecc/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/constants/Constants.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/constants/Constants.java
b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/constants/Constants.java
index cb0fcf2..0792d83 100644
--- a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/constants/Constants.java
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/constants/Constants.java
@@ -43,7 +43,14 @@ public class Constants {
    public static final String QUERY_STRING = "qparm1=qvalue1&qparm2=qvalue2";
    
    // for several tests to servlet / jsp for comparison
-   public static final String MULTIPLE_INCLUDE_NAME = "MultipleIncludeServlet";
+   public static final String ATTR_DISPATCH_TARGET = "req.attr.dispatch.target";
+   public static final String ATTR_DISPATCH_ACTION = "req.attr.dispatch.action";
+   public static final String ATTR_DISPATCH_REQUEST_URI  = "req.attr.dispatch.request_uri
";
+   public static final String ATTR_DISPATCH_CONTEXT_PATH = "req.attr.dispatch.context_path";
+   public static final String ATTR_DISPATCH_SERVLET_PATH = "req.attr.dispatch.servlet_path";
+   public static final String ATTR_DISPATCH_PATH_INFO    = "req.attr.dispatch.path_info";
+   public static final String ATTR_DISPATCH_QUERY_STRING = "req.attr.dispatch.query_string";
+   public static final String ATTR_DISPATCH_COMMITTED = "req.attr.dispatch.committed";
    public static final String MULTIPLE_INCLUDE_ATTR = "req.attr.multi";
    public static final String MULTIPLE_INCLUDE_VAL = "Included counter=";
    public static final String THREADID_ATTR = "req.attr.tid";

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2a619ecc/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/servlets/IncluderForwarderServlet.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/servlets/IncluderForwarderServlet.java
b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/servlets/IncluderForwarderServlet.java
new file mode 100644
index 0000000..42edea4
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/servlets/IncluderForwarderServlet.java
@@ -0,0 +1,108 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package javax.portlet.tck.servlets;
+
+import java.io.*;
+import java.util.*;
+import java.util.logging.*;
+import static java.util.logging.Logger.*;
+import javax.portlet.*;
+import javax.portlet.filter.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.portlet.tck.beans.*;
+import javax.portlet.tck.constants.*;
+import static javax.portlet.tck.constants.Constants.*;
+import static javax.portlet.tck.beans.JSR286DispatcherTestCaseDetails.*;
+
+/**
+ * Servlet for JSR 362 request dispatcher testing.
+ * 
+ * This servlet forwards to or includes another servlet in order to allow multi-level
+ * forward / include testing. Request attributes specify the action (forward or include)
+ * to be carried out and the target of the action. 
+ * 
+ * @author nick
+ *
+ */
+public class IncluderForwarderServlet extends HttpServlet {
+   private static final long serialVersionUID = -4104376549644600993L;
+   private static final String LOG_CLASS = 
+         IncluderForwarderServlet.class.getName();
+   private final Logger LOGGER = Logger.getLogger(LOG_CLASS);
+
+   @Override
+   protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+         throws ServletException, IOException {
+      processTCKReq(req, resp);
+   }
+
+   @Override
+   protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+         throws ServletException, IOException {
+      processTCKReq(req, resp);
+   }
+
+   // The tck uses only get & post requests
+   protected void processTCKReq(HttpServletRequest request, HttpServletResponse response)
+         throws ServletException, IOException {
+      LOGGER.entering(LOG_CLASS, "servlet entry");
+
+      String action = (String) request.getAttribute(ATTR_DISPATCH_ACTION);
+      if (action == null || !action.matches("(include|forward)")) {
+         String msg = LOG_CLASS + ": Bad action attribute. action = " + action;
+         LOGGER.severe(msg);
+         throw new ServletException(msg);
+      }
+
+      String target = (String) request.getAttribute(ATTR_DISPATCH_TARGET);
+      if (target == null) {
+         String msg = LOG_CLASS + ": Bad target attribute. target = " + action;
+         LOGGER.severe(msg);
+         throw new ServletException(msg);
+      }
+      
+      String uri = request.getRequestURI();
+      String cp = request.getContextPath();
+      String sp = request.getServletPath();
+      String pi = request.getPathInfo();
+      String qs = request.getQueryString();
+      
+      request.setAttribute(ATTR_DISPATCH_REQUEST_URI, uri);
+      request.setAttribute(ATTR_DISPATCH_CONTEXT_PATH, cp);
+      request.setAttribute(ATTR_DISPATCH_SERVLET_PATH, sp);
+      request.setAttribute(ATTR_DISPATCH_PATH_INFO, pi);
+      request.setAttribute(ATTR_DISPATCH_QUERY_STRING, qs);
+      
+      RequestDispatcher rd = request.getRequestDispatcher(target);
+      if (rd == null) {
+         String msg = LOG_CLASS + ": Could not get request dispatcher.";
+         LOGGER.severe(msg);
+         throw new ServletException(msg);
+      }
+      
+      if (action.equals("include")) {
+         rd.include(request, response);
+      } else {
+         rd.forward(request, response);
+      }
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2a619ecc/portlet-tck_3.0/deploy/pom.xml
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/deploy/pom.xml b/portlet-tck_3.0/deploy/pom.xml
index 48a54cf..484d0eb 100644
--- a/portlet-tck_3.0/deploy/pom.xml
+++ b/portlet-tck_3.0/deploy/pom.xml
@@ -185,6 +185,18 @@
       </dependency>
       <dependency>
          <groupId>${project.groupId}</groupId>
+         <artifactId>tck-V2DispatcherTests5</artifactId>
+         <version>${project.version}</version>
+         <type>war</type>
+      </dependency>
+      <dependency>
+         <groupId>${project.groupId}</groupId>
+         <artifactId>tck-V2DispatcherTests6</artifactId>
+         <version>${project.version}</version>
+         <type>war</type>
+      </dependency>
+      <dependency>
+         <groupId>${project.groupId}</groupId>
          <artifactId>tck-V2DispatcherReqRespTests1</artifactId>
          <version>${project.version}</version>
          <type>war</type>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2a619ecc/portlet-tck_3.0/driver/pom.xml
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/driver/pom.xml b/portlet-tck_3.0/driver/pom.xml
index 80440d2..6bf318a 100644
--- a/portlet-tck_3.0/driver/pom.xml
+++ b/portlet-tck_3.0/driver/pom.xml
@@ -195,6 +195,18 @@
       </dependency>
       <dependency>
          <groupId>${project.groupId}</groupId>
+         <artifactId>tck-V2DispatcherTests5</artifactId>
+         <version>${project.version}</version>
+         <type>war</type>
+      </dependency>
+      <dependency>
+         <groupId>${project.groupId}</groupId>
+         <artifactId>tck-V2DispatcherTests6</artifactId>
+         <version>${project.version}</version>
+         <type>war</type>
+      </dependency>
+      <dependency>
+         <groupId>${project.groupId}</groupId>
          <artifactId>tck-V2DispatcherReqRespTests1</artifactId>
          <version>${project.version}</version>
          <type>war</type>
@@ -280,6 +292,8 @@
                         tck-V2DispatcherTests,
                         tck-V2DispatcherTests2,
                         tck-V2DispatcherTests4,
+                        tck-V2DispatcherTests5,
+                        tck-V2DispatcherTests6,
                         tck-V2DispatcherTests3S
                      </includeArtifactIds>
                      <includes>${test.file.dir}/*.xml</includes>
@@ -441,7 +455,11 @@
                         </property>
                         <property>
                            <name>test.debug</name>
-                           <value>${test.module}</value>
+                           <value>false</value>
+                        </property>
+                        <property>
+                           <name>test.timeout</name>
+                           <value>${test.timeout}</value>
                         </property>
                      </systemProperties>
                   </configuration>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2a619ecc/portlet-tck_3.0/driver/src/main/resources/xml-resources/pageFiles.xml
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/driver/src/main/resources/xml-resources/pageFiles.xml b/portlet-tck_3.0/driver/src/main/resources/xml-resources/pageFiles.xml
index a73d420..c94326d 100644
--- a/portlet-tck_3.0/driver/src/main/resources/xml-resources/pageFiles.xml
+++ b/portlet-tck_3.0/driver/src/main/resources/xml-resources/pageFiles.xml
@@ -45,6 +45,8 @@
    <fl:file>tck-V2DispatcherTests2-pages.xml</fl:file>
    <fl:file>tck-V2DispatcherTests3S-pages.xml</fl:file>
    <fl:file>tck-V2DispatcherTests4-pages.xml</fl:file>
+   <fl:file>tck-V2DispatcherTests5-pages.xml</fl:file>
+   <fl:file>tck-V2DispatcherTests6-pages.xml</fl:file>
    <fl:file>tck-V2DispatcherReqRespTests1-pages.xml</fl:file>
    <fl:file>tck-V2DispatcherReqRespTests2-pages.xml</fl:file>
    <fl:file>tck-V2DispatcherReqRespTests3-pages.xml</fl:file>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2a619ecc/portlet-tck_3.0/driver/src/main/resources/xml-resources/testFiles.xml
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/driver/src/main/resources/xml-resources/testFiles.xml b/portlet-tck_3.0/driver/src/main/resources/xml-resources/testFiles.xml
index 82df30e..c622647 100644
--- a/portlet-tck_3.0/driver/src/main/resources/xml-resources/testFiles.xml
+++ b/portlet-tck_3.0/driver/src/main/resources/xml-resources/testFiles.xml
@@ -45,6 +45,8 @@
    <fl:file>tck-V2DispatcherTests2-tests.xml</fl:file>
    <fl:file>tck-V2DispatcherTests3S-tests.xml</fl:file>
    <fl:file>tck-V2DispatcherTests4-tests.xml</fl:file>
+   <fl:file>tck-V2DispatcherTests5-tests.xml</fl:file>
+   <fl:file>tck-V2DispatcherTests6-tests.xml</fl:file>
    <fl:file>tck-V2DispatcherReqRespTests1-tests.xml</fl:file>
    <fl:file>tck-V2DispatcherReqRespTests2-tests.xml</fl:file>
    <fl:file>tck-V2DispatcherReqRespTests3-tests.xml</fl:file>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2a619ecc/portlet-tck_3.0/pom.xml
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/pom.xml b/portlet-tck_3.0/pom.xml
index 55ca32a..d603a26 100644
--- a/portlet-tck_3.0/pom.xml
+++ b/portlet-tck_3.0/pom.xml
@@ -101,10 +101,14 @@
       <!-- Can be used with firefox or HTMLUnit without setting the test.browser.webDriver
property. -->
       <!-- Use of Chrome or IE requires the webDriver to be downloaded ad available. Set
the -->
       <!-- test.browser.webDriver property to point to the appropriate WebDriver server.
-->
+      <test.browser>firefox</test.browser>
       <test.browser>HTMLUnit</test.browser>
       <!-- commented outline below shows configuration for the Internet Explorer  driver
-->
       <!-- test.browser.webDriver>C:\ntutil\IEDriverServer_x64_2.42.0\IEDriverServer.exe</test.browser.webDriver
-->
 
+     <!-- Specify timeout in seconds for the driver to wait for page load. must be an
integer. -->
+      <test.timeout>3</test.timeout>
+
       <!-- Set in subprojects containing additional test case file. default is no additional
file (false) -->
       <additional.testcase.uri>false</additional.testcase.uri>
       <!-- Set to true for modules that define all test cases in a file (TCs are not generated
from the portlet.xml) -->
@@ -139,6 +143,8 @@
       <module>V2DispatcherTests2</module>
       <module>V2DispatcherTests3S</module>
       <module>V2DispatcherTests4</module>
+      <module>V2DispatcherTests5</module>
+      <module>V2DispatcherTests6</module>
       <module>V2DispatcherReqRespTests1</module>
       <module>V2DispatcherReqRespTests2</module>
       <module>V2DispatcherReqRespTests3</module>


Mime
View raw message