You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mf...@apache.org on 2009/10/13 22:34:56 UTC

svn commit: r824913 [2/5] - in /myfaces/portlet-bridge/testsuite/trunk/src/main: java/org/apache/myfaces/portlet/faces/testsuite/beans/ java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_3/ java/org/apache/myfaces/portlet/faces/testsuite/tes...

Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java?rev=824913&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java Tue Oct 13 20:34:55 2009
@@ -0,0 +1,3851 @@
+/* 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 org.apache.myfaces.portlet.faces.testsuite.tests.chapter6.section_6_1_3_1;
+
+
+import java.io.UnsupportedEncodingException;
+
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import java.util.Set;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+
+import javax.el.ValueExpression;
+
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.application.ViewHandler;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.render.ResponseStateManager;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletURL;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import javax.portlet.WindowState;
+import javax.portlet.faces.Bridge;
+import javax.portlet.faces.BridgeUtil;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+
+import javax.servlet.jsp.JspContext;
+
+import org.apache.myfaces.portlet.faces.testsuite.annotation.BridgeTest;
+import org.apache.myfaces.portlet.faces.testsuite.beans.TestRunnerBean;
+import org.apache.myfaces.portlet.faces.testsuite.common.Constants;
+import org.apache.myfaces.portlet.faces.testsuite.common.portlet.wrapper.ActionRequestDecorator;
+import org.apache.myfaces.portlet.faces.testsuite.common.portlet.wrapper.RenderRequestDecorator;
+
+
+public class Tests
+  extends Object
+{
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "dispatchUsesIncludeTest")
+  public String dispatchUsesIncludeTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    // Some servlet containers wrap ther request/response before invokign the dispatched servlet +
+    // handle the servlet defined special (include/forward) attributes in a separate list which is
+    // managed in the wrapped request -- Pluto (2.0) does this.  This means that inside of a JSF
+    // expression running in a JSP we can't merely get the externalContext and check if the
+    // include attrbiute is set.  Rather we must do an EL evaluation on the request object to
+    // do the check.  Unfortunately ther is no easy way to get the JSP elcontext -- so instead
+    // do the check in the JSP itself and set a request attribute we will have access to.
+    Boolean value =
+      (Boolean) FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("org.apache.myfaces.portlet.faces.testsuite.dispatchInclude");
+
+    if (value == null)
+    {
+      testRunner.setTestResult(false,
+                               "Unable to acquire the request attribute containing the result that should have been set in the JSP page.");
+      return Constants.TEST_FAILED;
+    }
+    else if (value.booleanValue())
+    {
+      testRunner.setTestResult(true,
+                               "Successfully accessed javax.servlet.include.servletPath attribute indicating we are inside a dispatch.include");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "javax.servlet.include.servletPath not set, but it would be if we are inside a dispatch.include");
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeActionURLPoundCharTest")
+  public String encodeActionURLPoundCharTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String POUNDCHAR_TEST_STRING = "#AnchorReference";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    
+    if (extCtx.encodeActionURL(POUNDCHAR_TEST_STRING).equals(POUNDCHAR_TEST_STRING))
+    {
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly returned an unchanged string when the string was prefixed with #.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeActionURL didn't return an unchanged string when the string was prefixed with #.  Test parameter: " +
+                               POUNDCHAR_TEST_STRING +
+                               " and encodeActionURL returned: " +
+                               extCtx.encodeActionURL(POUNDCHAR_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeActionURLAbsoluteURLTest")
+  public String encodeActionURLAbsoluteURLTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String ABSOLUTEURL_TEST_STRING = "http://www.apache.org";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    
+    if (extCtx.encodeActionURL(ABSOLUTEURL_TEST_STRING).equals(ABSOLUTEURL_TEST_STRING))
+    {
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly returned an unchanged string when passed an absolute URL.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeActionURL didn't return an unchanged string when passed an absolute URL.  Test parameter: " +
+                               ABSOLUTEURL_TEST_STRING +
+                               " and encodeActionURL returned: " +
+                               extCtx.encodeActionURL(ABSOLUTEURL_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeActionURLDirectLinkTrueTest")
+  public String encodeActionURLDirectLinkTrueTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String DIRECTLINK_TRUE_TEST_STRING =
+      "/test.jsp?firstParam=value&javax.portlet.faces.DirectLink=true&anotherParam=value";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    
+    if (extCtx.encodeActionURL(DIRECTLINK_TRUE_TEST_STRING).equals(DIRECTLINK_TRUE_TEST_STRING))
+    {
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly returned an unchanged string when passed an URL containing the javax.portlet.faces.DirectLink parameter with a value of true.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeActionURL didn't return an unchanged string when passed an URL containing the javax.portlet.faces.DirectLink parameter with a value of true.  Test parameter: " +
+                               DIRECTLINK_TRUE_TEST_STRING +
+                               " and encodeActionURL returned: " +
+                               extCtx.encodeActionURL(DIRECTLINK_TRUE_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeActionURLDirectLinkFalseTest")
+  public String encodeActionURLDirectLinkFalseTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String DIRECTLINK_FALSE_TEST_STRING =
+      "/test.jsp?firstParam=value&javax.portlet.faces.DirectLink=false&anotherParam=value";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    
+    if (!extCtx.encodeActionURL(DIRECTLINK_FALSE_TEST_STRING).contains("javax.portlet.faces.DirectLink"))
+    {
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly returned an url string without the javax.portlet.faces.DirectLink parameter when its value was false.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeActionURL didn't return an url string without the javax.portlet.faces.DirectLink parameter when its value was false.  Test parameter: " +
+                               DIRECTLINK_FALSE_TEST_STRING +
+                               " and encodeActionURL returned: " +
+                               extCtx.encodeActionURL(DIRECTLINK_FALSE_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeActionURLPortletRenderTest")
+  public String encodeActionURLPortletRenderTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String PORTLET_RENDER_TEST_STRING =
+      "portlet:render?param1=value1&param2=value2";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    
+    String bridgeEncoded =
+      extCtx.encodeActionURL(PORTLET_RENDER_TEST_STRING);
+
+    RenderResponse response = (RenderResponse) extCtx.getResponse();
+    PortletURL portletURL = response.createRenderURL();
+    portletURL.setParameter("param1", "value1");
+    portletURL.setParameter("param2", "value2");
+    String portletEncoded = portletURL.toString();
+
+    if (bridgeEncoded.equals(portletEncoded))
+    {
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet render URL as an actionURL using the portlet: syntax.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeActionURL incorrectly encoded a portlet render URL as an actionURL using the portlet: syntax.  In encoding: " +
+                               PORTLET_RENDER_TEST_STRING +
+                               " the bridge returned: " + bridgeEncoded +
+                               " but the corresponding portletURL encoding returned: " +
+                               portletEncoded);
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeActionURLPortletActionTest")
+  public String encodeActionURLPortletActionTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String PORTLET_ACTION_TEST_STRING =
+      "portlet:action?param1=value1&param2=value2";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    String bridgeEncoded =
+      extCtx.encodeActionURL(PORTLET_ACTION_TEST_STRING);
+
+    RenderResponse response = (RenderResponse) extCtx.getResponse();
+    PortletURL portletURL = response.createActionURL();
+    portletURL.setParameter("param1", "value1");
+    portletURL.setParameter("param2", "value2");
+    String portletEncoded = portletURL.toString();
+    
+    if (bridgeEncoded.equals(portletEncoded))
+    {
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet action URL as an actionURL using the portlet: syntax.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeActionURL incorrectly encoded a portlet action URL as an actionURL using the portlet: syntax.  In encoding: " +
+                               PORTLET_ACTION_TEST_STRING +
+                               " the bridge returned: " + bridgeEncoded +
+                               " but the corresponding portletURL encoding returned: " +
+                               portletEncoded);
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLJSFViewActionTest")
+  public String encodeActionURLJSFViewActionTest(TestRunnerBean testRunner)
+  {
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      return "encodeActionURLJSFViewActionTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet action URL.");
+      return Constants.TEST_SUCCESS;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithParamActionTest")
+  public String encodeActionURLWithParamActionTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      return "encodeActionURLWithParamActionTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      // Parameter encoded in the faces-config.xml target
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (pVal != null && pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(true,
+                                 "encodeActionURL correctly encoded a portlet action URL containing a parameter.");
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        if (pVal == null)
+          testRunner.setTestResult(false,
+                                   "encodeActionURL incorrectly encoded a portlet action URL containing a parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+        else
+          testRunner.setTestResult(false,
+                                   "encodeActionURL incorrectly encoded a portlet action URL containing a parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                   pVal);
+      }
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithModeActionTest")
+  public String encodeActionURLWithModeActionTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      return "encodeActionURLWithModeActionTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Mode encoded in the faces-config.xml target
+      PortletMode mode = pReq.getPortletMode();
+      if (mode == null || !mode.toString().equalsIgnoreCase("edit"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the new portlet mode.  The resulting request wasn't in the expected 'edit' mode.");
+        return Constants.TEST_FAILED;
+      }
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new mode and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+        return Constants.TEST_FAILED;
+      }
+      if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new mode and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+        return Constants.TEST_FAILED;
+      }
+
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet action URL containing a new mode and parameter.");
+      return Constants.TEST_SUCCESS;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithInvalidModeActionTest")
+  public String encodeActionURLWithInvalidModeActionTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      return "encodeActionURLWithInvalidModeActionTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Mode encoded in the faces-config.xml target
+      PortletMode mode = pReq.getPortletMode();
+      if (mode == null || !mode.toString().equalsIgnoreCase("view"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the invalid portlet mode.  The resulting request should have ignored the invalid mode and remained in 'view' mode.");
+        return Constants.TEST_FAILED;
+      }
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid mode and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+        return Constants.TEST_FAILED;
+      }
+      if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid mode and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+        return Constants.TEST_FAILED;
+      }
+
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet action URL by ignoring the invalid mode and properly encoding the parameter.");
+      return Constants.TEST_SUCCESS;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithWindowStateActionTest")
+  public String encodeActionURLWithWindowStateActionTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      return "encodeActionURLWithWindowStateActionTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Mode encoded in the faces-config.xml target
+      WindowState ws = pReq.getWindowState();
+      if (ws == null || !ws.toString().equalsIgnoreCase("maximized"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the new portlet window state.  The resulting request wasn't in the expected 'maximized' mode.");
+        return Constants.TEST_FAILED;
+      }
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new window state and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+        return Constants.TEST_FAILED;
+      }
+      if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new window state and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+        return Constants.TEST_FAILED;
+      }
+
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet action URL containing a new window state and parameter.");
+      return Constants.TEST_SUCCESS;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithInvalidWindowStateActionTest")
+  public String encodeActionURLWithInvalidWindowStateActionTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      return "encodeActionURLWithInvalidWindowStateActionTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Mode encoded in the faces-config.xml target
+      WindowState ws = pReq.getWindowState();
+      if (ws == null || !ws.toString().equalsIgnoreCase("normal"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the invalid window state.  The resulting request should have ignored the invalid window state and remained in 'normal' mode.");
+        return Constants.TEST_FAILED;
+      }
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid window state and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+        return Constants.TEST_FAILED;
+      }
+      if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid window state and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+        return Constants.TEST_FAILED;
+      }
+
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet action URL by ignoring the invalid window state and properly encoding the parameter.");
+      return Constants.TEST_SUCCESS;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithSecurityActionTest")
+  public String encodeActionURLWithSecurityActionTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      return "encodeActionURLWithSecurityActionTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Secure encoded in the faces-config.xml target
+      if (!pReq.isSecure())
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the portlet security state.  The resulting request wasn't in the expected 'secure' mode.");
+        return Constants.TEST_FAILED;
+      }
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new security state and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+        return Constants.TEST_FAILED;
+      }
+      if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new security state and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+        return Constants.TEST_FAILED;
+      }
+
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet action URL accessed in a secure state and parameter.");
+      return Constants.TEST_SUCCESS;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithInvalidSecurityActionTest")
+  public String encodeActionURLWithInvalidSecurityActionTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      return "encodeActionURLWithInvalidSecurityActionTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Mode encoded in the faces-config.xml target
+      if (pReq.isSecure())
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded an invalid portlet security state.  The resulting request wasn't in the expected 'non-secure' mode.");
+        return Constants.TEST_FAILED;
+      }
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid security state and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+        return Constants.TEST_FAILED;
+      }
+      if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid security state and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+        return Constants.TEST_FAILED;
+      }
+
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet action URL ontaining an invalid security state and parameter.");
+      return Constants.TEST_SUCCESS;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLJSFViewRenderTest")
+  public String encodeActionURLJSFViewRenderTest(TestRunnerBean testRunner)
+  {
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      testRunner.setTestResult(true,
+                               "encodeActionURL correctly encoded a portlet action URL.");
+      return "encodeActionURLJSFViewRenderTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      return Constants.TEST_SUCCESS;
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithParamRenderTest")
+  public String encodeActionURLWithParamRenderTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      // Parameter encoded in the faces-config.xml target
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (pVal != null && pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(true,
+                                 "encodeActionURL correctly encoded a portlet action URL containing a parameter.");
+      }
+      else
+      {
+        if (pVal == null)
+          testRunner.setTestResult(false,
+                                   "encodeActionURL incorrectly encoded a portlet action URL containing a parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+        else
+          testRunner.setTestResult(false,
+                                   "encodeActionURL incorrectly encoded a portlet action URL containing a parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                   pVal);
+      }
+      return "encodeActionURLWithParamRenderTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      if (testRunner.getTestStatus())
+      {
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        return Constants.TEST_FAILED;
+
+      }
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithModeRenderTest")
+  public String encodeActionURLWithModeRenderTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Mode encoded in the faces-config.xml target
+      PortletMode mode = pReq.getPortletMode();
+
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+
+      if (mode == null || !mode.toString().equalsIgnoreCase("edit"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the new portlet mode.  The resulting request wasn't in the expected 'edit' mode.");
+      }
+      else if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new mode and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+      }
+      else if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new mode and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+      }
+      else
+      {
+        testRunner.setTestResult(true,
+                                 "encodeActionURL correctly encoded a portlet action URL containing a new mode and parameter.");
+      }
+      return "encodeActionURLWithModeRenderTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      if (testRunner.getTestStatus())
+      {
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        return Constants.TEST_FAILED;
+      }
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithInvalidModeRenderTest")
+  public String encodeActionURLWithInvalidModeRenderTest(TestRunnerBean testRunner)
+  {
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Mode encoded in the faces-config.xml target
+      PortletMode mode = pReq.getPortletMode();
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+
+      if (mode == null || !mode.toString().equalsIgnoreCase("view"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the invalid portlet mode.  The resulting request should have ignored the invalid mode and remained in 'view' mode.");
+      }
+      else if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid mode and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+      }
+      else if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid mode and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+      }
+      else
+      {
+        testRunner.setTestResult(true,
+                                 "encodeActionURL correctly encoded a portlet action URL by ignoring the invalid mode and properly encoding the parameter.");
+      }
+      return "encodeActionURLWithInvalidModeActionTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      if (testRunner.getTestStatus())
+      {
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        return Constants.TEST_FAILED;
+      }
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithWindowStateRenderTest")
+  public String encodeActionURLWithWindowStateRenderTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Mode encoded in the faces-config.xml target
+      WindowState ws = pReq.getWindowState();
+
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+
+      if (ws == null || !ws.toString().equalsIgnoreCase("maximized"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the new portlet window state.  The resulting request wasn't in the expected 'maximized' mode.");
+      }
+      else if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new window state and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+      }
+      else if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new window state and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+      }
+      else
+      {
+        testRunner.setTestResult(true,
+                                 "encodeActionURL correctly encoded a portlet action URL containing a new window state and parameter.");
+      }
+      return "encodeActionURLWithWindowStateRenderTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      if (testRunner.getTestStatus())
+      {
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        return Constants.TEST_FAILED;
+      }
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithInvalidWindowStateRenderTest")
+  public String encodeActionURLWithInvalidWindowStateRenderTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Parameter/Mode encoded in the faces-config.xml target
+      WindowState ws = pReq.getWindowState();
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (ws == null || !ws.toString().equalsIgnoreCase("normal"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the invalid window state.  The resulting request should have ignored the invalid window state and remained in 'normal' mode.");
+      }
+      else if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid window state and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+      }
+      else if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid window state and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+      }
+      else
+      {
+        testRunner.setTestResult(true,
+                                 "encodeActionURL correctly encoded a portlet action URL by ignoring the invalid window state and properly encoding the parameter.");
+      }
+      return "encodeActionURLWithInvalidWindowStateRenderTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      if (testRunner.getTestStatus())
+      {
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        return Constants.TEST_FAILED;
+      }
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithSecurityRenderTest")
+  public String encodeActionURLWithSecurityRenderTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (!pReq.isSecure())
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded the portlet security state.  The resulting request wasn't in the expected 'secure' mode.");
+      }
+      else if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new security state and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+      }
+      else if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing a new security state and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+      }
+      else
+      {
+        testRunner.setTestResult(true,
+                                 "encodeActionURL correctly encoded a portlet action URL accessed in a secure state and parameter.");
+      }
+      return "encodeActionURLWithSecurityRenderTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      if (testRunner.getTestStatus())
+      {
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        return Constants.TEST_FAILED;
+      }
+    }
+  }
+
+  // Test is MultiRequest -- Render/Action
+
+  @BridgeTest(test = "encodeActionURLWithInvalidSecurityRenderTest")
+  public String encodeActionURLWithInvalidSecurityRenderTest(TestRunnerBean testRunner)
+  {
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      FacesContext ctx = FacesContext.getCurrentInstance();
+      PortletRequest pReq =
+        (PortletRequest) ctx.getExternalContext().getRequest();
+      // Check that the parameter came along too
+      String pVal =
+        ctx.getExternalContext().getRequestParameterMap().get("param1");
+      if (pReq.isSecure())
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded an invalid portlet security state.  The resulting request wasn't in the expected 'non-secure' mode.");
+        return Constants.TEST_FAILED;
+      }
+      else if (pVal == null)
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid security state and parameter.  The resulting request didn't contain the expected 'param1' parameter.");
+        return Constants.TEST_FAILED;
+      }
+      else if (!pVal.equals("testValue"))
+      {
+        testRunner.setTestResult(false,
+                                 "encodeActionURL incorrectly encoded a portlet action URL containing an invalid security state and parameter.  The resulting request contained the wrong parameter value. Expected: testValue  Received: " +
+                                 pVal);
+        return Constants.TEST_FAILED;
+      }
+
+      else
+      {
+        testRunner.setTestResult(true,
+                                 "encodeActionURL correctly encoded a portlet action URL ontaining an invalid security state and parameter.");
+      }
+      return "encodeActionURLWithInvalidSecurityRenderTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      if (testRunner.getTestStatus())
+      {
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        return Constants.TEST_FAILED;
+      }
+    }
+  }
+
+
+  // Test is SingleRequest -- Render only
+
+  /************** encodeResourceURLTests *********************************************************/
+  @BridgeTest(test = "encodeResourceURLOpaqueTest")
+  public String encodeResourceURLOpaqueTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String OPAQUE_TEST_STRING = "mailto:jsr-301-comments@jcp.org";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    if (extCtx.encodeResourceURL(OPAQUE_TEST_STRING).equals(OPAQUE_TEST_STRING))
+    {
+      testRunner.setTestResult(true,
+                               "encodeResourceURL correctly returned an unchanged string when the input was an opaque URL.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeResourceURL didn't return an unchanged string when the input was an opaque URL.  Test parameter: " +
+                               OPAQUE_TEST_STRING +
+                               " and encodeResourceURL returned: " +
+                               extCtx.encodeResourceURL(OPAQUE_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeResourceURLForeignExternalURLTest")
+  public String encodeResourceURLForeignExternalURLTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String FOREIGNEXTERNALURL_TEST_STRING = "http://www.apache.org";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    if (extCtx.encodeResourceURL(FOREIGNEXTERNALURL_TEST_STRING).equals(((PortletResponse) extCtx.getResponse()).encodeURL(FOREIGNEXTERNALURL_TEST_STRING)))
+    {
+      testRunner.setTestResult(true,
+                               "encodeResourceURL correctly encoded a foreign external URL.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeResourceURL didn't correctly encoded a foreign external URL.  Expected: " +
+                               ((PortletResponse) extCtx.getResponse()).encodeURL(FOREIGNEXTERNALURL_TEST_STRING) +
+                               " and encodeResourceURL returned: " +
+                               extCtx.encodeResourceURL(FOREIGNEXTERNALURL_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeResourceURLForeignExternalURLBackLinkTest")
+  public String encodeResourceURLForeignExternalURLBackLinkTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String FOREIGNEXTERNALURL_BACKLINK_TEST_STRING =
+      "http://www.apache.org?javax.portlet.faces.BackLink=myBackLinkParam";
+    final String FOREIGNEXTERNALURL_BACKLINK_VERIFY_STRING =
+      "http://www.apache.org?myBackLinkParam=";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    // compute what the backLink should be
+    String actionURL =
+      extCtx.encodeActionURL(ctx.getApplication().getViewHandler().getActionURL(ctx,
+                                                                                ctx.getViewRoot().getViewId()));
+    String verifyString = null;
+    try
+    {
+      verifyString =
+          FOREIGNEXTERNALURL_BACKLINK_VERIFY_STRING + URLEncoder.encode(actionURL,
+                                                                        "UTF-8");
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      testRunner.setTestResult(false,
+                               "Failed because couldn't UTF-8 encode backLink parameter.");
+      return Constants.TEST_FAILED;
+    }
+
+    if (extCtx.encodeResourceURL(FOREIGNEXTERNALURL_BACKLINK_TEST_STRING).equals(((PortletResponse) extCtx.getResponse()).encodeURL(verifyString)))
+    {
+      testRunner.setTestResult(true,
+                               "encodeResourceURL correctly encoded a foreign external URL with a backLink.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeResourceURL didn't correctly encoded a foreign external URL with a backLink.  Expected: " +
+                               ((PortletResponse) extCtx.getResponse()).encodeURL(verifyString) +
+                               " but encodeResourceURL returned: " +
+                               extCtx.encodeResourceURL(FOREIGNEXTERNALURL_BACKLINK_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeResourceURLRelativeURLTest")
+  public String encodeResourceURLRelativeURLTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String RELATIVEURL_TEST_STRING = "../resources/myImage.jpg";
+    final String RELATIVEURL_VERIFY_STRING = "/resources/myImage.jpg";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    if (extCtx.encodeResourceURL(RELATIVEURL_TEST_STRING).equals(((PortletResponse) extCtx.getResponse()).encodeURL(extCtx.getRequestContextPath() +
+                                                                                                                    RELATIVEURL_VERIFY_STRING)))
+    {
+      testRunner.setTestResult(true,
+                               "encodeResourceURL correctly encoded a resource referenced by a relative path.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeResourceURL incorrectly encoded a resource referenced by a relative path.  Expected: " +
+                               ((PortletResponse) extCtx.getResponse()).encodeURL(extCtx.getRequestContextPath() +
+                                                                                  RELATIVEURL_VERIFY_STRING) +
+                               " and encodeResourceURL returned: " +
+                               extCtx.encodeResourceURL(RELATIVEURL_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeResourceURLRelativeURLBackLinkTest")
+  public String encodeResourceURLRelativeURLBackLinkTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String RELATIVEURL_BACKLINK_TEST_STRING =
+      "../resources/myImage.jpg?javax.portlet.faces.BackLink=myBackLinkParam";
+    final String RELATIVEURL_BACKLINK_VERIFY_STRING =
+      "/resources/myImage.jpg?myBackLinkParam=";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    // compute what the backLink should be
+    String actionURL =
+      extCtx.encodeActionURL(ctx.getApplication().getViewHandler().getActionURL(ctx,
+                                                                                ctx.getViewRoot().getViewId()));
+    String verifyString = null;
+    try
+    {
+      verifyString =
+          extCtx.getRequestContextPath() + RELATIVEURL_BACKLINK_VERIFY_STRING +
+          URLEncoder.encode(actionURL, "UTF-8");
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      testRunner.setTestResult(false,
+                               "Failed because couldn't UTF-8 encode backLink parameter.");
+      return Constants.TEST_FAILED;
+    }
+
+    if (extCtx.encodeResourceURL(RELATIVEURL_BACKLINK_TEST_STRING).equals(((PortletResponse) extCtx.getResponse()).encodeURL(verifyString)))
+    {
+      testRunner.setTestResult(true,
+                               "encodeResourceURL correctly encoded a relative URL with a backLink.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeResourceURL didn't correctly encoded a relative URL with a backLink.  Expected: " +
+                               verifyString +
+                               " but encodeResourceURL returned: " +
+                               extCtx.encodeResourceURL(RELATIVEURL_BACKLINK_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeResourceURLTest")
+  public String encodeResourceURLTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String URL_TEST_STRING = "/resources/myImage.jpg";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    if (extCtx.encodeResourceURL(URL_TEST_STRING).equals(((PortletResponse) extCtx.getResponse()).encodeURL(extCtx.getRequestContextPath() +
+                                                                                                            URL_TEST_STRING)))
+    {
+      testRunner.setTestResult(true,
+                               "encodeResourceURL correctly encoded a resource referenced by a context path relative path.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeResourceURL incorrectly encoded a resource referenced by a context path relative path.  Expected: " +
+                               ((PortletResponse) extCtx.getResponse()).encodeURL(extCtx.getRequestContextPath() +
+                                                                                  URL_TEST_STRING) +
+                               " and encodeResourceURL returned: " +
+                               extCtx.encodeResourceURL(URL_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeResourceURLRelativeBackLinkTest")
+  public String encodeResourceURLRelativeBackLinkTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String URL_BACKLINK_TEST_STRING =
+      "/resources/myImage.jpg?javax.portlet.faces.BackLink=myBackLinkParam";
+    final String URL_BACKLINK_VERIFY_STRING =
+      "/resources/myImage.jpg?myBackLinkParam=";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    // compute what the backLink should be
+    String actionURL =
+      extCtx.encodeActionURL(ctx.getApplication().getViewHandler().getActionURL(ctx,
+                                                                                ctx.getViewRoot().getViewId()));
+    String verifyString = null;
+    try
+    {
+      verifyString =
+          extCtx.getRequestContextPath() + URL_BACKLINK_VERIFY_STRING +
+          URLEncoder.encode(actionURL, "UTF-8");
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      testRunner.setTestResult(false,
+                               "Failed because couldn't UTF-8 encode backLink parameter.");
+      return Constants.TEST_FAILED;
+    }
+
+    if (extCtx.encodeResourceURL(URL_BACKLINK_TEST_STRING).equals(((PortletResponse) extCtx.getResponse()).encodeURL(verifyString)))
+    {
+      testRunner.setTestResult(true,
+                               "encodeResourceURL correctly encoded a relative URL with a backLink.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeResourceURL didn't correctly encoded a relative URL with a backLink.  Expected: " +
+                               ((PortletResponse) extCtx.getResponse()).encodeURL(verifyString) +
+                               " but encodeResourceURL returned: " +
+                               extCtx.encodeResourceURL(URL_BACKLINK_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeResourceURLViewLinkTest")
+  public String encodeResourceURLViewLinkTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    // assume web.xml does Faces suffix mapping of .jsf to .jsp
+    final String URL_VIEWLINK_TEST_STRING =
+      "/tests/viewLink.jsf?javax.portlet.faces.ViewLink=true&param1=testValue";
+    final String URL_VIEWLINK_VERIFY_STRING =
+      "/tests/viewLink.jsf?param1=testValue";
+
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    if (extCtx.encodeResourceURL(URL_VIEWLINK_TEST_STRING).equals(extCtx.encodeActionURL(URL_VIEWLINK_VERIFY_STRING)))
+    {
+      testRunner.setTestResult(true,
+                               "encodeResourceURL correctly encoded a viewLink.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeResourceURL incorrectly encoded a viewLink.  Expected: " +
+                               extCtx.encodeActionURL(URL_VIEWLINK_VERIFY_STRING) +
+                               " but encodeResourceURL with the viewLink returned: " +
+                               extCtx.encodeResourceURL(URL_VIEWLINK_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  @BridgeTest(test = "encodeResourceURLViewLinkWithBackLinkTest")
+  public String encodeResourceURLViewLinkWithBackLinkTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    final String URL_VIEWLINK_BACKLINK_TEST_STRING =
+      "/tests/viewLink.jsf?javax.portlet.faces.ViewLink=true&param1=testValue&javax.portlet.faces.BackLink=myBackLinkParam";
+    final String URL_VIEWLINK_BACKLINK_VERIFY_STRING =
+      "/tests/viewLink.jsf?param1=testValue&myBackLinkParam=";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    // compute what the backLink should be
+    String actionURL =
+      extCtx.encodeActionURL(ctx.getApplication().getViewHandler().getActionURL(ctx,
+                                                                                ctx.getViewRoot().getViewId()));
+    String verifyString = null;
+    try
+    {
+      verifyString =
+          URL_VIEWLINK_BACKLINK_VERIFY_STRING + URLEncoder.encode(actionURL,
+                                                                  "UTF-8");
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      testRunner.setTestResult(false,
+                               "Failed because couldn't UTF-8 encode backLink parameter.");
+      return Constants.TEST_FAILED;
+    }
+    // Note:  as we are adding a URL as a parameter make sure its properly URLEncoded -- this causes it to be doubly encoded
+    if (extCtx.encodeResourceURL(URL_VIEWLINK_BACKLINK_TEST_STRING).equals(extCtx.encodeActionURL(verifyString)))
+    {
+      testRunner.setTestResult(true,
+                               "encodeResourceURL correctly encoded a viewLink with a BackLink.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,
+                               "encodeResourceURL incorrectly encoded a viewLink.  Expected: " +
+                               extCtx.encodeActionURL(verifyString) +
+                               " but encodeResourceURL with the viewLink returned: " +
+                               extCtx.encodeResourceURL(URL_VIEWLINK_BACKLINK_TEST_STRING));
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is MultiRequest -- tests both setting request in action and render
+
+  @BridgeTest(test = "getSetRequestObjectTest")
+  public String getSetRequestObjectTest(TestRunnerBean testRunner)
+  {
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      ActionRequest aRequest =
+        new ActionRequestDecorator((ActionRequest) extCtx.getRequest());
+
+      extCtx.setRequest(aRequest);
+      if (extCtx.getRequest() == aRequest)
+      {
+        testRunner.setTestResult(true,
+                                 "Successfully set/retrieved a new ActionRequest using ExternalContxt.set/getRequest.");
+        return "getSetRequestObjectTest"; // action Navigation result
+      }
+      else
+      {
+        testRunner.setTestResult(false,
+                                 "ExternalContxt.set/getRequest a new ActionRequest failed as the retrieved object isn't the same as the one set.");
+        return "getSetRequestObjectTest";
+      }
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      // Now do the same thing for render
+      RenderRequest rRequest =
+        new RenderRequestDecorator((RenderRequest) extCtx.getRequest());
+
+      extCtx.setRequest(rRequest);
+      if (extCtx.getRequest() == rRequest)
+      {
+        testRunner.appendTestDetail("Successfully set/retrieved a new RenderRequest using ExternalContxt.set/getRequest.");
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        testRunner.setTestResult(false,
+                                 "ExternalContext.set/getRequest a new RenderRequest failed as the retrieved object isn't the same as the one set.");
+        return Constants.TEST_FAILED;
+      }
+    }
+  }
+
+
+  // Test is SingleRequest -- Render only
+
+  /******************** setRequestCharacterEncoding Tests ***************/
+  @BridgeTest(test = "setRequestCharacterEncodingRenderTest")
+  public String setRequestCharacterEncodingRenderTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    // Call setRequestCharacterEncoding -- fail if an exception is thrown
+    try
+    {
+      extCtx.setRequestCharacterEncoding("UTF-8");
+      // In portlet 1.0 there is no supprt for this -- so spec says ignore
+      testRunner.setTestResult(true,
+                               "setRequestCharacterEncoding correctly didn't throw an exception when called during the render Phase.");
+      return Constants.TEST_SUCCESS;
+    }
+    catch (Exception e)
+    {
+      testRunner.setTestResult(false,
+                               "setRequestCharacterEncoding correctly didn't throw an exception when called during the render Phase.");
+      return Constants.TEST_FAILED;
+    }
+  }
+
+  // Test is MultiRequest -- tests both setting request in action and render
+  // Note:  this tests that you can't get an encoding after reading the parameter.
+  //        we can't test for the positive -- that the setEncoding actually works
+  //        as portlet containers are supposed to process the form parameters before
+  //        the portlet reads them  -- some containers (WebSphere) chooses to do this
+  //        before calling the portlet.
+
+  @BridgeTest(test = "setRequestCharacterEncodingActionTest")
+  public String setRequestCharacterEncodingActionTest(TestRunnerBean testRunner)
+  {
+    final String utf8 = "UTF-8";
+    final String utf16 = "UTF-16";
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      String s = extCtx.getRequestCharacterEncoding();
+      String testEncoding = null;
+      // read the parameters to ensure setting the encoding is invalid.
+      Map m = ((PortletRequest) extCtx.getRequest()).getParameterMap();
+
+      if (s == null || (s != null && !s.equalsIgnoreCase(utf8)))
+      {
+        testEncoding = utf8;
+      }
+      else
+      {
+        testEncoding = utf16;
+      }
+
+      try
+      {
+        extCtx.setRequestCharacterEncoding(testEncoding);
+        String v = extCtx.getRequestCharacterEncoding();
+        if (v == null && s == null ||
+            v != null && s != null && v.equalsIgnoreCase(s))
+        {
+          testRunner.setTestResult(true,
+                                   "setRequestCharacterEncoding was correctly ignored after reading a parameter in an action request.");
+        }
+        else
+        {
+          testRunner.setTestResult(false,
+                                   "setRequestCharacterEncoding incorrectly set a new encoding after reading a parameter in an action request.");
+        }
+      }
+      catch (Exception e)
+      {
+        testRunner.setTestResult(false,
+                                 "setRequestCharacterEncoding was correctly ignored after reading a parameter in an action request.");
+      }
+      return "setRequestCharacterEncodingActionTest";
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      if (testRunner.getTestStatus())
+      {
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        return Constants.TEST_FAILED;
+      }
+    }
+  }
+
+
+  // Test is SingleRequest -- Render only
+
+  /******************** getRequestHeaderMap Tests ***************/
+  @BridgeTest(test = "getRequestHeaderMapRenderTest")
+  public String getRequestHeaderMapRenderTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    // Test the following:
+    //   1. Map is immutable
+    //   2. Map contains properties from the portlet request (that it should)
+    //   2. Doesn't contain the Content-Type property
+    //   3. Does include the Accept and Accept-Language
+
+    Map headerMap = extCtx.getRequestHeaderMap();
+    Enumeration propertyNames =
+      ((PortletRequest) extCtx.getRequest()).getPropertyNames();
+
+    // Test for immutability
+    try
+    {
+      String s = (String) headerMap.put("TestKey", "TestValue");
+      testRunner.setTestResult(false,
+                               "Failed: The Map returned from getRequestHeaderMap isn't immutable.");
+      return Constants.TEST_FAILED;
+    }
+    catch (Exception e)
+    {
+      // we expect to get an exception
+    }
+
+    Set<Map.Entry<String, String>> set = headerMap.entrySet();
+    int propsFound = 0;
+    for (Iterator<Map.Entry<String, String>> headers = set.iterator();
+         headers.hasNext(); )
+    {
+      Map.Entry<String, String> e = headers.next();
+      String key = e.getKey();
+      if (key.equalsIgnoreCase("content-type"))
+      {
+        testRunner.setTestResult(false,
+                                 "Failed: The Map returned from getRequestHeaderMap contains a content-type header but shouldn't.");
+        return Constants.TEST_FAILED;
+      }
+      else if (key.equalsIgnoreCase("content-length"))
+      {
+        testRunner.setTestResult(false,
+                                 "Failed: The Map returned from getRequestHeaderMap contains a content-length header but shouldn't.");
+        return Constants.TEST_FAILED;
+      }
+      else if (key.equalsIgnoreCase("accept"))
+      {
+        boolean found = false;
+        // parse the accept header into its parts
+        String[] accepts = trim(e.getValue().split(","));
+
+        Enumeration em =
+          ((PortletRequest) extCtx.getRequest()).getResponseContentTypes();
+
+        // Now ensure that all entries in the getResponseContentTypes enum are in the property
+        while (em.hasMoreElements())
+        {
+          String rct = ((String) em.nextElement());
+          for (int i = 0; i < accepts.length; i++)
+          {
+            if (rct.regionMatches(true, 0, accepts[i], 0, rct.length()))
+            {
+              found = true;
+              break;
+            }
+            if (!found)
+            {
+              testRunner.setTestResult(false,
+                                       "Failed: The Map returned from getRequestHeaderMap is missing a key returned in request.getResponseContentTypes: " +
+                                       rct);
+              return Constants.TEST_FAILED;
+            }
+          }
+        }
+      }
+      else if (key.equalsIgnoreCase("accept-language"))
+      {
+        // parse the accept header into its parts
+        String[] accepts = trim(e.getValue().split(","));
+
+        Enumeration em =
+          ((PortletRequest) extCtx.getRequest()).getLocales();
+
+        // Now ensure the two match
+        int found = 0;
+        while (em.hasMoreElements())
+        {
+          String rct =
+            ((Locale) em.nextElement()).toString().replace('_', '-');
+
+          for (int i = 0; i < accepts.length; i++)
+          {
+            if (rct.regionMatches(true, 0, accepts[i], 0, rct.length()))
+            {
+              found += 1;
+              break;
+            }
+          }
+        }
+        if (found != accepts.length)
+        {
+          testRunner.setTestResult(false,
+                                   "Failed: The Map returned from getRequestHeaderMap didn't contain an Accept-Language key with a value containing each of the locales returned from request.getResponseLocales segmented by a comma.");
+          return Constants.TEST_FAILED;
+        }
+      }
+    }
+
+    // Now enumerate the requests property Enumeration and make sure all are in this Map (except Content-Type)
+    while (propertyNames.hasMoreElements())
+    {
+      String prop = (String) propertyNames.nextElement();
+      if (!prop.equalsIgnoreCase("content-type") &&
+          !prop.equalsIgnoreCase("content-length"))
+      {
+        if (!headerMap.containsKey(prop))
+        {
+          testRunner.setTestResult(false,
+                                   "Failed: The Map returned from getRequestHeaderMap didn't contain all the key/values from request.getProperties. Its missing: " +
+                                   prop);
+          return Constants.TEST_FAILED;
+        }
+      }
+    }
+
+
+    // Otherwise all out tests passed:
+
+    testRunner.setTestResult(true,
+                             "The immutable Map returned from getRequestHeaderMap correctly threw an exception when written to.");
+    testRunner.appendTestDetail("The getRequestHeaderMap Map correctly didn't contain the content-type property.");
+    testRunner.appendTestDetail("The getRequestHeaderMap Map correctly didn't contain the content-length property.");
+    testRunner.appendTestDetail("The getRequestHeaderMap Map correctly contained an Accept property with a value containing entries from the concatenation of request.getResponseContentTypes segmented by a comma.");
+    testRunner.appendTestDetail("The getRequestHeaderMap Map correctly contained an Accept-Language property with a value equal to the concatenation of request.getLocales segmented by a comma.");
+    testRunner.appendTestDetail("The getRequestHeaderMap Map correctly contained all other properties returned by request.getProperties.");
+
+    return Constants.TEST_SUCCESS;
+
+  }
+
+  private String[] trim(String[] toTrim)
+  {
+    for (int i = 0; i < toTrim.length; i++)
+    {
+      toTrim[i] = toTrim[i].trim();
+    }
+    return toTrim;
+  }
+
+  // Test is MultiRequest -- tests both setting request in action and render
+  // Note:  this tests that you can't get an encoding after reading the parameter.
+  //        we can't test for the positive -- that the setEncoding actually works
+  //        as portlet containers are supposed to process the form parameters before
+  //        the portlet reads them  -- some containers (WebSphere) chooses to do this
+  //        before calling the portlet.
+
+  @BridgeTest(test = "getRequestHeaderMapActionTest")
+  public String getRequestHeaderMapActionTest(TestRunnerBean testRunner)
+  {
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      // Test the following:
+      //   1. Map is immutable
+      //   2. Map contains properties from the portlet request (that it should)
+      //   2. Doesn't contain the Content-Type property
+      //   3. Does include the Accept and Accept-Language
+
+      Map headerMap = extCtx.getRequestHeaderMap();
+      Enumeration propertyNames =
+        ((PortletRequest) extCtx.getRequest()).getPropertyNames();
+
+      // Test for immutability
+      try
+      {
+        String s = (String) headerMap.put("TestKey", "TestValue");
+        testRunner.setTestResult(false,
+                                 "Failed: The Map returned from getRequestHeaderMap isn't immutable.");
+        return "getRequestHeaderMapActionTest";
+      }
+      catch (Exception e)
+      {
+        // we expect to get an exception
+      }
+
+      Set<Map.Entry<String, String>> set = headerMap.entrySet();
+      int propsFound = 0;
+      for (Iterator<Map.Entry<String, String>> headers = set.iterator();
+           headers.hasNext(); )
+      {
+        Map.Entry<String, String> e = headers.next();
+        String key = e.getKey();
+        if (key.equalsIgnoreCase("accept"))
+        {
+          boolean found = false;
+          // parse the accept header into its parts
+          String[] accepts = trim(e.getValue().split(","));
+
+          Enumeration em =
+            ((PortletRequest) extCtx.getRequest()).getResponseContentTypes();
+
+          // Now ensure the two match
+          while (em.hasMoreElements())
+          {
+            String rct = ((String) em.nextElement());
+            for (int i = 0; i < accepts.length; i++)
+            {
+              if (rct.regionMatches(true, 0, accepts[i], 0, rct.length()))
+              {
+                found = true;
+                break;
+              }
+              if (!found)
+              {
+                testRunner.setTestResult(false,
+                                         "Failed: The Map returned from getRequestHeaderMap is missing a key returned in request.getResponseContentTypes: " +
+                                         rct);
+                return "getRequestHeaderMapActionTest";
+              }
+            }
+          }
+        }
+        else if (key.equalsIgnoreCase("accept-language"))
+        {
+          // parse the accept header into its parts
+          String[] accepts = trim(e.getValue().split(","));
+
+          Enumeration em =
+            ((PortletRequest) extCtx.getRequest()).getLocales();
+
+          // Now ensure the two match
+          int found = 0;
+          while (em.hasMoreElements())
+          {
+            String rct =
+              ((Locale) em.nextElement()).toString().replace('_', '-');
+
+            for (int i = 0; i < accepts.length; i++)
+            {
+              if (rct.regionMatches(true, 0, accepts[i], 0, rct.length()))
+              {
+                found += 1;
+                break;
+              }
+            }
+          }
+          if (found != accepts.length)
+          {
+            testRunner.setTestResult(false,
+                                     "Failed: The Map returned from getRequestHeaderMap didn't contain an Accept-Language key with a value containing each of the locales returned from request.getResponseLocales segmented by a comma.");
+            return "getRequestHeaderMapActionTest";
+          }
+        }
+      }
+
+      // Now enumerate the requests property Enumeration and make sure all are in this Map (except Content-Type)
+      while (propertyNames.hasMoreElements())
+      {
+        String prop = (String) propertyNames.nextElement();
+        if (!headerMap.containsKey(prop))
+        {
+          testRunner.setTestResult(false,
+                                   "Failed: The Map returned from getRequestHeaderMap didn't contain all the key/values from request.getProperties. Its missing: " +
+                                   prop);
+          return "getRequestHeaderMapActionTest";
+
+        }
+      }
+
+
+      // Otherwise all out tests passed:
+
+      testRunner.setTestResult(true,
+                               "The immutable Map returned from getRequestHeaderMap correctly threw an exception when written to.");
+      testRunner.appendTestDetail("The getRequestHeaderMap Map correctly contained an Accept property with a value containing entries from the concatenation of request.getResponseContentTypes segmented by a comma.");
+      testRunner.appendTestDetail("The getRequestHeaderMap Map correctly contained an Accept-Language key with a value equal to the concatenation of request.getLocales segmented by a comma.");
+      testRunner.appendTestDetail("The getRequestHeaderMap Map correctly contained all other properties returned by request.getProperties.");
+
+      return "getRequestHeaderMapActionTest";
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+
+      if (testRunner.getTestStatus())
+      {
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        return Constants.TEST_FAILED;
+      }
+    }
+  }
+
+  // Test is SingleRequest -- Render only
+
+  /******************** getRequestHeaderValuesMap Tests ***************/
+  @BridgeTest(test = "getRequestHeaderValuesMapRenderTest")
+  public String getRequestHeaderValuesMapRenderTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    // Test the following:
+    //   1. Map is immutable
+    //   2. Map contains properties from the portlet request (that it should)
+    //   2. Doesn't contain the Content-Type property
+    //   3. Does include the Accept and Accept-Language
+
+    Map<String, String[]> headerMap = extCtx.getRequestHeaderValuesMap();
+    Enumeration propertyNames =
+      ((PortletRequest) extCtx.getRequest()).getPropertyNames();
+
+    // Test for immutability
+    try
+    {
+      String[] s = (String[]) headerMap.put("TestKey", new String[]
+          { "TestValue" });
+      testRunner.setTestResult(false,
+                               "Failed: The Map returned from getRequestHeaderValuesMap isn't immutable.");
+      return Constants.TEST_FAILED;
+    }
+    catch (Exception e)
+    {
+      // we expect to get an exception
+    }
+
+    Set<Map.Entry<String, String[]>> set = headerMap.entrySet();
+    int propsFound = 0;
+    for (Iterator<Map.Entry<String, String[]>> headers = set.iterator();
+         headers.hasNext(); )
+    {
+      Map.Entry<String, String[]> e = headers.next();
+      String key = e.getKey();
+      if (key.equalsIgnoreCase("content-type"))
+      {
+        testRunner.setTestResult(false,
+                                 "Failed: The Map returned from getRequestHeaderValuesMap contains a content-type header but shouldn't.");
+        return Constants.TEST_FAILED;
+      }
+      else if (key.equalsIgnoreCase("content-length"))
+      {
+        testRunner.setTestResult(false,
+                                 "Failed: The Map returned from getRequestHeaderValuesMap contains a content-length header but shouldn't.");
+        return Constants.TEST_FAILED;
+      }
+      else if (key.equalsIgnoreCase("accept"))
+      {
+        boolean found = false;
+        // parse the accept header into its parts
+        String[] acceptsValues = e.getValue();
+        String[] accepts = null;
+        int count = 0;
+        for (int i = 0; i < acceptsValues.length; i++)
+        {
+          String[] temp = trim(acceptsValues[i].split(","));
+          if (accepts == null)
+          {
+            accepts = new String[temp.length];
+          }
+          else
+          {
+            String[] acceptsTemp =
+              new String[accepts.length + temp.length];
+            System.arraycopy(accepts, 0, acceptsTemp, 0, count);
+            accepts = acceptsTemp;
+          }
+          System.arraycopy(temp, 0, accepts, count, temp.length);
+          count += temp.length;
+        }
+
+
+        Enumeration em =
+          ((PortletRequest) extCtx.getRequest()).getResponseContentTypes();
+
+        // Now ensure that all entries in the getResponseContentTypes enum are in the property
+        while (em.hasMoreElements())
+        {
+          String rct = ((String) em.nextElement());
+          for (int i = 0; i < accepts.length; i++)
+          {
+            if (rct.regionMatches(true, 0, accepts[i], 0, rct.length()))
+            {
+              found = true;
+              break;
+            }
+            if (!found)
+            {
+              testRunner.setTestResult(false,
+                                       "Failed: The Map returned from getRequestHeaderValuesMap is missing a key returned in request.getResponseContentTypes: " +
+                                       rct);
+              return Constants.TEST_FAILED;
+            }
+          }
+        }
+      }
+      else if (key.equalsIgnoreCase("accept-language"))
+      {
+        // parse the accept header into its parts
+        String[] acceptLangValues = e.getValue();
+        String[] accepts = null;
+        int count = 0;
+        for (int i = 0; i < acceptLangValues.length; i++)
+        {
+          String[] temp = trim(acceptLangValues[i].split(","));
+          if (accepts == null)
+          {
+            accepts = new String[temp.length];
+          }
+          else
+          {
+            String[] acceptsTemp =
+              new String[accepts.length + temp.length];
+            System.arraycopy(accepts, 0, acceptsTemp, 0, count);
+            accepts = acceptsTemp;
+          }
+          System.arraycopy(temp, 0, accepts, count, temp.length);
+        }
+
+        Enumeration em =
+          ((PortletRequest) extCtx.getRequest()).getLocales();
+
+        // Now ensure the two match
+        int found = 0;
+        while (em.hasMoreElements())
+        {
+          String rct =
+            ((Locale) em.nextElement()).toString().replace('_', '-');
+
+          for (int i = 0; i < accepts.length; i++)
+          {
+            if (rct.regionMatches(true, 0, accepts[i], 0, rct.length()))
+            {
+              found += 1;
+              break;
+            }
+          }
+        }
+        if (found != accepts.length)
+        {
+          testRunner.setTestResult(false,
+                                   "Failed: The Map returned from getRequestHeaderValuesMap didn't contain an Accept-Language key with a value containing each of the locales returned from request.getResponseLocales segmented by a comma.");
+          return Constants.TEST_FAILED;
+        }
+      }
+    }
+
+    // Now enumerate the requests property Enumeration and make sure all are in this Map (except Content-Type)
+    while (propertyNames.hasMoreElements())
+    {
+      String prop = (String) propertyNames.nextElement();
+      if (!prop.equalsIgnoreCase("content-type") &&
+          !prop.equalsIgnoreCase("content-length"))
+      {
+        if (!headerMap.containsKey(prop))
+        {
+          testRunner.setTestResult(false,
+                                   "Failed: The Map returned from getRequestHeaderValuesMap didn't contain all the key/values from request.getProperties. Its missing: " +
+                                   prop);
+          return Constants.TEST_FAILED;
+        }
+      }
+    }
+
+
+    // Otherwise all out tests passed:
+
+    testRunner.setTestResult(true,
+                             "The immutable Map returned from getRequestHeaderValuesMap correctly threw an exception when written to.");
+    testRunner.appendTestDetail("The getRequestHeaderValuesMap Map correctly didn't contain the content-type property.");
+    testRunner.appendTestDetail("The getRequestHeaderValuesMap Map correctly didn't contain the content-length property.");
+    testRunner.appendTestDetail("The getRequestHeaderValuesMap Map correctly contained an Accept property with a value containing entries from the concatenation of request.getResponseContentTypes segmented by a comma.");
+    testRunner.appendTestDetail("The getRequestHeaderValuesMap Map correctly contained an Accept-Language property with a value equal to the concatenation of request.getLocales segmented by a comma.");
+    testRunner.appendTestDetail("The getRequestHeaderValuesMap Map correctly contained all other properties returned by request.getProperties.");
+
+    return Constants.TEST_SUCCESS;
+
+  }
+
+  // Test is MultiRequest -- tests both setting request in action and render
+  // Note:  this tests that you can't get an encoding after reading the parameter.
+  //        we can't test for the positive -- that the setEncoding actually works
+  //        as portlet containers are supposed to process the form parameters before
+  //        the portlet reads them  -- some containers (WebSphere) chooses to do this
+  //        before calling the portlet.
+
+  @BridgeTest(test = "getRequestHeaderValuesMapActionTest")
+  public String getRequestHeaderValuesMapActionTest(TestRunnerBean testRunner)
+  {
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+
+    // This tests that we can encode a new mode in an actionURL
+    // done by navigation rule.
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      // Test the following:
+      //   1. Map is immutable
+      //   2. Map contains properties from the portlet request (that it should)
+      //   2. Doesn't contain the Content-Type property
+      //   3. Does include the Accept and Accept-Language
+
+      Map<String, String[]> headerMap = extCtx.getRequestHeaderValuesMap();
+      Enumeration propertyNames =
+        ((PortletRequest) extCtx.getRequest()).getPropertyNames();
+
+      // Test for immutability
+      try
+      {
+        String[] s = (String[]) headerMap.put("TestKey", new String[]
+            { "TestValue" });
+        headerMap.put("TestKey", s);
+        testRunner.setTestResult(false,
+                                 "Failed: The Map returned from getRequestHeaderMap isn't immutable.");
+        return "getRequestHeaderValuesMapActionTest";
+      }
+      catch (Exception e)
+      {
+        // we expect to get an exception
+      }
+
+      Set<Map.Entry<String, String[]>> set = headerMap.entrySet();
+      int propsFound = 0;
+      for (Iterator<Map.Entry<String, String[]>> headers = set.iterator();
+           headers.hasNext(); )
+      {
+        Map.Entry<String, String[]> e = headers.next();
+        String key = e.getKey();
+        if (key.equalsIgnoreCase("accept"))
+        {
+          boolean found = false;
+          // parse the accept header into its parts
+          String[] acceptsValues = e.getValue();
+          String[] accepts = null;
+          int count = 0;
+          for (int i = 0; i < acceptsValues.length; i++)
+          {
+            String[] temp = trim(acceptsValues[i].split(","));
+            if (accepts == null)
+            {
+              accepts = new String[temp.length];
+            }
+            else
+            {
+              String[] acceptsTemp =
+                new String[accepts.length + temp.length];
+              System.arraycopy(accepts, 0, acceptsTemp, 0, count);
+              accepts = acceptsTemp;
+            }
+            System.arraycopy(temp, 0, accepts, count, temp.length);
+          }
+
+          Enumeration em =
+            ((PortletRequest) extCtx.getRequest()).getResponseContentTypes();
+
+          // Now ensure the two match
+          while (em.hasMoreElements())
+          {
+            String rct = ((String) em.nextElement());
+            for (int i = 0; i < accepts.length; i++)
+            {

[... 1689 lines stripped ...]