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 2010/02/11 18:24:27 UTC

svn commit: r909087 [1/2] - in /myfaces/portlet-bridge/testsuite/trunk: ./ src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/ src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/ src/main/java/org/apache/myfaces/portlet/faces/t...

Author: mfreedman
Date: Thu Feb 11 17:23:51 2010
New Revision: 909087

URL: http://svn.apache.org/viewvc?rev=909087&view=rev
Log:
Added Tests for EL (section 6.5) as well as ViewHandler tests (6.2).
pom.xml updated to generate a portlet 2.0 war

Added:
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_2_1/
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_2_1/Tests.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_6/
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_6/Tests.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/SingleRequestAfterContentTest.jsp
    myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/chapter6_5.jsp
Removed:
    myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/chapter6.jsp
Modified:
    myfaces/portlet-bridge/testsuite/trunk/pom.xml
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/TestRunnerBean.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/Constants.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/GenericFacesTestSuitePortlet.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/application/TestSuiteViewHandlerImpl.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/context/TCK_FacesContextImpl.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_5/section_5_2/ManualBridgeInvokePortlet.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_5_1/Tests.java
    myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/portlet.xml

Modified: myfaces/portlet-bridge/testsuite/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/pom.xml?rev=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/pom.xml (original)
+++ myfaces/portlet-bridge/testsuite/trunk/pom.xml Thu Feb 11 17:23:51 2010
@@ -53,6 +53,7 @@
     <jsf.impl.groupId>${jsf.groupId}</jsf.impl.groupId>
     <jsf.impl.artifactId>jsf-impl</jsf.impl.artifactId>
     <jsf.impl.version>${jsf.version}</jsf.impl.version>
+    <jstl.version>1.2</jstl.version>
 
     <!-- Implementation Configurations -->    
     <jetty.version>6.1.10</jetty.version>
@@ -132,6 +133,13 @@
         <version>${pluto-embedded.version}</version>
         <scope>provided</scope>
       </dependency>
+
+      <dependency>
+        <groupId>javax.servlet</groupId>
+        <artifactId>jstl</artifactId>
+        <version>${jstl.version}</version>
+        <scope>compile</scope>
+      </dependency>
     </dependencies>
   </dependencyManagement>
   
@@ -342,7 +350,21 @@
               </goals>
             </execution>
           </executions>
-        </plugin>  
+        </plugin>
+ 
+        <plugin>
+          <groupId>org.apache.portals.pluto</groupId>
+          <artifactId>maven-pluto-plugin</artifactId>
+          <version>2.0.0</version>
+          <executions>
+            <execution>
+              <phase>generate-resources</phase>
+              <goals>
+                <goal>assemble</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
       </plugins>
     </pluginManagement>
   </build>
@@ -421,6 +443,7 @@
       
     </profile>
     
+    <!-- Generates a war file to work in a Pluto 1.x environment --> 
     <profile>
       <id>tck-war-pluto</id>
       <activation>
@@ -430,6 +453,13 @@
         </property>
       </activation>
 
+      <dependencies>
+        <dependency>
+          <groupId>javax.servlet</groupId>
+          <artifactId>jstl</artifactId>
+        </dependency>
+      </dependencies>
+
       <build>
         <plugins>
           <plugin>
@@ -446,6 +476,44 @@
       </build>      
     </profile>
 
+    <!-- Generates a war file to work in a Pluto 2.0 environment -->    
+    <profile>
+      <id>tck-war-pluto-2</id>
+      <activation>
+        <property>
+          <name>tck.generate-war</name>
+          <value>pluto2.0</value>
+        </property>
+      </activation>
+
+      <properties>
+        <pluto.plugin.groupId>org.apache.portals.pluto</pluto.plugin.groupId>
+        <pluto.version>2.0.0</pluto.version>
+      </properties>
+
+      <dependencies>
+        <dependency>
+          <groupId>javax.servlet</groupId>
+          <artifactId>jstl</artifactId>
+        </dependency>
+      </dependencies>
+
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.portals.pluto</groupId>
+            <artifactId>maven-pluto-plugin</artifactId>
+          </plugin>
+          <plugin>
+            <artifactId>maven-war-plugin</artifactId>
+            <configuration>
+              <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
     <!-- This profile switches the jsf implementation from mojarra to myfaces. -->    
     <profile>
       <id>jsf-myfaces</id>

Modified: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/TestRunnerBean.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/TestRunnerBean.java?rev=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/TestRunnerBean.java (original)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/TestRunnerBean.java Thu Feb 11 17:23:51 2010
@@ -117,6 +117,12 @@
     return getTestResult(runTest());
   }
   
+  // Run the test and renders the result 
+  public String getRenderTestResultAsAfterContent()
+  {
+    return getTestResultAsAfterContent(runTest());
+  }
+  
   public String getRedisplayLinkName()
   {
     // Still running test is test is neither marked complete in the bean itself or in the session attribute
@@ -158,6 +164,15 @@
     return mResultWriter.toString();
   }
   
