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/01 22:47:22 UTC
svn commit: r820782 [1/6] - in /myfaces/portlet-bridge/testsuite/trunk: ./
src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/myfaces/ src/main/java/org/apache/myfaces/portlet/
src/main/java/org/apache/m...
Author: mfreedman
Date: Thu Oct 1 20:47:19 2009
New Revision: 820782
URL: http://svn.apache.org/viewvc?rev=820782&view=rev
Log:
Initial Check-in of the JSR 301 TCK tests.
Added:
myfaces/portlet-bridge/testsuite/trunk/pom.xml
myfaces/portlet-bridge/testsuite/trunk/src/
myfaces/portlet-bridge/testsuite/trunk/src/main/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/annotation/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/annotation/BridgeTest.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean1.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean2.java
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/
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/
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/portlet/wrapper/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionRequestDecorator.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionResponseDecorator.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletRequestDecorator.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletResponseDecorator.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/RenderRequestDecorator.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/RenderResponseDecorator.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/BridgeTCKResultWriter.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/context/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/context/TCK_FacesContextFactoryImpl.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/common/util/faces/render/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/faces/render/TCK_PortletUrlRenderer.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/tags/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/util/tags/TCKSpanTag.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_3/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_3/BridgeVersionTestPortlet.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/EncodeActionURLRenderViewHandler.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/FacesContextFactoryServiceProviderTest.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/chapter_6/Tests.java
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/sample/
myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/tests/sample/SampleTests.java
myfaces/portlet-bridge/testsuite/trunk/src/main/resources/
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/faces-config.xml
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/jetty-pluto-web-default.xml
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/pluto1.0_web.xml
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/portlet.xml
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/WEB-INF/web.xml
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/DispatchTest.jsp
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/MultiRequestFormDataTest.jsp
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/MultiRequestTest.jsp
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/MultiRequestTestResult.jsp
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/MultiRequestTestResultRenderCheck.jsp
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/SingleRequestTest.jsp
myfaces/portlet-bridge/testsuite/trunk/src/main/webapp/tests/chapter6.jsp
Added: myfaces/portlet-bridge/testsuite/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/pom.xml?rev=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/pom.xml (added)
+++ myfaces/portlet-bridge/testsuite/trunk/pom.xml Thu Oct 1 20:47:19 2009
@@ -0,0 +1,340 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.myfaces.portlet-bridge</groupId>
+ <artifactId>portlet-bridge-testsuite</artifactId>
+ <packaging>war</packaging>
+ <name>MyFaces Portlet Bridge Test Suite</name>
+ <version>1.0.0-SNAPSHOT</version>
+ <inceptionYear>2007</inceptionYear>
+ <description>
+ Portlet 1.0 Bridge for JavaServer Faces is a subproject of Apache MyFaces which provides an
+ implementation of the standardized Portlet Bridge as outlined by JSR-301 and subsequent
+ specifications. This project contains the tests for the TCK which validate an implementations
+ fidelity to the specification.
+ </description>
+
+ <url>http://myfaces.apache.org/portlet-bridge/1.0</url>
+
+ <parent>
+ <artifactId>portlet-bridge-master-pom</artifactId>
+ <groupId>org.apache.myfaces.portlet-bridge</groupId>
+ <version>1</version>
+ </parent>
+
+ <properties>
+ <latestRelease>1.0.0-beta-2</latestRelease>
+ <portletSpecVersion>1.0</portletSpecVersion>
+ <jsfSpecVersion>1.2</jsfSpecVersion>
+ <specVersion>1.0</specVersion>
+ <jsrNumber>301</jsrNumber>
+ <specLink>http://www.jcp.org/en/jsr/detail?id=${jsrNumber}</specLink>
+ <specName>Portlet ${portletSpecVersion} Bridge for JavaServer Faces ${jsfSpecVersion}</specName>
+ <projectSeries>1.x</projectSeries>
+ <jetty-plugin.version>6.1.16</jetty-plugin.version>
+ <pluto-embedded.version>1.0.1</pluto-embedded.version>
+ <jsf.version>1.2_03</jsf.version>
+ </properties>
+
+ <!-- issueManagement is in parent -->
+ <!-- ciManagement are in parent -->
+ <!-- mailingLists are in parent -->
+ <!-- developers are in parent -->
+ <!-- contributors are in parent -->
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/portlet-bridge/core/trunk/</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/portlet-bridge/core/trunk/</developerConnection>
+ <url>http://svn.apache.org/viewcvs.cgi/myfaces/portlet-bridge/core/trunk/</url>
+ </scm>
+
+ <distributionManagement>
+ <site>
+ <id>apache-site</id>
+ <url>scpexe://minotaur.apache.org/www/myfaces.apache.org/portlet-bridge/1.0</url>
+ </site>
+ </distributionManagement>
+
+<!--
+ <modules>
+ <module>impl</module>
+ </modules>
+-->
+
+
+ <!-- Versions and scope of dependencies -->
+ <dependencyManagement>
+ <dependencies>
+ <!-- Portlet 1.0 Bridge API -->
+ <dependency>
+ <groupId>portlet-bridge-api</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Portlet API -->
+ <dependency>
+ <groupId>portlet-api</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Servlet API -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- JSP API -->
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- J2EE Annotations -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- MyFaces API -->
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>1.2.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <version>1.2.2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- JSF R.I. API -->
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <!-- As per spec, 1.2_03 is the minimum R.I. for version 1.0 bridge -->
+ <version>${jsf.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Jetty Pluto Plugin -->
+ <dependency>
+ <groupId>com.bekk.boss</groupId>
+ <artifactId>maven-jetty-pluto-embedded</artifactId>
+ <version>${pluto-embedded.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <!-- JSF Portlet Bridge API -->
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>portlet-bridge-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- JSF Portlet Bridge Impl -->
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>portlet-bridge-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>portlet-api</groupId>
+ <artifactId>portlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>portlet-bridge-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>portlet-bridge-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.0_spec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jdev-plugin</artifactId>
+ <groupId>org.apache.myfaces.trinidadbuild</groupId>
+ <configuration>
+ <libraries>
+ <library>JSP Runtime</library>
+ </libraries>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <version>1.0-alpha-6</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <configuration>
+ <resourceBundles>
+ <resourceBundle>org.apache:apache-jar-resource-bundle:1.3</resourceBundle>
+ </resourceBundles>
+ <properties>
+ <addLicense>true</addLicense>
+ </properties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Generates the Javadocs for the Website. Wagon will transport it -->
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>false</aggregate>
+ <linksource>true</linksource>
+ <breakiterator>true</breakiterator>
+ <quiet>true</quiet>
+ <verbose>false</verbose>
+ <source>${jdk.version}</source>
+ <charset>UTF-8</charset>
+ <links>
+ <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
+ <link>http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/api</link>
+ <link>http://portals.apache.org/pluto/portlet-1.0-apidocs/</link>
+ </links>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Specification-Title>${specName}</Specification-Title>
+ <Specification-Version>${specVersion}</Specification-Version>
+ <Specification-Vendor>Java Community (JSR-301)</Specification-Vendor>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>${jetty-plugin.version}</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <profiles>
+ <!-- This profile is invoked by -DprepareRelease=true. This allows mvn release:prepare to
+ run successfully on the assembly projects. -->
+ <profile>
+ <id>prepare-release</id>
+ <activation>
+ <property>
+ <name>prepareRelease</name>
+ </property>
+ </activation>
+ <modules>
+ <module>assembly</module>
+ </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <arguments>-DprepareRelease</arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>perform-release</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <modules>
+ <module>assembly</module>
+ </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.2</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-scm-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <id>getting-scm.revision</id>
+ <goals>
+ <goal>update</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
\ No newline at end of file
Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/annotation/BridgeTest.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/annotation/BridgeTest.java?rev=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/annotation/BridgeTest.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/annotation/BridgeTest.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,42 @@
+/* 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation for marking a method for handling
+ * a specific test.
+ */
+@Target(ElementType.METHOD)
+@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+public @interface BridgeTest {
+ /**
+ * TestName.
+ *
+ * Expected to match the TestName portion of the portletName
+ * @return test name.
+ */
+ String test() default "";
+
+}
Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean1.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean1.java?rev=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean1.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean1.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,77 @@
+/* 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.beans;
+
+import javax.annotation.PreDestroy;
+
+import javax.faces.context.FacesContext;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.faces.annotation.BridgePreDestroy;
+import javax.portlet.faces.annotation.BridgeRequestScopeAttributeAdded;
+
+public class PreDestroyBean1
+{
+ PortletRequest mRequest;
+ boolean mInBridgeRequestScope = false;
+
+ public PreDestroyBean1()
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ mRequest = (PortletRequest) ctx.getExternalContext().getRequest();
+ }
+
+ public Boolean getInBridgeRequestScope()
+ {
+ if (mInBridgeRequestScope)
+ return Boolean.TRUE;
+ else
+ return Boolean.FALSE;
+ }
+
+ @BridgeRequestScopeAttributeAdded
+ public void attributeAddedToBridgeRequestScope()
+ {
+ mRequest.setAttribute("PreDestroyBean1.attributeAdded", Boolean.TRUE);
+ mInBridgeRequestScope = true;
+ }
+
+ @PreDestroy
+ public void servletPredestroy()
+ {
+ if (!mInBridgeRequestScope)
+ {
+ mRequest.setAttribute("PreDestroyBean1.servletPreDestroy", Boolean.TRUE); // indicates we would do the destroy
+ }
+ else
+ {
+ mRequest.setAttribute("PreDestroyBean1.servletPreDestroy", Boolean.FALSE); // indicates we would not do the destroy
+ }
+
+ }
+
+
+ @BridgePreDestroy
+ public void bridgePredestroy()
+ {
+ mRequest.setAttribute("PreDestroyBean1.bridgePreDestroy", Boolean.TRUE);
+ mInBridgeRequestScope = false;
+ }
+}
Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean2.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean2.java?rev=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean2.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/PreDestroyBean2.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,78 @@
+/* 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.beans;
+
+import javax.annotation.PreDestroy;
+
+import javax.faces.context.FacesContext;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.faces.annotation.BridgePreDestroy;
+import javax.portlet.faces.annotation.BridgeRequestScopeAttributeAdded;
+
+public class PreDestroyBean2
+{
+ PortletRequest mRequest;
+ boolean mInBridgeRequestScope = false;
+
+ public PreDestroyBean2()
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ mRequest = (PortletRequest) ctx.getExternalContext().getRequest();
+ mInBridgeRequestScope = true;
+ }
+
+ public Boolean isInBridgeRequestScope()
+ {
+ if (mInBridgeRequestScope)
+ return Boolean.TRUE;
+ else
+ return Boolean.FALSE;
+ }
+
+ @BridgeRequestScopeAttributeAdded
+ public void attributeAddedToBridgeRequestScope()
+ {
+ mRequest.setAttribute("PreDestroyBean2.attributeAdded", Boolean.TRUE);
+
+ }
+
+ @PreDestroy
+ public void servletPredestroy()
+ {
+ if (!mInBridgeRequestScope)
+ {
+ mRequest.setAttribute("PreDestroyBean2.servletPreDestroy", Boolean.TRUE); // indicates we would do the destroy
+ }
+ else
+ {
+ mRequest.setAttribute("PreDestroyBean2.servletPreDestroy", Boolean.FALSE); // indicates we would not do the destroy
+ }
+
+ }
+
+
+ @BridgePreDestroy
+ public void bridgePredestroy()
+ {
+ mRequest.setAttribute("PreDestroyBean2.bridgePreDestroy", Boolean.TRUE);
+ mInBridgeRequestScope = false;
+ }
+}
Added: 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=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/TestRunnerBean.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/beans/TestRunnerBean.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,200 @@
+/* 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.beans;
+
+import java.lang.IllegalStateException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+
+import java.util.Map;
+
+
+import javax.faces.context.FacesContext;
+
+
+import org.apache.myfaces.portlet.faces.testsuite.annotation.BridgeTest;
+
+import org.apache.myfaces.portlet.faces.testsuite.common.Constants;
+import org.apache.myfaces.portlet.faces.testsuite.common.util.BridgeTCKResultWriter;
+
+
+public class TestRunnerBean
+ extends Object
+{
+
+ // The portlet's name is testGroup-testName-portlet. For example encodeActionURL_absoluteURLTest-portlet.
+ // testGroup corresponds to the managedBean name that holds the object containing the test.
+ // testName corresponds to the name of the Test that is the value of the
+ // test method annotation we look for to determine which method is called to run the test.
+ private String mTestGroup;
+ private String mTestName;
+
+ private Object mTest;
+
+ private BridgeTCKResultWriter mResultWriter;
+ private boolean mStatus = false;
+ private boolean mTestComplete = false;
+ private Method mTestMethod;
+
+ public TestRunnerBean()
+ {
+ // Get the Test information from the request (attributes)
+ // Placed into the request by the GenericFacesTestSuitePortlet
+ FacesContext context = FacesContext.getCurrentInstance();
+ Map<String, Object> m = context.getExternalContext().getRequestMap();
+ mTestGroup = (String) m.get(Constants.TEST_BEAN_NAME);
+ mTestName = (String) m.get(Constants.TEST_NAME);
+
+
+ if (mTestGroup == null || mTestName == null)
+ {
+ throw new IllegalStateException("Couldn't locate the TestGroup or TestName in the request. Did you use the GenericFacesTestSuitePortlet?");
+ }
+
+ // Now lookup the object that implements the test. There should be a managedBean with the same name as
+ // the testGroup.
+ mTest = context.getELContext()
+ .getELResolver().getValue(context.getELContext(), null, mTestGroup);
+
+ if (mTest == null)
+ {
+ throw new IllegalStateException("Couldn't locate managed bean containing the test: " + mTestGroup);
+ }
+
+ // The test is annotated by a method annotation with a parameter value = mTestName -- so
+ // look it up.
+ mTestMethod = getAnnotatedTestMethod(mTestName, mTest);
+
+
+
+ if (mTestMethod == null)
+ throw new IllegalStateException("Couldn't locate (annotation for) test: " + mTestName + "Test in the test object.");
+ }
+
+ public String runActionTest()
+ {
+
+ // Called either because the action is submitted
+ return runTest();
+ }
+
+ public boolean getTestStatus()
+ {
+ return mStatus;
+ }
+
+ public boolean isTestComplete()
+ {
+ return mTestComplete;
+ }
+
+ public void setTestComplete(boolean complete)
+ {
+ mTestComplete = complete;
+ }
+
+ public String getRenderTestResult()
+ {
+ runTest();
+ return getTestResult();
+ }
+
+ public void setTestResult(boolean passed, String detail)
+ {
+ mResultWriter = new BridgeTCKResultWriter(mTestName);
+ mResultWriter.setStatus(passed);
+ mResultWriter.addDetail(detail);
+
+ mStatus = passed;
+ }
+
+
+ public String getTestResult()
+ {
+ if (mResultWriter == null)
+ setTestResult(false, "Test failed: A test result hasn't been set! Usually this indicates the request flow broken due to bridge failure.");
+
+
+ return mResultWriter.toString();
+ }
+
+ public void appendTestDetail(String detail)
+ {
+ if (mResultWriter != null)
+ {
+ mResultWriter.addDetail(detail);
+ }
+ }
+
+ private String runTest()
+ {
+ // Only run the test once
+ if (mTestComplete)
+ {
+ return (mStatus) ? Constants.TEST_SUCCESS : Constants.TEST_FAILED;
+ }
+
+ // run the test and return the result.
+ if (mTestMethod != null)
+ {
+ try
+ {
+ return (String) mTestMethod.invoke(mTest, this);
+ }
+ catch (Exception e)
+ {
+ setTestResult(false, "Test failed: " + e.toString() + " thrown during invocation");
+ return Constants.TEST_FAILED;
+ }
+ }
+ else
+ {
+ setTestResult(false, "Test failed: unable to determine test method to call. Is the portletName properly encoded? Syntax: testBean-testMethodName-portlet");
+ return Constants.TEST_FAILED;
+ }
+ }
+
+ private Method getAnnotatedTestMethod(String testName, Object testObj)
+ {
+ // search methods for one annotated by the BridgeTest annotation and
+ // with a test (parameter) value = portletNameTest
+ for (Method method: testObj.getClass().getMethods())
+ {
+ Annotation[] annotations = method.getAnnotations();
+ if (annotations != null)
+ {
+ for (Annotation annotation: annotations)
+ {
+ Class<? extends Annotation> annotationType =
+ annotation.annotationType();
+ if (BridgeTest.class.equals(annotationType))
+ {
+ String annotatedTestName = ((BridgeTest) annotation).test();
+ if (annotatedTestName != null && annotatedTestName.length() > 0
+ && annotatedTestName.equalsIgnoreCase(testName))
+ return method;
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
Added: 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=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/Constants.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/Constants.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,28 @@
+/* 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.common;
+
+public class Constants extends Object
+{
+ 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 TEST_FAILED = "FAILED";
+ public final static String TEST_SUCCESS = "SUCCESS";
+}
\ No newline at end of file
Added: 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=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/GenericFacesTestSuitePortlet.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/GenericFacesTestSuitePortlet.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,85 @@
+/* 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.common.portlet;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.faces.GenericFacesPortlet;
+
+import org.apache.myfaces.portlet.faces.testsuite.common.Constants;
+
+public class GenericFacesTestSuitePortlet extends GenericFacesPortlet
+{
+
+ private String mTestBeanName;
+ private String mTestName;
+
+ public void init(PortletConfig config)
+ throws PortletException
+ {
+ super.init(config);
+ // parse the portlet name to extract the testName and bean we use to during this test
+ // This information is subsequently attached to each request (as an attribute).
+ // The generic TestRunnerBean uses this information to execute the bean and properly
+ // reference the test in any result.
+
+ // portletName syntax: testGroup-testName-portlet
+ String portletName = config.getPortletName();
+ String [] parts = portletName.split("-");
+ if (parts.length != 3)
+ {
+ throw new IllegalStateException("Incorrect portletName syntax for a test: should be testGroup-testName-portlet");
+ }
+ mTestBeanName = parts[0];
+ mTestName = parts[1];
+ if (!mTestName.endsWith("Test"))
+ {
+ mTestName = mTestName.concat("Test");
+ }
+ }
+ public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
+ throws PortletException, IOException
+ {
+ initTestRequest(actionRequest);
+ // add an additional attribute -- so one of the tests can verify its excluded in render
+ actionRequest.setAttribute("verifyPreBridgeExclusion", "avalue");
+ super.processAction(actionRequest, actionResponse);
+ }
+
+ public void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse)
+ throws PortletException, IOException
+ {
+ initTestRequest(renderRequest);
+ super.doDispatch(renderRequest, renderResponse);
+ }
+
+ private void initTestRequest(PortletRequest portletRequest)
+ {
+ portletRequest.setAttribute(Constants.TEST_BEAN_NAME, mTestBeanName);
+ portletRequest.setAttribute(Constants.TEST_NAME, mTestName);
+ }
+}
\ No newline at end of file
Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionRequestDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionRequestDecorator.java?rev=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionRequestDecorator.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionRequestDecorator.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,148 @@
+/* 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.common.portlet.wrapper;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.PortletRequest;
+
+public class ActionRequestDecorator extends PortletRequestDecorator implements ActionRequest
+{
+ private PortletRequest mRequest = null;
+
+ public ActionRequestDecorator(ActionRequest request) throws IllegalArgumentException
+ {
+
+ super(request);
+ }
+
+ /**
+ * Retrieves the body of the HTTP request from client to portal as binary data using an
+ * <CODE>InputStream</CODE>. Either this method or {@link #getReader} may be called to read the
+ * body, but not both.
+ * <p>
+ * For HTTP POST data of type application/x-www-form-urlencoded this method throws an
+ * <code>IllegalStateException</code> as this data has been already processed by the
+ * portal/portlet-container and is available as request parameters.
+ *
+ * @return an input stream containing the body of the request
+ *
+ * @exception java.lang.IllegalStateException
+ * if getReader was already called, or it is a HTTP POST data of type
+ * application/x-www-form-urlencoded
+ * @exception java.io.IOException
+ * if an input or output exception occurred
+ */
+ public java.io.InputStream getPortletInputStream() throws java.io.IOException
+ {
+ // mRequest is a protected member of PortletRequestDecorator
+ return ((ActionRequest) mRequest).getPortletInputStream();
+ }
+
+ /**
+ * Overrides the name of the character encoding used in the body of this request. This method must
+ * be called prior to reading input using {@link #getReader} or {@link #getPortletInputStream}.
+ * <p>
+ * This method only sets the character set for the Reader that the {@link #getReader} method
+ * returns.
+ *
+ * @param enc
+ * a <code>String</code> containing the name of the chararacter encoding.
+ *
+ * @exception java.io.UnsupportedEncodingException
+ * if this is not a valid encoding
+ * @exception java.lang.IllegalStateException
+ * if this method is called after reading request parameters or reading input using
+ * <code>getReader()</code>
+ */
+ public void setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException
+ {
+ // mRequest is a protected member of PortletRequestDecorator
+ ((ActionRequest) mRequest).setCharacterEncoding(enc);
+ }
+
+ /**
+ * Retrieves the body of the HTTP request from the client to the portal as character data using a
+ * <code>BufferedReader</code>. The reader translates the character data according to the
+ * character encoding used on the body. Either this method or {@link #getPortletInputStream} may
+ * be called to read the body, not both.
+ * <p>
+ * For HTTP POST data of type application/x-www-form-urlencoded this method throws an
+ * <code>IllegalStateException</code> as this data has been already processed by the
+ * portal/portlet-container and is available as request parameters.
+ *
+ * @return a <code>BufferedReader</code> containing the body of the request
+ *
+ * @exception java.io.UnsupportedEncodingException
+ * if the character set encoding used is not supported and the text cannot be decoded
+ * @exception java.lang.IllegalStateException
+ * if {@link #getPortletInputStream} method has been called on this request, it is a
+ * HTTP POST data of type application/x-www-form-urlencoded.
+ * @exception java.io.IOException
+ * if an input or output exception occurred
+ *
+ * @see #getPortletInputStream
+ */
+ public java.io.BufferedReader getReader() throws java.io.UnsupportedEncodingException,
+ java.io.IOException
+ {
+ // mRequest is a protected member of PortletRequestDecorator
+ return ((ActionRequest) mRequest).getReader();
+ }
+
+ /**
+ * Returns the name of the character encoding used in the body of this request. This method
+ * returns <code>null</code> if the request does not specify a character encoding.
+ *
+ * @return a <code>String</code> containing the name of the chararacter encoding, or
+ * <code>null</code> if the request does not specify a character encoding.
+ */
+ public java.lang.String getCharacterEncoding()
+ {
+ // mRequest is a protected member of PortletRequestDecorator
+ return ((ActionRequest) mRequest).getCharacterEncoding();
+ }
+
+ /**
+ * Returns the MIME type of the body of the request, or null if the type is not known.
+ *
+ * @return a <code>String</code> containing the name of the MIME type of the request, or null if
+ * the type is not known.
+ */
+ public java.lang.String getContentType()
+ {
+ // mRequest is a protected member of PortletRequestDecorator
+ return ((ActionRequest) mRequest).getContentType();
+ }
+
+ /**
+ * Returns the length, in bytes, of the request body which is made available by the input stream,
+ * or -1 if the length is not known.
+ *
+ *
+ * @return an integer containing the length of the request body or -1 if the length is not known
+ *
+ */
+ public int getContentLength()
+ {
+ // mRequest is a protected member of PortletRequestDecorator
+ return ((ActionRequest) mRequest).getContentLength();
+ }
+
+}
Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionResponseDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionResponseDecorator.java?rev=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionResponseDecorator.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/ActionResponseDecorator.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,224 @@
+/* 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.common.portlet.wrapper;
+
+import java.util.Map;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+
+public class ActionResponseDecorator extends PortletResponseDecorator implements ActionResponse
+{
+
+ public ActionResponseDecorator(ActionResponse response) throws IllegalArgumentException
+ {
+
+ super(response);
+ }
+
+ @Override
+ public ActionResponse getParent()
+ {
+ return (ActionResponse) super.getParent();
+ }
+
+ @Override
+ public ActionResponse getRoot()
+ {
+ return (ActionResponse) super.getRoot();
+ }
+
+ /**
+ * Sets the window state of a portlet to the given window state.
+ * <p>
+ * Possible values are the standard window states and any custom window states supported by the
+ * portal and the portlet. Standard window states are:
+ * <ul>
+ * <li>MINIMIZED
+ * <li>NORMAL
+ * <li>MAXIMIZED
+ * </ul>
+ *
+ * @param windowState
+ * the new portlet window state
+ *
+ * @exception WindowStateException
+ * if the portlet cannot switch to the specified window state. To avoid this
+ * exception the portlet can check the allowed window states with
+ * <code>Request.isWindowStateAllowed()</code>.
+ * @exception java.lang.IllegalStateException
+ * if the method is invoked after <code>sendRedirect</code> has been called.
+ *
+ * @see WindowState
+ */
+ public void setWindowState(WindowState windowState) throws WindowStateException
+ {
+
+ ((ActionResponse) getParent()).setWindowState(windowState);
+ }
+
+ /**
+ * Sets the portlet mode of a portlet to the given portlet mode.
+ * <p>
+ * Possible values are the standard portlet modes and any custom portlet modes supported by the
+ * portal and the portlet. Portlets must declare in the deployment descriptor the portlet modes
+ * they support for each markup type. Standard portlet modes are:
+ * <ul>
+ * <li>EDIT
+ * <li>HELP
+ * <li>VIEW
+ * </ul>
+ * <p>
+ * Note: The portlet may still be called in a different window state in the next render call,
+ * depending on the portlet container / portal.
+ *
+ * @param portletMode
+ * the new portlet mode
+ *
+ * @exception PortletModeException
+ * if the portlet cannot switch to this portlet mode, because the portlet or portal
+ * does not support it for this markup, or the current user is not allowed to switch
+ * to this portlet mode. To avoid this exception the portlet can check the allowed
+ * portlet modes with <code>Request.isPortletModeAllowed()</code>.
+ * @exception java.lang.IllegalStateException
+ * if the method is invoked after <code>sendRedirect</code> has been called.
+ */
+ public void setPortletMode(PortletMode portletMode) throws PortletModeException
+ {
+ ((ActionResponse) getParent()).setPortletMode(portletMode);
+ }
+
+ /**
+ * Instructs the portlet container to send a redirect response to the client using the specified
+ * redirect location URL.
+ * <p>
+ * This method only accepts an absolute URL (e.g.
+ * <code>http://my.co/myportal/mywebap/myfolder/myresource.gif</code>) or a full path URI (e.g.
+ * <code>/myportal/mywebap/myfolder/myresource.gif</code>). If required, the portlet container
+ * may encode the given URL before the redirection is issued to the client.
+ * <p>
+ * The sendRedirect method can not be invoked after any of the following methods of the
+ * ActionResponse interface has been called:
+ * <ul>
+ * <li>setPortletMode
+ * <li>setWindowState
+ * <li>setRenderParameter
+ * <li>setRenderParameters
+ * </ul>
+ *
+ * @param location
+ * the redirect location URL
+ *
+ * @exception java.io.IOException
+ * if an input or output exception occurs.
+ * @exception java.lang.IllegalArgumentException
+ * if a relative path URL is given
+ * @exception java.lang.IllegalStateException
+ * if the method is invoked after any of above mentioned methods of the
+ * ActionResponse interface has been called.
+ */
+ public void sendRedirect(String location) throws java.io.IOException
+ {
+ ((ActionResponse) getParent()).sendRedirect(location);
+ }
+
+ /**
+ * Sets a parameter map for the render request.
+ * <p>
+ * All previously set render parameters are cleared.
+ * <p>
+ * These parameters will be accessible in all sub-sequent render calls via the
+ * <code>PortletRequest.getParameter</code> call until a new request is targeted to the portlet.
+ * <p>
+ * The given parameters do not need to be encoded prior to calling this method.
+ *
+ * @param parameters
+ * Map containing parameter names for the render phase as keys and parameter values as
+ * map values. The keys in the parameter map must be of type String. The values in the
+ * parameter map must be of type String array (<code>String[]</code>).
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if parameters is <code>null</code>, if any of the key/values in the Map are
+ * <code>null</code>, if any of the keys is not a String, or if any of the values
+ * is not a String array.
+ * @exception java.lang.IllegalStateException
+ * if the method is invoked after <code>sendRedirect</code> has been called.
+ */
+ // FIXME: When portlet API is Java 5 compliant, fix this generic issue
+ @SuppressWarnings("unchecked")
+ public void setRenderParameters(Map parameters)
+ {
+ ((ActionResponse) getParent()).setRenderParameters(parameters);
+ }
+
+ /**
+ * Sets a String parameter for the render request.
+ * <p>
+ * These parameters will be accessible in all sub-sequent render calls via the
+ * <code>PortletRequest.getParameter</code> call until a request is targeted to the portlet.
+ * <p>
+ * This method replaces all parameters with the given key.
+ * <p>
+ * The given parameter do not need to be encoded prior to calling this method.
+ *
+ * @param key
+ * key of the render parameter
+ * @param value
+ * value of the render parameter
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if key or value are <code>null</code>.
+ * @exception java.lang.IllegalStateException
+ * if the method is invoked after <code>sendRedirect</code> has been called.
+ */
+ public void setRenderParameter(String key, String value)
+ {
+ ((ActionResponse) getParent()).setRenderParameter(key, value);
+ }
+
+ /**
+ * Sets a String array parameter for the render request.
+ * <p>
+ * These parameters will be accessible in all sub-sequent render calls via the
+ * <code>PortletRequest.getParameter</code> call until a request is targeted to the portlet.
+ * <p>
+ * This method replaces all parameters with the given key.
+ * <p>
+ * The given parameter do not need to be encoded prior to calling this method.
+ *
+ * @param key
+ * key of the render parameter
+ * @param values
+ * values of the render parameter
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if key or value are <code>null</code>.
+ * @exception java.lang.IllegalStateException
+ * if the method is invoked after <code>sendRedirect</code> has been called.
+ */
+ public void setRenderParameter(String key, String[] values)
+ {
+ ((ActionResponse) getParent()).setRenderParameter(key, values);
+ }
+
+}
Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletRequestDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletRequestDecorator.java?rev=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletRequestDecorator.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletRequestDecorator.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,626 @@
+/* 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.common.portlet.wrapper;
+
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.PortalContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletSession;
+import javax.portlet.WindowState;
+
+public class PortletRequestDecorator implements PortletRequest
+{
+ protected PortletRequest mRequest = null;
+
+ public PortletRequestDecorator(PortletRequest request) throws IllegalArgumentException
+ {
+ if (request == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ mRequest = request;
+ }
+
+ public PortletRequest getParent()
+ {
+ return mRequest;
+ }
+
+ public PortletRequest getRoot()
+ {
+ PortletRequest root = mRequest;
+ while (root instanceof PortletRequestDecorator)
+ {
+ root = ((PortletRequestDecorator) root).getParent();
+ }
+ return root;
+ }
+
+ /**
+ * Returns true, if the given window state is valid to be set for this portlet in the context of
+ * the current request.
+ *
+ * @param state
+ * window state to checked
+ *
+ * @return true, if it is valid for this portlet in this request to change to the given window
+ * state
+ *
+ */
+ public boolean isWindowStateAllowed(WindowState state)
+ {
+ return mRequest.isWindowStateAllowed(state);
+ }
+
+ /**
+ * Returns true, if the given portlet mode is a valid one to set for this portlet in the context
+ * of the current request.
+ *
+ * @param mode
+ * portlet mode to check
+ *
+ * @return true, if it is valid for this portlet in this request to change to the given portlet
+ * mode
+ *
+ */
+ public boolean isPortletModeAllowed(PortletMode mode)
+ {
+ return mRequest.isPortletModeAllowed(mode);
+ }
+
+ /**
+ * Returns the current portlet mode of the portlet.
+ *
+ * @return the portlet mode
+ */
+ public PortletMode getPortletMode()
+ {
+ return mRequest.getPortletMode();
+ }
+
+ /**
+ * Returns the current window state of the portlet.
+ *
+ * @return the window state
+ */
+ public WindowState getWindowState()
+ {
+ return mRequest.getWindowState();
+ }
+
+ /**
+ * Returns the preferences object associated with the portlet.
+ *
+ * @return the portlet preferences
+ */
+ public PortletPreferences getPreferences()
+ {
+ return mRequest.getPreferences();
+ }
+
+ /**
+ * Returns the current portlet session or, if there is no current session, creates one and returns
+ * the new session.
+ * <p>
+ * Creating a new portlet session will result in creating a new <code>HttpSession</code> on
+ * which the portlet session is based on.
+ *
+ * @return the portlet session
+ */
+ public PortletSession getPortletSession()
+ {
+ return mRequest.getPortletSession();
+ }
+
+ /**
+ * Returns the current portlet session or, if there is no current session and the given flag is
+ * <CODE>true</CODE>, creates one and returns the new session.
+ * <P>
+ * If the given flag is <CODE>false</CODE> and there is no current portlet session, this method
+ * returns <CODE>null</CODE>.
+ * <p>
+ * Creating a new portlet session will result in creating a new <code>HttpSession</code> on
+ * which the portlet session is based on.
+ *
+ * @param create
+ * <CODE>true</CODE> to create a new session, <BR>
+ * <CODE>false</CODE> to return <CODE>null</CODE> if there is no current session
+ * @return the portlet session
+ */
+ public PortletSession getPortletSession(boolean create)
+ {
+ return mRequest.getPortletSession(create);
+ }
+
+ /**
+ * Returns the value of the specified request property as a <code>String</code>. If the request
+ * did not include a property of the specified name, this method returns <code>null</code>.
+ * <p>
+ * A portlet can access portal/portlet-container specific properties through this method and, if
+ * available, the headers of the HTTP client request.
+ * <p>
+ * This method should only be used if the property has only one value. If the property might have
+ * more than one value, use {@link #getProperties}.
+ * <p>
+ * If this method is used with a multivalued parameter, the value returned is equal to the first
+ * value in the Enumeration returned by <code>getProperties</code>.
+ *
+ * @param name
+ * a <code>String</code> specifying the property name
+ *
+ * @return a <code>String</code> containing the value of the requested property, or
+ * <code>null</code> if the request does not have a property of that name.
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if name is <code>null</code>.
+ */
+ public String getProperty(String name)
+ {
+ return mRequest.getProperty(name);
+ }
+
+ /**
+ * Returns all the values of the specified request property as a <code>Enumeration</code> of
+ * <code>String</code> objects.
+ * <p>
+ * If the request did not include any propertys of the specified name, this method returns an
+ * empty <code>Enumeration</code>. The property name is case insensitive. You can use this
+ * method with any request property.
+ *
+ * @param name
+ * a <code>String</code> specifying the property name
+ *
+ * @return a <code>Enumeration</code> containing the values of the requested property. If the
+ * request does not have any properties of that name return an empty
+ * <code>Enumeration</code>.
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if name is <code>null</code>.
+ */
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getProperties(String name)
+ {
+ return mRequest.getProperties(name);
+ }
+
+ /**
+ *
+ * Returns a <code>Enumeration</code> of all the property names this request contains. If the
+ * request has no properties, this method returns an empty <code>Enumeration</code>.
+ *
+ *
+ * @return an <code>Enumeration</code> of all the property names sent with this request; if the
+ * request has no properties, an empty <code>Enumeration</code>.
+ */
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getPropertyNames()
+ {
+ return mRequest.getPropertyNames();
+ }
+
+ /**
+ * Returns the context of the calling portal.
+ *
+ * @return the context of the calling portal
+ */
+ public PortalContext getPortalContext()
+ {
+ return mRequest.getPortalContext();
+ }
+
+ /**
+ * Returns the name of the authentication scheme used for the connection between client and
+ * portal, for example, <code>BASIC_AUTH</code>, <code>CLIENT_CERT_AUTH</code>, a custom one
+ * or <code>null</code> if there was no authentication.
+ *
+ * @return one of the static members <code>BASIC_AUTH</code>, <code>FORM_AUTH</code>,
+ * <code>CLIENT_CERT_AUTH</code>, <code>DIGEST_AUTH</code> (suitable for ==
+ * comparison) indicating the authentication scheme, a custom one, or <code>null</code>
+ * if the request was not authenticated.
+ */
+ public String getAuthType()
+ {
+ return mRequest.getAuthType();
+ }
+
+ /**
+ * Returns the context path which is the path prefix associated with the deployed portlet
+ * application. If the portlet application is rooted at the base of the web server URL namespace
+ * (also known as "default" context), this path must be an empty string. Otherwise, it must be the
+ * path the portlet application is rooted to, the path must start with a '/' and it must not end
+ * with a '/' character.
+ * <p>
+ * To encode a URL the {@link PortletResponse#encodeURL} method must be used.
+ *
+ * @return a <code>String</code> specifying the portion of the request URL that indicates the
+ * context of the request
+ *
+ * @see PortletResponse#encodeURL
+ */
+ public String getContextPath()
+ {
+ return mRequest.getContextPath();
+ }
+
+ /**
+ * Returns the login of the user making this request, if the user has been authenticated, or null
+ * if the user has not been authenticated.
+ *
+ * @return a <code>String</code> specifying the login of the user making this request, or
+ * <code>null</code> if the user login is not known.
+ *
+ */
+ public String getRemoteUser()
+ {
+ return mRequest.getRemoteUser();
+ }
+
+ /**
+ * Returns a java.security.Principal object containing the name of the current authenticated user.
+ *
+ * @return a <code>java.security.Principal</code> containing the name of the user making this
+ * request, or <code>null</code> if the user has not been authenticated.
+ */
+ public java.security.Principal getUserPrincipal()
+ {
+ return mRequest.getUserPrincipal();
+ }
+
+ /**
+ * Returns a boolean indicating whether the authenticated user is included in the specified
+ * logical "role". Roles and role membership can be defined using deployment descriptors. If the
+ * user has not been authenticated, the method returns <code>false</code>.
+ *
+ * @param role
+ * a <code>String</code> specifying the name of the role
+ *
+ * @return a <code>boolean</code> indicating whether the user making this request belongs to a
+ * given role; <code>false</code> if the user has not been authenticated.
+ */
+ public boolean isUserInRole(String role)
+ {
+ return mRequest.isUserInRole(role);
+ }
+
+ /**
+ *
+ * Returns the value of the named attribute as an <code>Object</code>, or <code>null</code>
+ * if no attribute of the given name exists.
+ * <p>
+ * Attribute names should follow the same conventions as package names. This specification
+ * reserves names matching <code>java.*</code>, and <code>javax.*</code>.
+ * <p>
+ * In a distributed portlet web application the <code>Object</code> needs to be serializable.
+ *
+ * @param name
+ * a <code>String</code> specifying the name of the attribute
+ *
+ * @return an <code>Object</code> containing the value of the attribute, or <code>null</code>
+ * if the attribute does not exist.
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if name is <code>null</code>.
+ *
+ */
+ public Object getAttribute(String name)
+ {
+ return mRequest.getAttribute(name);
+ }
+
+ /**
+ * Returns an <code>Enumeration</code> containing the names of the attributes available to this
+ * request. This method returns an empty <code>Enumeration</code> if the request has no
+ * attributes available to it.
+ *
+ *
+ * @return an <code>Enumeration</code> of strings containing the names of the request
+ * attributes, or an empty <code>Enumeration</code> if the request has no attributes
+ * available to it.
+ */
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getAttributeNames()
+ {
+ return mRequest.getAttributeNames();
+ }
+
+ /**
+ * Returns the value of a request parameter as a <code>String</code>, or <code>null</code> if
+ * the parameter does not exist. Request parameters are extra information sent with the request.
+ * The returned parameter are "x-www-form-urlencoded" decoded.
+ * <p>
+ * Only parameters targeted to the current portlet are accessible.
+ * <p>
+ * This method should only be used if the parameter has only one value. If the parameter might
+ * have more than one value, use {@link #getParameterValues}.
+ * <p>
+ * If this method is used with a multivalued parameter, the value returned is equal to the first
+ * value in the array returned by <code>getParameterValues</code>.
+ *
+ *
+ *
+ * @param name
+ * a <code>String</code> specifying the name of the parameter
+ *
+ * @return a <code>String</code> representing the single value of the parameter
+ *
+ * @see #getParameterValues
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if name is <code>null</code>.
+ *
+ */
+ public String getParameter(String name)
+ {
+ return mRequest.getParameter(name);
+ }
+
+ /**
+ *
+ * Returns an <code>Enumeration</code> of <code>String</code> objects containing the names of
+ * the parameters contained in this request. If the request has no parameters, the method returns
+ * an empty <code>Enumeration</code>.
+ * <p>
+ * Only parameters targeted to the current portlet are returned.
+ *
+ *
+ * @return an <code>Enumeration</code> of <code>String</code> objects, each
+ * <code>String</code> containing the name of a request parameter; or an empty
+ * <code>Enumeration</code> if the request has no parameters.
+ */
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getParameterNames()
+ {
+ return mRequest.getParameterNames();
+ }
+
+ /**
+ * Returns an array of <code>String</code> objects containing all of the values the given
+ * request parameter has, or <code>null</code> if the parameter does not exist. The returned
+ * parameters are "x-www-form-urlencoded" decoded.
+ * <p>
+ * If the parameter has a single value, the array has a length of 1.
+ *
+ *
+ * @param name
+ * a <code>String</code> containing the name of the parameter the value of which is
+ * requested
+ *
+ * @return an array of <code>String</code> objects containing the parameter values.
+ *
+ * @see #getParameter
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if name is <code>null</code>.
+ *
+ */
+ public String[] getParameterValues(String name)
+ {
+ return mRequest.getParameterValues(name);
+
+ }
+
+ /**
+ * Returns a <code>Map</code> of the parameters of this request. Request parameters are extra
+ * information sent with the request. The returned parameters are "x-www-form-urlencoded" decoded.
+ * <p>
+ * The values in the returned <code>Map</code> are from type String array (<code>String[]</code>).
+ * <p>
+ * If no parameters exist this method returns an empty <code>Map</code>.
+ *
+ * @return an immutable <code>Map</code> containing parameter names as keys and parameter values
+ * as map values, or an empty <code>Map</code> if no parameters exist. The keys in the
+ * parameter map are of type String. The values in the parameter map are of type String
+ * array (<code>String[]</code>).
+ */
+ @SuppressWarnings("unchecked")
+ public Map<String, String[]> getParameterMap()
+ {
+ return mRequest.getParameterMap();
+ }
+
+ /**
+ * Returns a boolean indicating whether this request was made using a secure channel between
+ * client and the portal, such as HTTPS.
+ *
+ * @return true, if the request was made using a secure channel.
+ */
+ public boolean isSecure()
+ {
+ return mRequest.isSecure();
+ }
+
+ /**
+ * Stores an attribute in this request.
+ *
+ * <p>
+ * Attribute names should follow the same conventions as package names. Names beginning with
+ * <code>java.*</code>, <code>javax.*</code>, and <code>com.sun.*</code> are reserved for
+ * use by Sun Microsystems. <br>
+ * If the value passed into this method is <code>null</code>, the effect is the same as calling
+ * {@link #removeAttribute}.
+ *
+ *
+ * @param name
+ * a <code>String</code> specifying the name of the attribute
+ *
+ * @param o
+ * the <code>Object</code> to be stored
+ *
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if name is <code>null</code>.
+ */
+ public void setAttribute(String name, Object o)
+ {
+ mRequest.setAttribute(name, o);
+ }
+
+ /**
+ *
+ * Removes an attribute from this request. This method is not generally needed, as attributes only
+ * persist as long as the request is being handled.
+ *
+ * <p>
+ * Attribute names should follow the same conventions as package names. Names beginning with
+ * <code>java.*</code>, <code>javax.*</code>, and <code>com.sun.*</code> are reserved for
+ * use by Sun Microsystems.
+ *
+ * @param name
+ * a <code>String</code> specifying the name of the attribute to be removed
+ *
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if name is <code>null</code>.
+ */
+ public void removeAttribute(String name)
+ {
+ mRequest.removeAttribute(name);
+ }
+
+ /**
+ *
+ * Returns the session ID indicated in the client request. This session ID may not be a valid one,
+ * it may be an old one that has expired or has been invalidated. If the client request did not
+ * specify a session ID, this method returns <code>null</code>.
+ *
+ * @return a <code>String</code> specifying the session ID, or <code>null</code> if the
+ * request did not specify a session ID
+ *
+ * @see #isRequestedSessionIdValid
+ *
+ */
+ public String getRequestedSessionId()
+ {
+ return mRequest.getRequestedSessionId();
+ }
+
+ /**
+ *
+ * Checks whether the requested session ID is still valid.
+ *
+ * @return <code>true</code> if this request has an id for a valid session in the current
+ * session context; <code>false</code> otherwise
+ *
+ * @see #getRequestedSessionId
+ * @see #getPortletSession
+ */
+ public boolean isRequestedSessionIdValid()
+ {
+ return mRequest.isRequestedSessionIdValid();
+ }
+
+ /**
+ * Returns the portal preferred content type for the response.
+ * <p>
+ * The content type only includes the MIME type, not the character set.
+ * <p>
+ * Only content types that the portlet has defined in its deployment descriptor are valid return
+ * values for this method call. If the portlet has defined <code>'*'</code> or
+ * <code>'* / *'</code> as supported content types, these may also be valid return values.
+ *
+ * @return preferred MIME type of the response
+ */
+ public String getResponseContentType()
+ {
+ return mRequest.getResponseContentType();
+ }
+
+ /**
+ * Gets a list of content types which the portal accepts for the response. This list is ordered
+ * with the most preferable types listed first.
+ * <p>
+ * The content type only includes the MIME type, not the character set.
+ * <p>
+ * Only content types that the portlet has defined in its deployment descriptor are valid return
+ * values for this method call. If the portlet has defined <code>'*'</code> or
+ * <code>'* / *'</code> as supported content types, these may also be valid return values.
+ *
+ * @return ordered list of MIME types for the response
+ */
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getResponseContentTypes()
+ {
+ return mRequest.getResponseContentTypes();
+ }
+
+ /**
+ * Returns the preferred Locale in which the portal will accept content. The Locale may be based
+ * on the Accept-Language header of the client.
+ *
+ * @return the prefered Locale in which the portal will accept content.
+ */
+ public Locale getLocale()
+ {
+ return mRequest.getLocale();
+ }
+
+ /**
+ * Returns an Enumeration of Locale objects indicating, in decreasing order starting with the
+ * preferred locale in which the portal will accept content for this request. The Locales may be
+ * based on the Accept-Language header of the client.
+ *
+ * @return an Enumeration of Locales, in decreasing order, in which the portal will accept content
+ * for this request
+ */
+ @SuppressWarnings("unchecked")
+ public Enumeration<Locale> getLocales()
+ {
+ return mRequest.getLocales();
+ }
+
+ /**
+ * Returns the name of the scheme used to make this request. For example, <code>http</code>,
+ * <code>https</code>, or <code>ftp</code>. Different schemes have different rules for
+ * constructing URLs, as noted in RFC 1738.
+ *
+ * @return a <code>String</code> containing the name of the scheme used to make this request
+ */
+ public String getScheme()
+ {
+ return mRequest.getScheme();
+ }
+
+ /**
+ * Returns the host name of the server that received the request.
+ *
+ * @return a <code>String</code> containing the name of the server to which the request was sent
+ */
+ public String getServerName()
+ {
+ return mRequest.getServerName();
+ }
+
+ /**
+ * Returns the port number on which this request was received.
+ *
+ * @return an integer specifying the port number
+ */
+ public int getServerPort()
+ {
+ return mRequest.getServerPort();
+ }
+
+}
Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletResponseDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletResponseDecorator.java?rev=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletResponseDecorator.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/PortletResponseDecorator.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,119 @@
+/* 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.common.portlet.wrapper;
+
+import javax.portlet.PortletResponse;
+
+public class PortletResponseDecorator implements PortletResponse
+{
+ protected PortletResponse mResponse = null;
+
+ public PortletResponseDecorator(PortletResponse response) throws IllegalArgumentException
+ {
+ if (response == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ mResponse = response;
+ }
+
+ public PortletResponse getParent()
+ {
+ return mResponse;
+ }
+
+ public PortletResponse getRoot()
+ {
+ PortletResponse root = mResponse;
+ while (root instanceof PortletResponseDecorator)
+ {
+ root = ((PortletResponseDecorator) root).getParent();
+ }
+ return root;
+ }
+
+ /**
+ * Adds a String property to an existing key to be returned to the portal.
+ * <p>
+ * This method allows response properties to have multiple values.
+ * <p>
+ * Properties can be used by portlets to provide vendor specific information to the portal.
+ *
+ * @param key
+ * the key of the property to be returned to the portal
+ * @param value
+ * the value of the property to be returned to the portal
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if key is <code>null</code>.
+ */
+ public void addProperty(String key, String value)
+ {
+ mResponse.addProperty(key, value);
+ }
+
+ /**
+ * Sets a String property to be returned to the portal.
+ * <p>
+ * Properties can be used by portlets to provide vendor specific information to the portal.
+ * <p>
+ * This method resets all properties previously added with the same key.
+ *
+ * @param key
+ * the key of the property to be returned to the portal
+ * @param value
+ * the value of the property to be returned to the portal
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if key is <code>null</code>.
+ */
+ public void setProperty(String key, String value)
+ {
+ mResponse.setProperty(key, value);
+ }
+
+ /**
+ * Returns the encoded URL of the resource, like servlets, JSPs, images and other static files, at
+ * the given path.
+ * <p>
+ * Some portal/portlet-container implementation may require those URLs to contain implementation
+ * specific data encoded in it. Because of that, portlets should use this method to create such
+ * URLs.
+ * <p>
+ * The <code>encodeURL</code> method may include the session ID and other
+ * portal/portlet-container specific information into the URL. If encoding is not needed, it
+ * returns the URL unchanged.
+ *
+ * @param path
+ * the URI path to the resource. This must be either an absolute URL (e.g.
+ * <code>http://my.co/myportal/mywebap/myfolder/myresource.gif</code>) or a full path
+ * URI (e.g. <code>/myportal/mywebap/myfolder/myresource.gif</code>).
+ *
+ * @exception java.lang.IllegalArgumentException
+ * if path doesn't have a leading slash or is not an absolute URL
+ *
+ * @return the encoded resource URL as string
+ */
+ public String encodeURL(String path)
+ {
+ return mResponse.encodeURL(path);
+ }
+
+}
Added: myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/RenderRequestDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/RenderRequestDecorator.java?rev=820782&view=auto
==============================================================================
--- myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/RenderRequestDecorator.java (added)
+++ myfaces/portlet-bridge/testsuite/trunk/src/main/java/org/apache/myfaces/portlet/faces/testsuite/common/portlet/wrapper/RenderRequestDecorator.java Thu Oct 1 20:47:19 2009
@@ -0,0 +1,33 @@
+/* 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.common.portlet.wrapper;
+
+import javax.portlet.RenderRequest;
+
+public class RenderRequestDecorator extends PortletRequestDecorator implements RenderRequest
+{
+
+ public RenderRequestDecorator(RenderRequest request) throws IllegalArgumentException
+ {
+
+ super(request);
+ }
+
+}