+  public String getTestResultAsAfterContent(String s)
+  {
+    String result = getTestResult(s);
+    char[] resultChars = result.toCharArray();
+    
+    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("javax.portlet.faces.AfterViewContent", resultChars);
+    return "";
+  }
+  
   public String getTestResult()
   {
     if (mResultWriter == null)

Modified: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/Constants.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/Constants.java?rev=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/Constants.java (original)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/Constants.java Thu Feb 11 17:23:51 2010
@@ -23,6 +23,7 @@
 {
   public final static String TEST_BEAN_NAME = "org.apache.myfaces.portlet.faces.testsuite.common.testBean";
   public final static String TEST_NAME = "org.apache.myfaces.portlet.faces.testsuite.common.testName";
+  public final static String PORTLET_CONFIG = "org.apache.myfaces.portlet.faces.testsuite.common.portletConfig";
   public final static String TEST_FAILED = "FAILED";
   public final static String TEST_SUCCESS = "SUCCESS";
 }
\ No newline at end of file

Modified: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/GenericFacesTestSuitePortlet.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/GenericFacesTestSuitePortlet.java?rev=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/GenericFacesTestSuitePortlet.java (original)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/GenericFacesTestSuitePortlet.java Thu Feb 11 17:23:51 2010
@@ -94,6 +94,7 @@
   {
     portletRequest.setAttribute(Constants.TEST_BEAN_NAME, mTestBeanName);
     portletRequest.setAttribute(Constants.TEST_NAME, mTestName);
+    portletRequest.setAttribute(Constants.PORTLET_CONFIG, this.getPortletConfig());
     
     if (portletRequest.getParameter(Bridge.VIEW_ID) != null)
     {

Modified: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/application/TestSuiteViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/application/TestSuiteViewHandlerImpl.java?rev=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/application/TestSuiteViewHandlerImpl.java (original)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/application/TestSuiteViewHandlerImpl.java Thu Feb 11 17:23:51 2010
@@ -65,7 +65,6 @@
 
   // the ViewHandler to delegate to
   private ViewHandler mDelegate;
-  private Bridge.BridgeRenderPolicy mRenderPolicy = null;
 
   public TestSuiteViewHandlerImpl(ViewHandler handler)
   {
@@ -98,8 +97,9 @@
   public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException,
                                                                        FacesException
   {
-    // Do nothing when not running in portlet request
-    if (!BridgeUtil.isPortletRequest())
+    String testName = (String) context.getExternalContext().getRequestMap().get(Constants.TEST_NAME);
+    // Do nothing when not running in portlet request or not the specific test
+    if (!BridgeUtil.isPortletRequest() || testName == null || testName.indexOf("renderPolicyTest") < 0)
     {
       super.renderView(context, viewToRender);
       return;

Modified: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/context/TCK_FacesContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/context/TCK_FacesContextImpl.java?rev=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/context/TCK_FacesContextImpl.java (original)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/context/TCK_FacesContextImpl.java Thu Feb 11 17:23:51 2010
@@ -138,7 +138,7 @@
 
   public void release()
   { 
-    getExternalContext().getRequestMap().put("org.apache.portlet.faces.tck.facesContextReleased", Boolean.TRUE);
+    getExternalContext().getSessionMap().put("org.apache.portlet.faces.tck.facesContextReleased", Boolean.TRUE);
     mWrapped.release();
   }
 

Modified: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_5/section_5_2/ManualBridgeInvokePortlet.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_5/section_5_2/ManualBridgeInvokePortlet.java?rev=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_5/section_5_2/ManualBridgeInvokePortlet.java (original)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_5/section_5_2/ManualBridgeInvokePortlet.java Thu Feb 11 17:23:51 2010
@@ -68,16 +68,18 @@
     super.processAction(request, response);
     if (getTestName().equals(FACESCONTEXTRELEASED_ACTION_TEST))
     {
-      if (request.getAttribute("org.apache.portlet.faces.tck.facesContextReleased") != null)
+      if (request.getPortletSession(true).getAttribute("org.apache.portlet.faces.tck.facesContextReleased") != null)
       {
-        request.getPortletSession(true).setAttribute("org.apache.portlet.faces.tck.testResult", Boolean.TRUE);
+        request.getPortletSession().setAttribute("org.apache.portlet.faces.tck.testResult", Boolean.TRUE);
         request.getPortletSession().setAttribute("org.apache.portlet.faces.tck.testDetail", "Correctly released FacesContext at end of doFacesRequest (action).");
+        request.getPortletSession().removeAttribute("org.apache.portlet.faces.tck.facesContextReleased");
       }
       else
       {
-        request.getPortletSession(true).setAttribute("org.apache.portlet.faces.tck.testResult", Boolean.FALSE);
+        request.getPortletSession().setAttribute("org.apache.portlet.faces.tck.testResult", Boolean.FALSE);
         request.getPortletSession().setAttribute("org.apache.portlet.faces.tck.testDetail", "Didn't release FacesContext at end of doFacesRequest (action).");        
       }
+      
     }
     else if (getTestName().equals(PORTLETPHASEREMOVED_ACTION_TEST))
     {
@@ -136,9 +138,10 @@
     else if (getTestName().equals(FACESCONTEXTRELEASED_RENDER_TEST))
     {
       super.doDispatch(renderRequest, renderResponse);
-      if (renderRequest.getAttribute("org.apache.portlet.faces.tck.facesContextReleased") != null)
+      if (renderRequest.getPortletSession(true).getAttribute("org.apache.portlet.faces.tck.facesContextReleased") != null)
       {
         outputTestResult(renderResponse, Boolean.TRUE, "Correctly release FacesContext at end of render.");
+        renderRequest.getPortletSession().removeAttribute("org.apache.portlet.faces.tck.facesContextReleased");
       }
       else
       {

Modified: 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=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java (original)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_1_3_1/Tests.java Thu Feb 11 17:23:51 2010
@@ -1300,8 +1300,8 @@
 
   // Test is SingleRequest -- Render only
   // Test #6.32
-  @BridgeTest(test = "encodeResourceURLRelativeBackLinkTest")
-  public String encodeResourceURLRelativeBackLinkTest(TestRunnerBean testRunner)
+  @BridgeTest(test = "encodeResourceURLBackLinkTest")
+  public String encodeResourceURLBackLinkTest(TestRunnerBean testRunner)
   {
     testRunner.setTestComplete(true);
 
@@ -1332,13 +1332,13 @@
     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.");
+                               "encodeResourceURL correctly encoded an URL with a backLink.");
       return Constants.TEST_SUCCESS;
     }
     else
     {
       testRunner.setTestResult(false,
-                               "encodeResourceURL didn't correctly encoded a relative URL with a backLink.  Expected: " +
+                               "encodeResourceURL didn't correctly encoded an URL with a backLink.  Expected: " +
                                ((PortletResponse) extCtx.getResponse()).encodeURL(verifyString) +
                                " but encodeResourceURL returned: " +
                                extCtx.encodeResourceURL(URL_BACKLINK_TEST_STRING));

Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_2_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_2_1/Tests.java?rev=909087&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_2_1/Tests.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_2_1/Tests.java Thu Feb 11 17:23:51 2010
@@ -0,0 +1,141 @@
+/* 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.chapter_6.section_6_2_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.component.UIViewRoot;
+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.portlet.faces.annotation.ExcludeFromManagedRequestScope;
+import javax.portlet.faces.annotation.PortletNamingContainer;
+
+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
+  // Test #6.86
+  @BridgeTest(test = "isPortletNamingContainerTest")
+  public String isPortletNamingContainerTest(TestRunnerBean testRunner)
+  { 
+    UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
+    testRunner.setTestComplete(true);
+
+    if (viewRoot.getClass().getAnnotation(PortletNamingContainer.class) != null)
+    {
+      testRunner.setTestResult(true,  
+                             "UIViewRoot is correctly annotated with javax.portlet.faces.annotation.PortletNamingContainer.");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,  
+                             "UIViewRoot is not annotated with javax.portlet.faces.annotation.PortletNamingContainer.");
+      return Constants.TEST_FAILED;
+    }
+  }
+  
+  // Test is SingleRequest -- Render
+  // Test #6.88
+  @BridgeTest(test = "hasRenderContentAfterViewAttributeTest")
+  public String hasRenderContentAfterViewAttributeTest(TestRunnerBean testRunner)
+  { 
+    testRunner.setTestComplete(true);
+
+    Boolean afterViewContent = (Boolean) FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("javax.portlet.faces.RenderContentAfterView");
+    if (afterViewContent == null)
+    {
+      testRunner.setTestResult(false,  
+                             "javax.portlet.faces.RenderContentAfterView request attribute not set prior to render (dispatch).");
+      return Constants.TEST_FAILED;
+    }
+    else if (afterViewContent.booleanValue())
+    {
+      testRunner.setTestResult(true,  
+                             "javax.portlet.faces.RenderContentAfterView request attribute correctly set prior to render (dispatch).");
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      testRunner.setTestResult(false,  
+                             "javax.portlet.faces.RenderContentAfterView request attribute set but is FALSE.");
+      return Constants.TEST_FAILED;
+    }
+  }
+  
+  // Test is SingleRequest -- Render
+  // Test #6.89
+  @BridgeTest(test = "renderContentAfterViewTest")
+  public String renderContentAfterViewTest(TestRunnerBean testRunner)
+  { 
+    testRunner.setTestComplete(true);
+
+    testRunner.setTestResult(true,  
+                             "Content Rendered After View.");
+      return Constants.TEST_SUCCESS;
+  }
+  
+
+}

Modified: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_5_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_5_1/Tests.java?rev=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_5_1/Tests.java (original)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_5_1/Tests.java Thu Feb 11 17:23:51 2010
@@ -1,12 +1,12 @@
 /*
  *  Copyright 2009 .
- * 
+ *
  *  Licensed 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.
@@ -17,28 +17,38 @@
 
 package org.apache.myfaces.portlet.faces.testsuite.tests.chapter_6.section_6_5_1;
 
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import java.util.Set;
+
 import javax.el.ELResolver;
+
 import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.faces.render.ResponseStateManager;
+
 import javax.portlet.ActionRequest;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
-import javax.portlet.RenderRequest;
 import javax.portlet.faces.Bridge;
 import javax.portlet.faces.BridgeUtil;
 
+import javax.portlet.faces.preference.Preference;
+
 import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpSession;
+
 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;
@@ -47,454 +57,349 @@
  *
  * @author jhaley
  */
-public class Tests {
+public class Tests
+{
 
-    /**
-     * Testing JSF EL - implicits are in alpha order.
-     * @param testRunner
-     * @return
-     */
-      @BridgeTest(test = "JSF_ELTest")
-      public String JSF_ELTest(TestRunnerBean testRunner)
+  /**
+   * Testing JSF EL - implicits are in alpha order.
+   * @param testRunner
+   * @return
+   */
+  @BridgeTest(test = "JSF_ELTest")
+  public String JSF_ELTest(TestRunnerBean testRunner)
+  {
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    ELResolver facesResolver = ctx.getELContext().getELResolver();
+       
+    // Test that each implicit object is accessible and has the right value in 
+    // both the action phase and render phase
+    if (BridgeUtil.getPortletRequestPhase() == 
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      //ACTION REQUEST
+      try
+      {
+        // First ensure there are entries in the various scopes
+        ensureScopeEntries(extCtx);
+        
+        // JSF Implicit Objects:
+        // application -> ExternalContext.getContext();
+        testImplicitObject(testRunner, facesResolver, ctx, "application", extCtx.getContext());
+        // applicationScope -> externalContext.getApplicationMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "applicationScope", extCtx.getApplicationMap());
+        // cookie -> externalContext.getRequestCookieMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "cookie", extCtx.getRequestCookieMap());
+        // facesContext -> the FacesContext for this request
+        testImplicitObject(testRunner, facesResolver, ctx, "facesContext", ctx);
+        // header -> externalContext.getRequestHeaderMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "header", extCtx.getRequestHeaderMap());
+        // headerValues -> externalContext.getRequestHeaderValuesMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "headerValues", extCtx.getRequestHeaderValuesMap());
+        // initParam -> externalContext.getInitParameterMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "initParam", extCtx.getInitParameterMap());
+        // param -> externalContext.getRequestParameterMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "param", extCtx.getRequestParameterMap());
+        // paramValues -> externalContext.getRequestParameterValuesMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "paramValues", extCtx.getRequestParameterValuesMap());
+        // request -> externalContext.getRequest()
+        testImplicitObject(testRunner, facesResolver, ctx, "request", extCtx.getRequest());
+        // requestScope -> externalContext.getRequestScope()
+        testImplicitObject(testRunner, facesResolver, ctx, "requestScope", extCtx.getRequestMap());
+        // session -> externalContext.getSession()
+        testImplicitObject(testRunner, facesResolver, ctx, "session", extCtx.getSession(true));
+        // sessionScope -> externalContext.getSessionMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "sessionScope", extCtx.getSessionMap());
+        // view -> facesContext.getViewRoot()
+        testImplicitObject(testRunner, facesResolver, ctx, "view", ctx.getViewRoot());
+        
+        // Portlet implicit objects
+        // httpSessionScope:  mutable Map containing PortletSession attribute/values at APPLICATION_SCOPE.
+        testHttpSessionScope(testRunner, facesResolver, ctx, "httpSessionScope", (PortletSession) extCtx.getSession(true));
+        // mutablePortletPreferencesValues: mutable Map of type Map<String, javax.portlet.faces.preference.Preference>.  
+        testMutablePortletPreferencesValues(testRunner, facesResolver, ctx, "mutablePortletPreferencesValues", ((PortletRequest)extCtx.getRequest()).getPreferences().getMap());
+        // portletConfig -> object of type javax.portlet.PortletConfig
+        testImplicitObject(testRunner, facesResolver, ctx, "portletConfig", extCtx.getRequestMap().get(Constants.PORTLET_CONFIG));                                                                                                                                                                                      
+        // portletPreferences -> ExternalContext.getRequest().getPreferences() object.
+        testImplicitObject(testRunner, facesResolver, ctx, "portletPreferences", ((PortletRequest)extCtx.getRequest()).getPreferences());
+        // portletPreferencesValues -> ExternalContext.getRequest()).getPreferences().getMap().
+        testImplicitObjectArrayMaps(testRunner, facesResolver, ctx, "portletPreferencesValues", ((PortletRequest)extCtx.getRequest()).getPreferences().getMap());
+        // portletSession -> ExternalContext.getSession()
+        testImplicitObject(testRunner, facesResolver, ctx, "portletSession", extCtx.getSession(true));
+        // portletSessionScope -> ExternalContext.getSessionMap().
+        testImplicitObject(testRunner, facesResolver, ctx, "portletSessionScope", extCtx.getSessionMap());
+      }
+      catch (Throwable t)
+      {
+        testRunner.setTestResult(false, 
+                                 "JSF EL failure in action request: " + 
+                                 t.getCause().toString());
+      }
+      return "JSF_ELTest";
+    }
+    else //RENDER REQUEST
+    {
+
+
+      try
+      {
+        // JSF Implicit Objects
+        // application -> ExternalContext.getContext();
+        testImplicitObject(testRunner, facesResolver, ctx, "application", extCtx.getContext());
+        // applicationScope -> externalContext.getApplicationMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "applicationScope", extCtx.getApplicationMap());
+        // cookie -> externalContext.getRequestCookieMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "cookie", extCtx.getRequestCookieMap());
+        // facesContext -> the FacesContext for this request
+        testImplicitObject(testRunner, facesResolver, ctx, "facesContext", ctx);
+        // header -> externalContext.getRequestHeaderMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "header", extCtx.getRequestHeaderMap());
+        // headerValues -> externalContext.getRequestHeaderValuesMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "headerValues", extCtx.getRequestHeaderValuesMap());
+        // initParam -> externalContext.getInitParameterMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "initParam", extCtx.getInitParameterMap());
+        // param -> externalContext.getRequestParameterMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "param", extCtx.getRequestParameterMap());
+        // paramValues -> externalContext.getRequestParameterValuesMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "paramValues", extCtx.getRequestParameterValuesMap());
+        // request -> externalContext.getRequest()
+        testImplicitObject(testRunner, facesResolver, ctx, "request", extCtx.getRequest());
+        // requestScope -> externalContext.getRequestScope()
+        testImplicitObject(testRunner, facesResolver, ctx, "requestScope", extCtx.getRequestMap());
+        // session -> externalContext.getSession()
+        testImplicitObject(testRunner, facesResolver, ctx, "session", extCtx.getSession(true));
+        // sessionScope -> externalContext.getSessionMap()
+        testImplicitObject(testRunner, facesResolver, ctx, "sessionScope", extCtx.getSessionMap());
+        // view -> facesContext.getViewRoot()
+        testImplicitObject(testRunner, facesResolver, ctx, "view", ctx.getViewRoot());
+
+
+        // Portlet implicit objects
+        // httpSessionScope:  mutable Map containing PortletSession attribute/values at APPLICATION_SCOPE.
+        testHttpSessionScope(testRunner, facesResolver, ctx, "httpSessionScope", (PortletSession) extCtx.getSession(true));
+        // mutablePortletPreferencesValues: mutable Map of type Map<String, javax.portlet.faces.preference.Preference>.  
+        testMutablePortletPreferencesValues(testRunner, facesResolver, ctx, "mutablePortletPreferencesValues", ((PortletRequest)extCtx.getRequest()).getPreferences().getMap());
+        // portletConfig -> object of type javax.portlet.PortletConfig
+        testImplicitObject(testRunner, facesResolver, ctx, "portletConfig", extCtx.getRequestMap().get(Constants.PORTLET_CONFIG));                                                                                                                                                                                      
+        // portletPreferences -> ExternalContext.getRequest().getPreferences() object.
+        testImplicitObject(testRunner, facesResolver, ctx, "portletPreferences", ((PortletRequest)extCtx.getRequest()).getPreferences());
+        // portletPreferencesValues -> ExternalContext.getRequest()).getPreferences().getMap().
+        testImplicitObjectArrayMaps(testRunner, facesResolver, ctx, "portletPreferencesValues", ((PortletRequest)extCtx.getRequest()).getPreferences().getMap());
+        // portletSession -> ExternalContext.getSession()
+        testImplicitObject(testRunner, facesResolver, ctx, "portletSession", extCtx.getSession(true));
+        // portletSessionScope -> ExternalContext.getSessionMap().
+        testImplicitObject(testRunner, facesResolver, ctx, "portletSessionScope", extCtx.getSessionMap());
+        // renderRequest -> object of type javax.portlet.RenderRequest
+        testImplicitObject(testRunner, facesResolver, ctx, "renderRequest", extCtx.getRequest());
+        // renderResponse -> object of type javax.portlet.RenderResponse
+        testImplicitObject(testRunner, facesResolver, ctx, "renderResponse", extCtx.getResponse());
+      }
+      catch (Throwable t)
+      {
+        fail(testRunner, 
+                    "JSF EL failure in render request: " + t.getCause().toString());
+      }
+      
+      if (!testRunner.isTestComplete())
       {
-          if (BridgeUtil.getPortletRequestPhase() == Bridge.PortletPhase.ACTION_PHASE){
-              //ACTION REQUEST
-              try {
-                FacesContext ctx = FacesContext.getCurrentInstance();
-                ELResolver facesResolver = ctx.getELContext().getELResolver();
-                PortletRequest pReq = (PortletRequest) ctx.getExternalContext().getRequest();
-                
-
-                  //header in Faces EL resolves to a Map<String,String> with (in action request):
-                  // 1. map must include all props in request.getPropertyNames
-                  // 2. must have “Accept”, “Content-Type”, “Content-Length” and “Accept-Language”
-                  Map<String,String> headerFromFacesEL = (Map<String,String>) facesResolver.getValue(ctx.getELContext(), null, "header");
-                  if(headerFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                          return fail(testRunner,"implicit object 'header' failed to resolve in Faces EL.");
-                  }
-                  Enumeration propertyNames = pReq.getPropertyNames();
-                  while(propertyNames.hasMoreElements()){
-                      String name = (String) propertyNames.nextElement();
-                      String value = headerFromFacesEL.get(name);
-                      if(value == null){
-                          return fail(testRunner,"implicit object 'header' of Faces EL does not include all properties of the PortletRequest.");
-                      }
-                  }
-                  if(headerFromFacesEL.get("Accept") == null){
-                      return fail(testRunner,"implicit object 'header' of Faces EL does not include 'Accept' header in action request.");
-                  }
-                  if(headerFromFacesEL.get("Accept-Language") == null){
-                      return fail(testRunner,"implicit object 'header' of Faces EL does not include 'Accept-Language' header in action request.");
-                  }
-                  if(headerFromFacesEL.get("Content-Type") == null){
-                      return fail(testRunner,"implicit object 'header' of Faces EL does not include 'Content-Type' header in action request.");
-                  }
-                  if(headerFromFacesEL.get("Content-Length") == null){
-                      return fail(testRunner,"implicit object 'header' of Faces EL does not include 'Content-Length' header in action request.");
-                  }
-
-                  //headerValues in Faces EL resolved to a Map<String,String[]> with (in action request):
-                  // 1. map must include all props in request.getPropertyNames
-                  // 2. must have “Accept”, “Content-Type”, “Content-Length” and “Accept-Language”
-                  Map<String,String[]> headerValuesFromFacesEL = (Map<String,String[]>) facesResolver.getValue(ctx.getELContext(), null, "headerValues");
-                  if(headerValuesFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                          return fail(testRunner,"implicit object 'headerValues' failed to resolve in Faces EL.");
-                  }
-                  Enumeration reqPropertyNames = pReq.getPropertyNames();
-                  while(reqPropertyNames.hasMoreElements()){
-                      String name = (String) reqPropertyNames.nextElement();
-                      String value = headerFromFacesEL.get(name);
-                      if(value == null){
-                          return fail(testRunner,"implicit object 'headerValues' of Faces EL does not include all properties of the PortletRequest.");
-                      }
-                  }
-                  if(headerValuesFromFacesEL.get("Accept") == null){
-                      return fail(testRunner,"implicit object 'headerValues' of Faces EL does not include 'Accept' header in action request.");
-                  }
-                  if(headerValuesFromFacesEL.get("Accept-Language") == null){
-                      return fail(testRunner,"implicit object 'headerValues' of Faces EL does not include 'Accept-Language' header in action request.");
-                  }
-                  if(headerValuesFromFacesEL.get("Content-Type") == null){
-                      return fail(testRunner,"implicit object 'headerValues' of Faces EL does not include 'Content-Type' header in action request.");
-                  }
-                  if(headerValuesFromFacesEL.get("Content-Length") == null){
-                      return fail(testRunner,"implicit object 'headerValues' of Faces EL does not include 'Content-Length' header in action request.");
-                  }
-
-                  //request in Faces EL resolves to a PortletRequest
-                  // in an action request, this resolves to a ActionRequest.
-                  ActionRequest requestFromFacesEL = (ActionRequest) facesResolver.getValue(ctx.getELContext(), null, "request");
-                  if(requestFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                          return fail(testRunner,"implicit object 'request' failed to resolve in Faces EL, in action request.");
-                  }
-
-              }catch(Throwable t){
-                    testRunner.setTestResult(false, "JSF EL failure in action request: " + t.getCause().toString());
-              }
-              return "JSF_ELTest";
-          }
-          else //RENDER REQUEST
-          {
-
-          testRunner.setTestComplete(true);
-          FacesContext ctx = FacesContext.getCurrentInstance();
-          ELResolver facesResolver = ctx.getELContext().getELResolver();
-          PortletRequest pReq = (PortletRequest) ctx.getExternalContext().getRequest();
-
-          try {
-              //Faces EL
-
-              //application in Faces EL is a PortletContext; the application name can be accessed through it.
-              javax.portlet.PortletContext applicationFromFacesEL = (javax.portlet.PortletContext) facesResolver.getValue(ctx.getELContext(), null, "application");
-              if(applicationFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'application' failed to resolve in Faces EL.");
-              }
-              String applicationName = applicationFromFacesEL.getPortletContextName();
-              if(!applicationName.equals("bridge_Test_web")){
-                      return fail(testRunner,"implicit object 'application' failed to resolve application name in Faces EL.");
-               }
-
-              //applicationScope in Faces EL is a Map<String,Object>
-              // note - this test relies on success of 'application' to get the PortletContext for testing here.
-              //1. contains all attributes named in PortletContext.getAttributeNames().
-              //2. because the defaultViewIdMap is defined in portlet.xml for this portlet, it will always appear in this Map.
-              Map<String,Object> applicationScopeFromFacesEL = (Map<String,Object>) facesResolver.getValue(ctx.getELContext(), null, "applicationScope");
-              if(applicationScopeFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'applicationScope' failed to resolve in Faces EL.");
-              }
-              Map<String,String> defaultViewIdMap = (Map<String,String>) applicationScopeFromFacesEL.get("javax.portlet.faces.chapter6_5_1Tests-JSF_ELTest-portlet.defaultViewIdMap");
-              if(defaultViewIdMap == null || !defaultViewIdMap.get("view").equals("/tests/MultiRequestFormDataTest.jsp")){
-                      return fail(testRunner,"implicit object 'applicationScope' failed to resolve default viewId map in Faces EL.");
-               }
-              Enumeration portletContextAttributeNames = applicationFromFacesEL.getAttributeNames();
-              while(portletContextAttributeNames.hasMoreElements()){
-                  String name = (String) portletContextAttributeNames.nextElement();
-                  Object value = applicationScopeFromFacesEL.get(name);
-                  if(value == null){
-                      return fail(testRunner,"implicit object 'applicationScope' of Faces EL does not include all attributes of the PortletContext.");
-                  }
-              }
-
-              //cookie in Faces EL is an empty Map<String,Object>
-              Map<String,Object> cookieFromFacesEL = (Map<String,Object>) facesResolver.getValue(ctx.getELContext(), null, "cookie");
-              if(applicationScopeFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'cookie' failed to resolve in Faces EL.");
-              }
-              if(!cookieFromFacesEL.isEmpty()){
-                      return fail(testRunner,"implicit object 'cookie' is non-empty in Faces EL.");
-               }
-
-              //facesContext in Faces EL is equal to FacesContext.getCurrentInstance()
-              FacesContext facesContextFromFacesEL = (FacesContext) facesResolver.getValue(ctx.getELContext(), null, "facesContext");
-              if(facesContextFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'facesContext' failed to resolve in Faces EL.");
-              }
-              if(!facesContextFromFacesEL.equals(FacesContext.getCurrentInstance())){
-                   return fail(testRunner,"implicit object 'facesContext' not equal to FacesContext.currentInstance() in Faces EL.");
-              }
-
-              //header in Faces EL resolved to a Map<String,String> with:
-              // 1. map must include all props in request.getPropertyNames except Content-Type (excluded)
-              // 2. Accept and Accept-Language must exist in the map. (since this is render phase)
-              Map<String,String> headerFromFacesEL = (Map<String,String>) facesResolver.getValue(ctx.getELContext(), null, "header");
-              if(headerFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'header' failed to resolve in Faces EL.");
-              }
-              Enumeration propertyNames = pReq.getPropertyNames();
-              while(propertyNames.hasMoreElements()){
-                  String name = (String) propertyNames.nextElement();
-                  String value = headerFromFacesEL.get(name);
-                  if( name.equals("Content-Type") && value != null){
-                      return fail(testRunner,"implicit object 'header' of Faces EL does not exclude the Content-Type header in a render request.");
-                  }
-                  else if(value == null){
-                      return fail(testRunner,"implicit object 'header' of Faces EL does not include all properties of the PortletRequest.");
-                  }
-              }
-              if(headerFromFacesEL.get("Accept") == null){
-                  return fail(testRunner,"implicit object 'header' of Faces EL does not include 'Accept' header in render request.");
-              }
-              if(headerFromFacesEL.get("Accept-Language") == null){
-                  return fail(testRunner,"implicit object 'header' of Faces EL does not include 'Accept-Language' header in render request.");
-              }
-
-              //headerValues in Faces EL resolved to a Map<String,String[]> with:
-              // 1. map must include all props in request.getPropertyNames except Content-Type (excluded)
-              // 2. Accept and Accept-Language must exist in the map. (since this is render phase)
-              Map<String,String[]> headerValuesFromFacesEL = (Map<String,String[]>) facesResolver.getValue(ctx.getELContext(), null, "headerValues");
-              if(headerValuesFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'headerValues' failed to resolve in Faces EL.");
-              }
-              Enumeration reqPropertyNames = pReq.getPropertyNames();
-              while(reqPropertyNames.hasMoreElements()){
-                  String name = (String) reqPropertyNames.nextElement();
-                  String value = headerFromFacesEL.get(name);
-                  if( name.equals("Content-Type") && value != null){
-                      return fail(testRunner,"implicit object 'headerValues' of Faces EL does not exclude the Content-Type header in a render request.");
-                  }
-                  else if(value == null){
-                      return fail(testRunner,"implicit object 'headerValues' of Faces EL does not include all properties of the PortletRequest.");
-                  }
-              }
-              if(headerValuesFromFacesEL.get("Accept") == null){
-                  return fail(testRunner,"implicit object 'headerValues' of Faces EL does not include 'Accept' header in render request.");
-              }
-              if(headerValuesFromFacesEL.get("Accept-Language") == null){
-                  return fail(testRunner,"implicit object 'headerValues' of Faces EL does not include 'Accept-Language' header in render request.");
-              }
-
-              //initParam in Faces EL is a Map<String,Object> s.t.
-              //1. contains all parameters given by name in PortletContext.getInitParamterNames
-              //2. contains the javax.faces.DEFAULT_SUFFIX <context-param> from web.xml, as a particular init param test.
-               Map<String,Object> initParamFromFacesEL = (Map<String,Object>) ctx.getELContext().getELResolver().getValue(ctx.getELContext(), null, "initParam");
-              if(initParamFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'initParam' failed to resolve in Faces EL.");
-              }
-              String contextParm = (String) initParamFromFacesEL.get("javax.faces.DEFAULT_SUFFIX");
-              if(contextParm == null || !contextParm.equals(".jsp")){
-                      return fail(testRunner, "initParam in Faces EL not populated with web.xml context parameters.");
-              }
-              Enumeration initParmNames = applicationFromFacesEL.getInitParameterNames();
-              while(initParmNames.hasMoreElements()){
-                  String name = (String) initParmNames.nextElement();
-                  Object value = initParamFromFacesEL.get(name);
-                  if(value == null){
-                      return fail(testRunner,"implicit object 'initParam' of Faces EL does not include all parameters named in PortletContext.getInitParameterNames.");
-                  }
-              }
-
-              //param in Faces EL is an Iterator<String> s.t.
-              //1. contains all request parameters named in PortletRequest.getParamterNames
-              //2. in a render request following an action, contains request parm named ResponseStateManager.VIEW_STATE_PARAM
-              /*Iterator paramFromFacesEL = (Iterator) ctx.getELContext().getELResolver().getValue(ctx.getELContext(), null, "param");
-              if(paramFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'param' failed to resolve in Faces EL.");
-              }
-              Set requestParmsFromIterator = new HashSet();
-              while(paramFromFacesEL.hasNext()){
-                  requestParmsFromIterator.add(paramFromFacesEL.next());
-              }
-              Enumeration requestParmNames = pReq.getParameterNames();
-              while(requestParmNames.hasMoreElements()){
-                  String name = (String) requestParmNames.nextElement();
-                  if(!requestParmsFromIterator.contains(name)){
-                      return fail(testRunner,"implicit object 'param' of Faces EL does not include all request parameters named in PortletRequest.getParameterNames.");
-                  }
-              }
-              String[] viewStateParmValue = paramFromFacesEL.get(ResponseStateManager.VIEW_STATE_PARAM);
-              if(viewStateParmValue == null || viewStateParmValue.length == 0){
-                    return fail(testRunner,"implicit object 'paramValues' of Faces EL does not include the ResponseStateManager.VIEW_STATE_PARAM request parameter in a render request following an action.");
-              }*/ 
-
-              //paramValues in Faces EL is a Map<String,String[]> s.t.
-              //1. its keys contain all request parameters named in PortletRequest.getParamterNames
-              //2. in a render request follwing an action, contains request parm named ResponseStateManager.VIEW_STATE_PARAM
-              //3. because preserveActionParams is set in portlet definition, the
-              Map<String,String[]> paramValuesFromFacesEL = (Map<String,String[]>) ctx.getELContext().getELResolver().getValue(ctx.getELContext(), null, "paramValues");
-              if(paramValuesFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'paramValues' failed to resolve in Faces EL.");
-              }
-              Set<String> keys = paramValuesFromFacesEL.keySet();
-              Enumeration requestParmNames2 = pReq.getParameterNames();
-              while(requestParmNames2.hasMoreElements()){
-                  String name = (String) requestParmNames2.nextElement();
-                  if(!keys.contains(name)){
-                      return fail(testRunner,"implicit object 'paramValues' of Faces EL does not include all request parameters named in PortletRequest.getParameterNames.");
-                  }
-              }
-              String[] viewStateParmValue = paramValuesFromFacesEL.get(ResponseStateManager.VIEW_STATE_PARAM);
-              if(viewStateParmValue == null || viewStateParmValue.length == 0){
-                    return fail(testRunner,"implicit object 'paramValues' of Faces EL does not include the ResponseStateManager.VIEW_STATE_PARAM request parameter in a render request following an action.");
-              }
-              Map<String, String> paramMap = ctx.getExternalContext().getRequestParameterMap();
-               // loop through the Map and verify that 'value1' and 'value2' aren't there.
-              boolean foundField1 = false;
-              boolean foundField2 = false;
-              Set<Map.Entry<String, String>> set = paramMap.entrySet();
-              for (Iterator<Map.Entry<String, String>> params = set.iterator();
-                   params.hasNext(); )
-              {
-                Map.Entry<String, String> e = params.next();
-                String key = e.getKey();
-
-                // Can't look up by key because JSF munges this id
-                if (key.indexOf("formDataField1") > -1)
-                  foundField1 = true;
-                if (key.indexOf("formDataField2") > -1)
-                  foundField2 = true;
-              }
-              if(!foundField1 || !foundField2){
-                  return fail(testRunner,"implicit object 'paramValues' (of Faces EL) does not contain action params despite preserveActionParams being set to true.");
-              }
-              //request in Faces EL resolves to a PortletRequest
-              // in a render request, this resolves to a RenderRequest.
-              RenderRequest requestFromFacesEL = (RenderRequest) facesResolver.getValue(ctx.getELContext(), null, "request");
-              if(requestFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'request' failed to resolve in Faces EL.");
-              }
-
-              //requestScope in Faces EL resolves to a Map<String,Object> s.t.
-              // 1. its key set contains all attribute names returned in PortletRequest.getAttributeNames().
-              Map<String,Object> requestScopeFromFacesEL = (Map<String,Object>) facesResolver.getValue(ctx.getELContext(), null, "requestScope");
-              if(requestScopeFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'requestScope' failed to resolve in Faces EL.");
-              }
-              //this redundant copy works, but for some reason, requestScopeKeys used instead of newSet in the
-              //2nd while loop does not, hence the copy.
-              Set<String> requestScopeKeys = requestScopeFromFacesEL.keySet();
-              Set<String> newSet = new HashSet<String>();
-              Iterator<String> iter = requestScopeKeys.iterator();
-              while(iter.hasNext()){
-                  newSet.add(iter.next());
-              }
-              Enumeration requestAttributeNames = pReq.getAttributeNames();
-              while(requestAttributeNames.hasMoreElements()){
-                  String name = (String) requestAttributeNames.nextElement();
-                  if(!newSet.contains(name)){
-                      return fail(testRunner,"implicit object 'requestScope' of Faces EL does not include all request attributes named in PortletRequest.getAttributeNames.");
-                  }
-              }
-
-              //session in Faces EL resolves to a PortletSession and can access PORTLET_SCOPE attributes.
-              //PortletSession returned is identical to PortletRequest.getPortletSession()
-              //session could be null.
-              PortletSession sessionFromFacesEL = (PortletSession) facesResolver.getValue(ctx.getELContext(), null, "session");
-              if(!ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'session' failed to resolve in Faces EL.");
-              }
-              if(sessionFromFacesEL != null){
-                  if(sessionFromFacesEL.getAttribute("javax.portlet.faces.viewIdHistory.view") == null){
-                       return fail(testRunner,"implicit object 'session' failed to resolve PORTLET_SCOPE attribute javax.portlet.faces.viewIdHistory.view.");
-                  }
-                  if(!sessionFromFacesEL.equals(pReq.getPortletSession())){
-                      return fail(testRunner,"implicit object 'session' does not equal session returned in PortletRequest.getPortletSession().");
-                  }
-              }
-
-              //sessionScope in Faces EL is a Map<String,Object> s.t.
-              //1.  in its key set contains all names returned from PortletSession.getAttributeNames(PORTLET_SCOPE).
-              Map<String,String> sessionScopeFromFacesEL = (Map<String,String>) facesResolver.getValue(ctx.getELContext(), null, "sessionScope");
-              if(sessionScopeFromFacesEL == null || !ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'sessionScope' failed to resolve in Faces EL.");
-              }
-              Set<String> sessionScopeKeys = sessionScopeFromFacesEL.keySet();
-              Enumeration sessionAttributeNames = pReq.getPortletSession().getAttributeNames(PortletSession.PORTLET_SCOPE);
-              while(sessionAttributeNames.hasMoreElements()){
-                  String name = (String) sessionAttributeNames.nextElement();
-                  if(!sessionScopeKeys.contains(name)){
-                      return fail(testRunner,"implicit object 'sessionScope' of Faces EL does not include all session attributes named in PortletRequest.getAttributeNames(PORTLET_SCOPE).");
-                  }
-              }
-
-              //view in Faces EL resolves to a UIViewRoot equal to that returned from FacesContext.getViewRoot.
-              UIViewRoot view = (UIViewRoot) facesResolver.getValue(ctx.getELContext(), null, "view");
-              if(view == null || !ctx.getELContext().isPropertyResolved()){
-                  return fail(testRunner,"implicit object 'view' failed to resolve in Faces EL.");
-              }
-              if(!view.equals(ctx.getViewRoot())){
-                  return fail(testRunner,"implicit object 'view' does not equal UIViewRoot returned in FacesContext.getViewRoot().");
-              }
-
-              }catch(Throwable t){
-                  return fail(testRunner,"Failure in Faces EL resolve: " + t.getCause().toString());
-              }
-          //all JSF EL is correct, pass the test:
-          testRunner.setTestResult(true,"JSF_ELTest correct.");
-          return Constants.TEST_SUCCESS;
-        }
+        // Things completed successfully
+        testRunner.setTestComplete(true);
+        testRunner.setTestResult(true, "JSF EL impicit objects correctly resolved in both action and render phases.");
+        return Constants.TEST_SUCCESS;
       }
+      else
+      {
+        return Constants.TEST_FAILED;
+      }
+
+    }
+  }
+
+  /**
+   * Testing JSP EL.
+   * @param testRunner
+   * @return
+   */
+  
+
+  @BridgeTest(test = "JSP_ELTest")
+  public String JSP_ELTest(TestRunnerBean testRunner)
+  {
+    testRunner.setTestComplete(true);
+    Map<String, Object> m = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+    
+    Boolean status = (Boolean) m.get("org.apache.myfaces.portlet.faces.TCK.status");
+    
+    testRunner.setTestResult(status.booleanValue(), (String) m.get("org.apache.myfaces.portlet.faces.TCK.detail"));
+    if (status.booleanValue())
+    {
+      return Constants.TEST_SUCCESS;
+    }
+    else
+    {
+      return Constants.TEST_FAILED;
+    }
 
-      /**
-       * Testing JSP EL.
-       * @param testRunner
-       * @return
-       */
-      @BridgeTest(test = "JSP_ELTest")
-      public String JSP_ELTest(TestRunnerBean testRunner)
+  }
+
+  
+  private void ensureScopeEntries(ExternalContext extCtx)
+  {
+    // App Scope
+    extCtx.getApplicationMap().put("org.apache.myfaces.portlet.faces.TCK.appScopeAttr", Boolean.TRUE);
+    
+    // Session scope (portlet scope)
+    extCtx.getSessionMap().put("org.apache.myfaces.portlet.faces.TCK.portletSessionScopeAttr", Boolean.TRUE);
+    
+    // Session scope (app scope)
+    ((PortletSession) extCtx.getSession(true)).setAttribute("org.apache.myfaces.portlet.faces.TCK.applicationSessionScopeAttr", Boolean.TRUE, PortletSession.APPLICATION_SCOPE);
+    
+    // Request scope
+    extCtx.getRequestMap().put("org.apache.myfaces.portlet.faces.TCK.requestScopeAttr", Boolean.TRUE);
+  }
+  
+  private void testImplicitObject(TestRunnerBean testRunner, ELResolver resolver, FacesContext ctx, String implicitObject, Object compareTo)
+  {
+    Object objectFromFacesEL = resolver.getValue(ctx.getELContext(), 
+                                                   null, implicitObject);
+    if (objectFromFacesEL == null || 
+        !ctx.getELContext().isPropertyResolved())
+    {
+      fail(testRunner, 
+                  "implicit object " + implicitObject + " didn't resolve using the Faces EL resolver.");
+    }
+    else if (objectFromFacesEL != compareTo && !objectFromFacesEL.equals(compareTo))
+    {
+      fail(testRunner, 
+                    "implicit object  " + implicitObject + " resolved using the Faces EL resolver but its not equal to what is expected.");
+    }
+  }
+  
+  private void testImplicitObjectArrayMaps(TestRunnerBean testRunner, ELResolver resolver, FacesContext ctx, String implicitObject, Map<String, String[]> compareTo)
+  {
+    Map<String, String[]> objectFromFacesEL = (Map<String, String[]>) resolver.getValue(ctx.getELContext(), 
+                                                   null, implicitObject);
+    if (objectFromFacesEL == null || 
+        !ctx.getELContext().isPropertyResolved())
+    {
+      fail(testRunner, 
+                  "implicit object " + implicitObject + " didn't resolve using the Faces EL resolver.");
+    }
+    else if (!arrayMapsEquals(objectFromFacesEL, compareTo))
+    {
+      fail(testRunner, 
+                    "implicit object  " + implicitObject + " resolved using the Faces EL resolver but its not equal to what is expected.");
+    }
+  }
+  
+  private boolean arrayMapsEquals(Map<String, String[]> a, Map<String, String[]> b)
+  {
+    if (a == b) return true;
+    if (a.size() != b.size()) return false;
+    for (Iterator<Map.Entry<String, String[]>> i = a.entrySet().iterator(); i.hasNext();)
+    {
+      Map.Entry<String, String[]> e = i.next();
+      if (!Arrays.equals(e.getValue(), b.get(e.getKey())))
+        return false;
+    }
+    return true;
+  }
+  
+  private void testHttpSessionScope(TestRunnerBean testRunner, ELResolver resolver, FacesContext ctx, String implicitObject, PortletSession session)
+  {
+    Map<String, Object> objectFromFacesEL = (Map<String, Object>) resolver.getValue(ctx.getELContext(), 
+                                                   null, implicitObject);
+    if (objectFromFacesEL == null || 
+        !ctx.getELContext().isPropertyResolved())
+    {
+      fail(testRunner, 
+                  "implicit object " + implicitObject + " didn't resolve using the Faces EL resolver.");
+      return;
+    }
+    
+    // Now compare the result
+    // iterate over the Map and make sure each is in the portlet session app scope
+    for (Iterator<Map.Entry<String, Object>> i = objectFromFacesEL.entrySet().iterator(); i.hasNext();)
+    {
+      Map.Entry<String, Object> e = i.next();
+      Object compareTo = session.getAttribute(e.getKey(), PortletSession.APPLICATION_SCOPE);
+      if (compareTo == null)
+      {
+        fail(testRunner, "resolved implicit object httpSessionScope contains an entry that isn't in the portlet's session APPLICATION_SCOPE: " +
+             e.getKey());
+      }
+      else if (!e.getValue().equals(compareTo))
+      {
+        fail(testRunner, "resolved implicit object httpSessionScope contains an entry whose value differs from the one in the portlet's session APPLICATION_SCOPE" +
+             e.getKey());
+      } 
+    }
+    
+    // Now verify that the Map contained the correct number of entries
+    Enumeration en = session.getAttributeNames(PortletSession.APPLICATION_SCOPE);
+    int count = 0;
+    while (en.hasMoreElements())
+    {
+      en.nextElement();
+      count++;
+    }
+    
+    if (count != objectFromFacesEL.size())
+    {
+      fail(testRunner, 
+           "resolved implicit object httpSessionScope doesn't contain the same number of entries as are in the portlet's session ApplicationScope.");
+    }
+  }
+  
+  private void testMutablePortletPreferencesValues(TestRunnerBean testRunner, ELResolver resolver, FacesContext ctx, String implicitObject, Map<String, String[]> prefMap)
+  {
+    Map<String, Preference> objectFromFacesEL = (Map<String, Preference>) resolver.getValue(ctx.getELContext(), 
+                                                   null, implicitObject);
+    if (objectFromFacesEL == null || 
+        !ctx.getELContext().isPropertyResolved())
+    {
+      fail(testRunner, 
+                  "implicit object " + implicitObject + " didn't resolve using the Faces EL resolver.");
+      return;
+    }
+    
+    if (objectFromFacesEL.size() != prefMap.size())
+    {
+      fail(testRunner, 
+           "resolved implicit object mutablePortletPreferencesValues doesn't contain the same number of entries as are in the portlet's preference Map.");
+    }
+    
+    // Now test that the Map contains the same entries as the immutable preference Map
+    for (Iterator<Map.Entry<String, Preference>> i = objectFromFacesEL.entrySet().iterator(); i.hasNext();)
+    {
+      Map.Entry<String, Preference> e = i.next();
+      List<String> portletPrefValues = Arrays.asList(prefMap.get(e.getKey()));
+      if (portletPrefValues == null)
       {
-          if (BridgeUtil.getPortletRequestPhase() == Bridge.PortletPhase.ACTION_PHASE){
-                  //if called in action phase, some error in config - fail the test.
-                  return fail(testRunner, "JSP_ELTest failed - called in action request");
-          }
-          else {
-          testRunner.setTestComplete(true);
-          FacesContext ctx = FacesContext.getCurrentInstance();
-          ELResolver facesResolver = ctx.getELContext().getELResolver();
-          PortletRequest pReq = (PortletRequest) ctx.getExternalContext().getRequest();
-
-          try{
-              //JSP EL
-              //pageContext.session in JSP EL resolves to HttpSession and not PortletSession.
-              //further, it cannot access PORTLET_SCOPE attributes available on the PortletSession.
-              HttpSession sessionFromJSPEL = (HttpSession) pReq.getAttribute("pageContext_session");
-              if(sessionFromJSPEL instanceof PortletSession){
-                  return fail(testRunner, "pageContext.session returned PortletSession in JSP EL.");
-              }
-              if(sessionFromJSPEL.getAttribute("javax.portlet.faces.viewIdHistory.view") != null){
-                   return fail(testRunner,"pageContext.session accessed PORTLET_SCOPE attribute javax.portlet.faces.viewIdHistory.view.");
-              }
-
-              //pageContext.servletContext in JSP EL resolves to ServletContext and not PortletContext
-              ServletContext servletContextFromJSPEL = (ServletContext) pReq.getAttribute("pageContext_servletContext");
-              if(servletContextFromJSPEL instanceof PortletContext){
-                  return fail(testRunner, "pageContext.servletContext returned PortletContext in JSP EL.");
-              }
-
-              //pageContext.request in JSP EL resolves to HttpServletRequest;
-              HttpServletRequest requestFromJSPEL = (HttpServletRequest) pReq.getAttribute("pageContext_request");
-              if(requestFromJSPEL instanceof PortletRequest){
-                  PortletRequest portletRequestCast = (PortletRequest) requestFromJSPEL;
-              }
-
-              //application in JSP EL resolves to PortletContext and not to ServletContext.
-              PortletContext applicationFromJSPEL = (PortletContext) pReq.getAttribute("application");
-              if(applicationFromJSPEL instanceof ServletContext){
-                  return fail(testRunner, "application returns ServletContext in JSP EL.");
-              }
-              String applicationName = applicationFromJSPEL.getPortletContextName();
-              if(!applicationName.equals("bridge_Test_web")){
-                      return fail(testRunner,"implicit object 'application' failed to resolve application name in JSP EL.");
-               }
-
-
-              /* TODO - investigate IllegalStateException PWC6243 cannot access session scope failure
-               * in deref of sessionScope here:
-               obj = pReq.getAttribute("sessionScope");
-              if(!(obj instanceof Map)){
-                  return fail(testRunner, "sessionScope failed in JSP EL.");
-              }
-              Map<String,String> castMap = (Map) obj;*/
-              System.out.println("");
-
-              //javax.servlet.jsp.JspFactory.getDefaultFactory()..getPageContext(arg0, arg1, arg2, arg3, arg4, arg5, arg6).getPageContext().
-
-
-          //test "applicationScope" implicit object
-          /*try {
-              Map<String,String> applicationScope = (Map<String,String>) ctx.getELContext().getELResolver().getValue(ctx.getELContext(), null, "applicationScope");
-              if(!ctx.getELContext().isPropertyResolved()){
-                      return fail(testRunner,"implicit object 'applicationScope' failed to resolve.");
-              }
-              //TODO: need to add an attribute and retrieve it here.
-          }catch(Throwable t){
-              return fail(testRunner,"implicit object 'applicationScope' failed to resolve.");
-          }*/
-
-        //test "initParam" implicit object
-
-
-          }catch(Throwable t){
-              return fail(testRunner,"Failure in JSP EL resolve: " + t.getCause().toString());
-          }
-
-          //all implicit objects found - pass the test:
-          testRunner.setTestResult(true,"JSP_ELTest correct.");
-          return Constants.TEST_SUCCESS;
-        }
+        fail(testRunner, "resolved implicit object mutablePortletPreferencesValues contains an entry that isn't in the portlet's preferences map: " +
+             e.getKey());
       }
+      else if (!e.getValue().getValues().equals(portletPrefValues))
+      {
+        fail(testRunner, "resolved implicit object mutablePortletPreferencesValues contains an entry whose value differs from the one in the portlet's preference" +
+             e.getKey());
+      }
+    }
+    
+  }
+  
 
-  private String fail(TestRunnerBean testRunner, String message){
-          testRunner.setTestResult(false,message);
-          return Constants.TEST_FAILED;
+  private void fail(TestRunnerBean testRunner, String message)
+  {
+    if (testRunner.isTestComplete())
+    {
+      testRunner.appendTestDetail(message);
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+      testRunner.setTestResult(false, message);
+    }
   }
+
 }

Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_6/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_6/Tests.java?rev=909087&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_6/Tests.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/section_6_6/Tests.java Thu Feb 11 17:23:51 2010
@@ -0,0 +1,196 @@
+/* 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.chapter_6.section_6_6;
+
+
+
+import javax.faces.component.UIViewRoot;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+
+import javax.portlet.RenderResponse;
+import javax.portlet.faces.Bridge;
+import javax.portlet.faces.BridgeUtil;
+import javax.portlet.faces.annotation.PortletNamingContainer;
+
+
+import javax.portlet.faces.component.PortletNamingContainerUIViewRoot;
+
+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;
+
+
+
+public class Tests
+  extends Object
+{
+  // Test is SingleRequest -- Render
+  // Test #6.91
+  @BridgeTest(test = "portletNamingContainerClientIdTest")
+  public String portletNamingContainerClientIdTest(TestRunnerBean testRunner)
+  { 
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    UIViewRoot viewRoot = ctx.getViewRoot();
+    String namespace = ((RenderResponse) ctx.getExternalContext().getResponse()).getNamespace();
+    
+    testRunner.setTestComplete(true);
+
+    if (viewRoot.getClass().getAnnotation(PortletNamingContainer.class) != null)
+    {
+      if (viewRoot.getContainerClientId(ctx).indexOf(namespace) >= 0)
+      {
+        testRunner.setTestResult(true,  
+                             "UIViewRoot getClientContainerId includes the portlet namespace id.");
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        testRunner.setTestResult(false,  
+                               "UIViewRoot getClientContainerId doesn not includes the portlet namespace id.");
+        return Constants.TEST_FAILED;
+      }
+    }
+    else
+    {
+      testRunner.setTestResult(false,  
+                             "UIViewRoot is not annotated with javax.portlet.faces.annotation.PortletNamingContainer.");
+      return Constants.TEST_FAILED;
+    }
+  }
+  
+  // Test is MultiRequest -- Action/Render
+  // Test #6.92
+  @BridgeTest(test = "portletNamingContainerClientIdConsistentTest")
+  public String portletNamingContainerClientIdConsistentTest(TestRunnerBean testRunner)
+  { 
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    ExternalContext extCtx = ctx.getExternalContext();
+    UIViewRoot viewRoot = ctx.getViewRoot();
+    String clientId = viewRoot.getContainerClientId(ctx);
+    
+    // In the action portion create/attach things to request scope that should either be preserved or
+    // are explicitly excluded -- test for presence/absence in render
+    if (BridgeUtil.getPortletRequestPhase() ==
+        Bridge.PortletPhase.ACTION_PHASE)
+    {
+      extCtx.getRequestMap().put("org.apache.myfaces.portlet.faces.tck.clientIdInAction", clientId);
+      return "portletNamingContainerClientIdConsistentTest"; // action Navigation result
+    }
+    else
+    {
+      testRunner.setTestComplete(true);
+      
+      // Values set by portlet at end of action
+      String clientIdInAction = (String) extCtx.getRequestMap().get("org.apache.myfaces.portlet.faces.tck.clientIdInAction");
+      if (clientIdInAction.equals(clientId))
+      {
+        testRunner.setTestResult(true,
+                                "getContainerClientId returned the same result in both the action and the render.");
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        testRunner.setTestResult(false,
+                                 "getContainerClientId returned a different result between an action and the render.  In action: "
+                                 + clientIdInAction + " while in render: " + clientId);
+        return Constants.TEST_FAILED;
+      }
+    }
+  } 
+  
+  // Test is SingleRequest -- Render
+  // Test #6.94
+  @BridgeTest(test = "portletNamingContainerUIViewRootTest")
+  public String portletNamingContainerUIViewRootTest(TestRunnerBean testRunner)
+  { 
+    
+    testRunner.setTestComplete(true);
+    
+    try
+    {
+      PortletNamingContainerUIViewRoot vr = new PortletNamingContainerUIViewRoot();
+      if (vr.getClass().getAnnotation(PortletNamingContainer.class) != null)
+      {
+        testRunner.setTestResult(true,  
+                           "class PortletNamingContainerUIViewRoot exists and can be instantiated and is properly annotated.");
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        testRunner.setTestResult(false,  
+                           "class PortletNamingContainerUIViewRoot exists and can be instantiated but isn't properly annotated.");
+        return Constants.TEST_FAILED;
+      }
+    }
+    catch (Exception e)
+    {
+      testRunner.setTestResult(false,  
+                               "class PortletNamingContainerUIViewRoot doesn't exist or can't be instantiated. Received exception: "
+                               + e.getMessage());
+      return Constants.TEST_FAILED;
+    }
+  }
+  
+  // Test is SingleRequest -- Render
+  // Test #6.96
+  @BridgeTest(test = "portletNamingContainerUIViewRootClientIdTest")
+  public String portletNamingContainerUIViewRootClientIdTest(TestRunnerBean testRunner)
+  { 
+    FacesContext ctx = FacesContext.getCurrentInstance();
+    UIViewRoot viewRoot = ctx.getViewRoot();
+    String namespace = ((RenderResponse) ctx.getExternalContext().getResponse()).getNamespace();
+    
+    testRunner.setTestComplete(true);
+    
+    try
+    {
+      PortletNamingContainerUIViewRoot vr = new PortletNamingContainerUIViewRoot();
+      // ensure it has an id 
+      vr.setId("nc");
+      
+      if (vr.getContainerClientId(ctx).indexOf(namespace) >= 0)
+      {
+      
+        testRunner.setTestResult(true,  
+                           "class PortletNamingContainerUIViewRoot correctly encodes portlet namespace id in the result from getContainerClientId");
+        return Constants.TEST_SUCCESS;
+      }
+      else
+      {
+        testRunner.setTestResult(false,  
+                                 "class PortletNamingContainerUIViewRoot doesn't encodes portlet namespace id in the result from getContainerClientId. namespaceId: "
+                                 + namespace + " getContainerClientId returned: " + vr.getContainerClientId(ctx));
+        return Constants.TEST_FAILED;
+      }
+    }
+    catch (Exception e)
+    {
+      testRunner.setTestResult(false,  
+                               "class PortletNamingContainerUIViewRoot doesn't exist or can't be instantiated. Received exception: "
+                               + e.getMessage());
+      return Constants.TEST_FAILED;
+    }
+  }
+  
+
+}

Modified: myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/faces-config.xml?rev=909087&r1=909086&r2=909087&view=diff
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/faces-config.xml Thu Feb 11 17:23:51 2010
@@ -60,12 +60,22 @@
     <managed-bean-class>org.apache.myfaces.portlet.faces.testsuite.tests.chapter_6.section_6_1_3_2.Tests</managed-bean-class>
     <managed-bean-scope>request</managed-bean-scope>
   </managed-bean>
-    <managed-bean>
+  <managed-bean>
+    <managed-bean-name>chapter6_2_1Tests</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.portlet.faces.testsuite.tests.chapter_6.section_6_2_1.Tests</managed-bean-class>
+    <managed-bean-scope>request</managed-bean-scope>
+  </managed-bean>
+  <managed-bean>
     <managed-bean-name>chapter6_5_1Tests</managed-bean-name>
     <managed-bean-class>org.apache.myfaces.portlet.faces.testsuite.tests.chapter_6.section_6_5_1.Tests</managed-bean-class>
     <managed-bean-scope>request</managed-bean-scope>
   </managed-bean>
   <managed-bean>
+    <managed-bean-name>chapter6_6Tests</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.portlet.faces.testsuite.tests.chapter_6.section_6_6.Tests</managed-bean-class>
+    <managed-bean-scope>request</managed-bean-scope>
+  </managed-bean>
+  <managed-bean>
     <managed-bean-name>predestroyBean1</managed-bean-name>
     <managed-bean-class>org.apache.myfaces.portlet.faces.testsuite.beans.PreDestroyBean1</managed-bean-class>
     <managed-bean-scope>request</managed-bean-scope>
@@ -314,7 +324,11 @@
     <navigation-case>
       <from-outcome>redirectActionTest</from-outcome>
       <to-view-id>/tests/MultiRequestTestResultRenderCheck.jsp</to-view-id>
-    </navigation-case>    
+    </navigation-case>   
+    <navigation-case>
+      <from-outcome>portletNamingContainerClientIdConsistentTest</from-outcome>
+      <to-view-id>/tests/MultiRequestTestResultRenderCheck.jsp</to-view-id>
+    </navigation-case>   
   </navigation-rule>
     
   <navigation-rule>