JBoss Portal SVN: r9718 - modules/portlet/trunk/test/src/test/resources/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-02 20:56:50 -0500 (Sat, 02 Feb 2008)
New Revision: 9718
Modified:
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- test case for filter config
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-03 01:53:19 UTC (rev 9717)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-03 01:56:50 UTC (rev 9718)
@@ -4,10 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
-<!--
- -->
-<!--Spec TCK Assertions tests-->
-<!--
+ <!--Spec TCK Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-tck-dispatcher.war"/>
@@ -53,9 +50,7 @@
<property name="archiveId" value="test-jsr168-tck-windowstates.war"/>
</generic>
- -->
-<!--API Tests-->
-<!--
+ <!--API Tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-api-actionrequest.war"/>
@@ -109,9 +104,7 @@
<property name="archiveId" value="test-jsr168-api-windowstate.war"/>
</generic>
- -->
-<!--Ext Tests-->
-<!--
+ <!--Ext Tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-portletconfig.war"/>
@@ -153,9 +146,7 @@
<property name="archiveId" value="test-jsr168-ext-taglib.war"/>
</generic>
- -->
-<!--Spec TCK Assertions tests-->
-<!--
+ <!--Spec TCK Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-dispatcher.war"/>
@@ -192,24 +183,18 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portleturl.war"/>
</generic>
--->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletfilter.war"/>
</generic>
-<!--
- -->
-<!--Spec API Assertions tests-->
-<!--
+ <!--Spec API Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-api-event.war"/>
</generic>
- -->
-<!--Ext Assertions tests-->
-<!--
+ <!--Ext Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletrequests.war"/>
@@ -222,7 +207,6 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-dispatcher.war"/>
</generic>
--->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletfilter.war"/>
16 years, 3 months
JBoss Portal SVN: r9717 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-02 20:53:19 -0500 (Sat, 02 Feb 2008)
New Revision: 9717
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomActionRequest.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomActionResponse.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomEventRequest.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomEventResponse.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomRenderRequest.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomRenderResponse.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomResourceRequest.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomResourceResponse.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsFilter1.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsFilter2.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/PortletApplication20MetaData.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractPortletFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractRenderFilter.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- test case for filter config
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/PortletApplication20MetaData.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/PortletApplication20MetaData.java 2008-02-03 00:39:42 UTC (rev 9716)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/PortletApplication20MetaData.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -144,7 +144,7 @@
{
if(this.filterMapping == null)
{
- this.filterMapping = new HashMap<String, FilterMappingMetaData>();
+ this.filterMapping = new LinkedHashMap<String, FilterMappingMetaData>();
}
this.filterMapping.put(filterMapping.getName(), filterMapping);
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractPortletFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractPortletFilter.java 2008-02-03 00:39:42 UTC (rev 9716)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractPortletFilter.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -23,13 +23,24 @@
package org.jboss.portal.test.portlet.jsr286.common;
import javax.portlet.filter.FilterConfig;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.filter.PortletFilter;
import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public abstract class AbstractPortletFilter
+public abstract class AbstractPortletFilter implements PortletFilter
{
/** . */
@@ -61,4 +72,24 @@
return null;
}
}
+
+ public void doFilter(ActionRequest req, ActionResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ chain.doFilter(req, resp);
+ }
+
+ public void doFilter(EventRequest req, EventResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ chain.doFilter(req, resp);
+ }
+
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ chain.doFilter(req, resp);
+ }
+
+ public void doFilter(ResourceRequest req, ResourceResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ chain.doFilter(req, resp);
+ }
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractRenderFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractRenderFilter.java 2008-02-03 00:39:42 UTC (rev 9716)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractRenderFilter.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -35,8 +35,4 @@
*/
public class AbstractRenderFilter extends AbstractPortletFilter implements RenderFilter
{
- public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
- {
- chain.doFilter(req, resp);
- }
}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomActionRequest.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomActionRequest.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomActionRequest.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.ActionRequestWrapper;
+import javax.portlet.ActionRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomActionRequest extends ActionRequestWrapper
+{
+ public CustomActionRequest(ActionRequest actionRequest)
+ {
+ super(actionRequest);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomActionResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomActionResponse.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomActionResponse.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.ActionResponseWrapper;
+import javax.portlet.ActionResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomActionResponse extends ActionResponseWrapper
+{
+ public CustomActionResponse(ActionResponse actionResponse)
+ {
+ super(actionResponse);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomEventRequest.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomEventRequest.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomEventRequest.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.EventRequestWrapper;
+import javax.portlet.EventRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomEventRequest extends EventRequestWrapper
+{
+ public CustomEventRequest(EventRequest eventRequest)
+ {
+ super(eventRequest);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomEventResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomEventResponse.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomEventResponse.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.EventResponseWrapper;
+import javax.portlet.EventResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomEventResponse extends EventResponseWrapper
+{
+ public CustomEventResponse(EventResponse eventResponse)
+ {
+ super(eventResponse);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomRenderRequest.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomRenderRequest.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomRenderRequest.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.RenderRequestWrapper;
+import javax.portlet.RenderRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomRenderRequest extends RenderRequestWrapper
+{
+ public CustomRenderRequest(RenderRequest renderRequest)
+ {
+ super(renderRequest);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomRenderResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomRenderResponse.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomRenderResponse.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.RenderResponseWrapper;
+import javax.portlet.RenderResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomRenderResponse extends RenderResponseWrapper
+{
+ public CustomRenderResponse(RenderResponse renderResponse)
+ {
+ super(renderResponse);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomResourceRequest.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomResourceRequest.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomResourceRequest.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.ResourceRequestWrapper;
+import javax.portlet.ResourceRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomResourceRequest extends ResourceRequestWrapper
+{
+ public CustomResourceRequest(ResourceRequest resourceRequest)
+ {
+ super(resourceRequest);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomResourceResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomResourceResponse.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/CustomResourceResponse.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.ResourceResponseWrapper;
+import javax.portlet.ResourceResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CustomResourceResponse extends ResourceResponseWrapper
+{
+ public CustomResourceResponse(ResourceResponse resourceResponse)
+ {
+ super(resourceResponse);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsFilter1.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsFilter1.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsFilter1.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+import org.jboss.portal.test.portlet.jsr286.common.AbstractPortletFilter;
+import org.jboss.portal.test.portlet.jsr286.common.CustomRenderRequest;
+import org.jboss.portal.test.portlet.jsr286.common.CustomRenderResponse;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.filter.RenderFilter;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PropagateDoFilterArgsFilter1 extends AbstractPortletFilter implements RenderFilter
+{
+
+ /** . */
+ public static CustomRenderRequest publishedRenderRequest;
+
+ /** . */
+ public static CustomRenderResponse publishedRenderResponse;
+
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ try
+ {
+ chain.doFilter(publishedRenderRequest = new CustomRenderRequest(req), publishedRenderResponse = new CustomRenderResponse(resp));
+ }
+ finally
+ {
+ publishedRenderRequest = null;
+ publishedRenderResponse = null;
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsFilter2.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsFilter2.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsFilter2.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+import org.jboss.portal.test.portlet.jsr286.common.AbstractPortletFilter;
+import org.jboss.portal.test.portlet.jsr286.common.CustomRenderRequest;
+import org.jboss.portal.test.portlet.jsr286.common.CustomRenderResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.filter.RenderFilter;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PropagateDoFilterArgsFilter2 extends AbstractPortletFilter implements RenderFilter
+{
+
+ /** . */
+ public static RenderRequest consumedRenderRequest;
+
+ /** . */
+ public static RenderResponse consumedRenderResponse;
+
+ /** . */
+ public static CustomRenderRequest publishedRenderRequest;
+
+ /** . */
+ public static CustomRenderResponse publishedRenderResponse;
+
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ consumedRenderRequest = req;
+ consumedRenderResponse = resp;
+
+ //
+ try
+ {
+ chain.doFilter(publishedRenderRequest = new CustomRenderRequest(req), publishedRenderResponse = new CustomRenderResponse(resp));
+ }
+ finally
+ {
+ consumedRenderRequest = null;
+ consumedRenderResponse = null;
+ publishedRenderRequest = null;
+ publishedRenderResponse = null;
+ }
+ }
+}
\ No newline at end of file
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PropagateDoFilterArgsTestCase.java 2008-02-03 01:53:19 UTC (rev 9717)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP3;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase(Assertion.JSR286_296)
+public class PropagateDoFilterArgsTestCase
+{
+ public PropagateDoFilterArgsTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest req, RenderResponse resp, PortletTestContext context) throws PortletException, IOException
+ {
+ assertSame(PropagateDoFilterArgsFilter1.publishedRenderRequest, PropagateDoFilterArgsFilter2.consumedRenderRequest);
+ assertSame(PropagateDoFilterArgsFilter1.publishedRenderResponse, PropagateDoFilterArgsFilter2.consumedRenderResponse);
+ assertSame(PropagateDoFilterArgsFilter2.publishedRenderRequest, req);
+ assertSame(PropagateDoFilterArgsFilter2.publishedRenderResponse, resp);
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/portlet.xml 2008-02-03 00:39:42 UTC (rev 9716)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/portlet.xml 2008-02-03 01:53:19 UTC (rev 9717)
@@ -55,6 +55,20 @@
</supported-publishing-event>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletC</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP3</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Event</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ </portlet>
+
<filter>
<filter-name>PortletFilterCounter</filter-name>
<filter-class>org.jboss.portal.test.portlet.jsr286.tck.portletfilter.PortletFilterCounter</filter-class>
@@ -79,6 +93,18 @@
<lifecycle>RESOURCE_PHASE</lifecycle>
</filter>
+ <filter>
+ <filter-name>PropagateDoFilterArgsFilter1</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.tck.portletfilter.PropagateDoFilterArgsFilter1</filter-class>
+ <lifecycle>RENDER_PHASE</lifecycle>
+ </filter>
+
+ <filter>
+ <filter-name>PropagateDoFilterArgsFilter2</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.tck.portletfilter.PropagateDoFilterArgsFilter2</filter-class>
+ <lifecycle>RENDER_PHASE</lifecycle>
+ </filter>
+
<filter-mapping>
<filter-name>WildcardFilter</filter-name>
<portlet-name>*</portlet-name>
@@ -89,6 +115,16 @@
<portlet-name>Prefixed*</portlet-name>
</filter-mapping>
+ <filter-mapping>
+ <filter-name>PropagateDoFilterArgsFilter1</filter-name>
+ <portlet-name>UniversalTestPortletC</portlet-name>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>PropagateDoFilterArgsFilter2</filter-name>
+ <portlet-name>UniversalTestPortletC</portlet-name>
+ </filter-mapping>
+
<event-definition>
<name>Event</name>
</event-definition>
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-03 00:39:42 UTC (rev 9716)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-03 01:53:19 UTC (rev 9717)
@@ -4,7 +4,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
- <!--Spec TCK Assertions tests-->
+<!--
+ -->
+<!--Spec TCK Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-tck-dispatcher.war"/>
@@ -50,7 +53,9 @@
<property name="archiveId" value="test-jsr168-tck-windowstates.war"/>
</generic>
- <!--API Tests-->
+ -->
+<!--API Tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-api-actionrequest.war"/>
@@ -104,7 +109,9 @@
<property name="archiveId" value="test-jsr168-api-windowstate.war"/>
</generic>
- <!--Ext Tests-->
+ -->
+<!--Ext Tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-portletconfig.war"/>
@@ -146,7 +153,9 @@
<property name="archiveId" value="test-jsr168-ext-taglib.war"/>
</generic>
- <!--Spec TCK Assertions tests-->
+ -->
+<!--Spec TCK Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-dispatcher.war"/>
@@ -183,18 +192,24 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portleturl.war"/>
</generic>
+-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletfilter.war"/>
</generic>
- <!--Spec API Assertions tests-->
+<!--
+ -->
+<!--Spec API Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-api-event.war"/>
</generic>
- <!--Ext Assertions tests-->
+ -->
+<!--Ext Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletrequests.war"/>
@@ -207,6 +222,7 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-dispatcher.war"/>
</generic>
+-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletfilter.war"/>
16 years, 3 months
JBoss Portal SVN: r9716 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api and 10 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-02 19:39:42 -0500 (Sat, 02 Feb 2008)
New Revision: 9716
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractPortletFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractRenderFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/FilterConfigFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/FilterConfigTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/web.xml
Removed:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractPortletFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractRenderFilter.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterConfigImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/Filter1.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterCounter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/TraceFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/WildcardTestCase.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- test case for filter config
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -213,7 +213,7 @@
context.getClassLoader(),
className,
"filter",
- filterInfo.getName());
+ filterInfo);
//
lifeCycle.create();
@@ -352,24 +352,24 @@
{
/** . */
- private final String filterName;
+ private final ContainerFilterInfo info;
private FilterLifecycle(
Class<PortletFilter> expectedClass,
ClassLoader classLoader,
String className,
String type,
- String filterName)
+ ContainerFilterInfo info)
{
super(log, expectedClass, classLoader, className, type);
//
- this.filterName = filterName;
+ this.info = info;
}
public void start(PortletFilter instance) throws Exception
{
- FilterConfigImpl config = new FilterConfigImpl(filterName, portletContext);
+ FilterConfigImpl config = new FilterConfigImpl(info, portletContext);
//
instance.init(config);
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterConfigImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterConfigImpl.java 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterConfigImpl.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -23,10 +23,12 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.portlet.impl.info.ContainerFilterInfo;
import javax.portlet.filter.FilterConfig;
import javax.portlet.PortletContext;
import java.util.Enumeration;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -36,20 +38,20 @@
{
/** . */
- private final String name;
+ private final ContainerFilterInfo filterInfo;
/** . */
private final PortletContext context;
- public FilterConfigImpl(String name, PortletContext context)
+ public FilterConfigImpl(ContainerFilterInfo filterInfo, PortletContext context)
{
- this.name = name;
+ this.filterInfo = filterInfo;
this.context = context;
}
public String getFilterName()
{
- return name;
+ return filterInfo.getName();
}
public PortletContext getPortletContext()
@@ -57,13 +59,20 @@
return context;
}
- public String getInitParameter(String s)
+ public String getInitParameter(String name)
{
- throw new NotYetImplemented();
+ if (name != null)
+ {
+ return filterInfo.getParameters().get(name);
+ }
+ else
+ {
+ return null;
+ }
}
public Enumeration getInitParameterNames()
{
- throw new NotYetImplemented();
+ return Collections.enumeration(filterInfo.getParameters().keySet());
}
}
Copied: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractPortletFilter.java (from rev 9715, modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractPortletFilter.java)
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractPortletFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractPortletFilter.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.FilterConfig;
+import javax.portlet.PortletException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class AbstractPortletFilter
+{
+
+ /** . */
+ private FilterConfig config;
+
+ public void init(FilterConfig config) throws PortletException
+ {
+ this.config = config;
+ }
+
+ public void destroy()
+ {
+ this.config = null;
+ }
+
+ protected FilterConfig getConfig()
+ {
+ return config;
+ }
+
+ protected String getName()
+ {
+ if (config != null)
+ {
+ return config.getFilterName();
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Copied: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractRenderFilter.java (from rev 9715, modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractRenderFilter.java)
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractRenderFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/common/AbstractRenderFilter.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.common;
+
+import javax.portlet.filter.RenderFilter;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class AbstractRenderFilter extends AbstractPortletFilter implements RenderFilter
+{
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ chain.doFilter(req, resp);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/FilterConfigFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/FilterConfigFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/FilterConfigFilter.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.ext.portletfilter;
+
+import org.jboss.portal.test.portlet.jsr286.common.AbstractRenderFilter;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.filter.FilterChain;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class FilterConfigFilter extends AbstractRenderFilter
+{
+
+ /** . */
+ public static String name;
+
+ /** . */
+ public static Map<String, String> parameters;
+
+ public void init(javax.portlet.filter.FilterConfig config) throws PortletException
+ {
+ super.init(config);
+
+ //
+ HashMap<String, String> tmp = new HashMap<String, String>();
+ for (Enumeration e = config.getInitParameterNames();e.hasMoreElements();)
+ {
+ String name = (String)e.nextElement();
+ String value = config.getInitParameter(name);
+ tmp.put(name, value);
+ }
+
+ //
+ name = config.getFilterName();
+ parameters = tmp;
+ }
+
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ chain.doFilter(req, resp);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/FilterConfigTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/FilterConfigTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/FilterConfigTestCase.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.ext.portletfilter;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.common.util.MapBuilder;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import java.io.IOException;
+
+/**
+ * Test that the init parameters of a filter are correct.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase()
+public class FilterConfigTestCase
+{
+ public FilterConfigTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("FilterConfigFilter", FilterConfigFilter.name);
+ assertEquals(MapBuilder.hashMap("foo", "foo_value").put("bar", "bar_value").get(), FilterConfigFilter.parameters);
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Deleted: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractPortletFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractPortletFilter.java 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractPortletFilter.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -1,64 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
-
-import javax.portlet.filter.FilterConfig;
-import javax.portlet.PortletException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public abstract class AbstractPortletFilter
-{
-
- /** . */
- private FilterConfig config;
-
- public void init(FilterConfig config) throws PortletException
- {
- this.config = config;
- }
-
- public void destroy()
- {
- this.config = null;
- }
-
- protected FilterConfig getConfig()
- {
- return config;
- }
-
- protected String getName()
- {
- if (config != null)
- {
- return config.getFilterName();
- }
- else
- {
- return null;
- }
- }
-}
Deleted: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractRenderFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractRenderFilter.java 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractRenderFilter.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -1,42 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
-
-import javax.portlet.filter.RenderFilter;
-import javax.portlet.filter.FilterChain;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.portlet.PortletException;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class AbstractRenderFilter extends AbstractPortletFilter implements RenderFilter
-{
- public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
- {
- chain.doFilter(req, resp);
- }
-}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/Filter1.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/Filter1.java 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/Filter1.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+import org.jboss.portal.test.portlet.jsr286.common.AbstractRenderFilter;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterCounter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterCounter.java 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterCounter.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+import org.jboss.portal.test.portlet.jsr286.common.AbstractRenderFilter;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/TraceFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/TraceFilter.java 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/TraceFilter.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+import org.jboss.portal.test.portlet.jsr286.common.AbstractPortletFilter;
+
import javax.portlet.filter.ActionFilter;
import javax.portlet.filter.EventFilter;
import javax.portlet.filter.RenderFilter;
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/WildcardTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/WildcardTestCase.java 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/WildcardTestCase.java 2008-02-03 00:39:42 UTC (rev 9716)
@@ -53,7 +53,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-(a)TestCase({Assertion.JSR286_298})
+(a)TestCase({Assertion.JSR286_298,Assertion.JSR286_300})
public class WildcardTestCase
{
public WildcardTestCase(PortletTestCase seq)
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-03 00:39:42 UTC (rev 9716)
@@ -263,6 +263,12 @@
includes="org/jboss/portal/test/portlet/@{testsuiteversion}/@{testsuitetype}/common/**"/>
<fileset
dir="${test.temp.portlet}"
+ includes="org/jboss/portal/test/portlet/@{testsuiteversion}/common/**"/>
+ <fileset
+ dir="${test.temp.portlet}"
+ includes="org/jboss/portal/test/portlet/common/**"/>
+ <fileset
+ dir="${test.temp.portlet}"
includes="org/jboss/portal/test/portlet/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}/**"/>
<fileset
dir="${test.temp.portlet}"
@@ -361,6 +367,7 @@
<package-jsr286-tck-test test="portletfilter"/>
<package-jsr286-api-test test="event"/>
<package-jsr286-ext-test test="portletrequests"/>
+ <package-jsr286-ext-test test="portletfilter"/>
<package-jsr286-ext-test test="portletresponses"/>
<package-jsr286-ext-test test="dispatcher"/>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/portlet.xml 2008-02-03 00:39:42 UTC (rev 9716)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ </portlet>
+
+ <filter>
+ <filter-name>FilterConfigFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.ext.portletfilter.FilterConfigFilter</filter-class>
+ <lifecycle>RENDER_PHASE</lifecycle>
+ <init-param>
+ <name>foo</name>
+ <value>foo_value</value>
+ </init-param>
+ <init-param>
+ <name>bar</name>
+ <value>bar_value</value>
+ </init-param>
+ </filter>
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/web.xml 2008-02-03 00:39:42 UTC (rev 9716)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <listener>
+ <listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+</web-app>
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-02 23:18:06 UTC (rev 9715)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-03 00:39:42 UTC (rev 9716)
@@ -207,6 +207,10 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-dispatcher.war"/>
</generic>
+ <generic>
+ <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId" value="test-jsr286-ext-portletfilter.war"/>
+ </generic>
<!--Misc Tests-->
<!--
16 years, 3 months
JBoss Portal SVN: r9715 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck and 8 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-02 18:18:06 -0500 (Sat, 02 Feb 2008)
New Revision: 9715
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractPortletFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractRenderFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/Filter1.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterCounter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/TraceFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/WildcardTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/web.xml
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestDriver.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- start to implement filtering test case
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-02-02 18:26:59 UTC (rev 9714)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -204,6 +204,13 @@
{
tmp.setFilters(EMPTY_FILTER_MAP);
}
+ for (FilterMetaData filterMD : tmp.getFilters().values())
+ {
+ if (filterMD.getInitParams() == null)
+ {
+ filterMD.setInitParams(EMPTY_INIT_PARAM_LIST);
+ }
+ }
if (tmp.getFilterMapping() == null)
{
tmp.setFilterMapping(EMPTY_FILTER_MAPPING_MAP);
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractPortletFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractPortletFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractPortletFilter.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+import javax.portlet.filter.FilterConfig;
+import javax.portlet.PortletException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class AbstractPortletFilter
+{
+
+ /** . */
+ private FilterConfig config;
+
+ public void init(FilterConfig config) throws PortletException
+ {
+ this.config = config;
+ }
+
+ public void destroy()
+ {
+ this.config = null;
+ }
+
+ protected FilterConfig getConfig()
+ {
+ return config;
+ }
+
+ protected String getName()
+ {
+ if (config != null)
+ {
+ return config.getFilterName();
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractRenderFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractRenderFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/AbstractRenderFilter.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+import javax.portlet.filter.RenderFilter;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class AbstractRenderFilter extends AbstractPortletFilter implements RenderFilter
+{
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ chain.doFilter(req, resp);
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/Filter1.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/Filter1.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/Filter1.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class Filter1 extends AbstractRenderFilter
+{
+
+
+
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterCounter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterCounter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterCounter.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletFilterCounter extends AbstractRenderFilter
+{
+
+ /** . */
+ private static int counter;
+
+ public static int getCounter()
+ {
+ synchronized (PortletFilterCounter.class)
+ {
+ return counter;
+ }
+ }
+
+ public PortletFilterCounter()
+ {
+ synchronized (PortletFilterCounter.class)
+ {
+ counter++;
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/PortletFilterTestCase.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_297})
+public class PortletFilterTestCase
+{
+ public PortletFilterTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals(1, PortletFilterCounter.getCounter());
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/TraceFilter.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/TraceFilter.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/TraceFilter.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -0,0 +1,149 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+import javax.portlet.filter.ActionFilter;
+import javax.portlet.filter.EventFilter;
+import javax.portlet.filter.RenderFilter;
+import javax.portlet.filter.ResourceFilter;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class TraceFilter extends AbstractPortletFilter implements ActionFilter, EventFilter, RenderFilter, ResourceFilter
+{
+
+ /** . */
+ public static final int ACTION = 0;
+
+ /** . */
+ public static final int EVENT = 1;
+
+ /** . */
+ public static final int RENDER = 2;
+
+ /** . */
+ public static final int RESOURCE = 3;
+
+ /** . */
+ private static final Map<String, Integer> traces = new HashMap<String, Integer>();
+
+ public static boolean isActive(String name, int type)
+ {
+ return traces.containsKey(name) && traces.get(name) == type;
+ }
+
+ private static void push(String name, int type)
+ {
+ if (!traces.containsKey(name))
+ {
+ traces.put(name, type);
+ }
+ }
+
+ private static void pop(String name, int type)
+ {
+ if (isActive(name, type))
+ {
+ traces.remove(name);
+ }
+ }
+
+ public void doFilter(ActionRequest req, ActionResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ String name = getName();
+
+ //
+ push(name, ACTION);
+ try
+ {
+ chain.doFilter(req, resp);
+ }
+ finally
+ {
+ pop(name, ACTION);
+ }
+ }
+
+ public void doFilter(EventRequest req, EventResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ String name = getName();
+
+ //
+ push(name, EVENT);
+ try
+ {
+ chain.doFilter(req, resp);
+ }
+ finally
+ {
+ pop(name, EVENT);
+ }
+ }
+
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ String name = getName();
+
+ //
+ push(name, RENDER);
+ try
+ {
+ chain.doFilter(req, resp);
+ }
+ finally
+ {
+ pop(name, RENDER);
+ }
+ }
+
+ public void doFilter(ResourceRequest req, ResourceResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ String name = getName();
+
+ //
+ push(name, RESOURCE);
+ try
+ {
+ chain.doFilter(req, resp);
+ }
+ finally
+ {
+ pop(name, RESOURCE);
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/WildcardTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/WildcardTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletfilter/WildcardTestCase.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -0,0 +1,146 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portletfilter;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTP2;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_298})
+public class WildcardTestCase
+{
+ public WildcardTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.ACTION));
+ assertFalse((TraceFilter.isActive("PartialWildcardFilter", TraceFilter.ACTION)));
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(1, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.EVENT));
+ assertFalse((TraceFilter.isActive("PartialWildcardFilter", TraceFilter.EVENT)));
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.RENDER));
+ assertFalse((TraceFilter.isActive("PartialWildcardFilter", TraceFilter.RENDER)));
+ return new InvokeGetResponse(response.createResourceURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.RESOURCE));
+ assertFalse((TraceFilter.isActive("PartialWildcardFilter", TraceFilter.RESOURCE)));
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(3, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(4, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.ACTION));
+ assertTrue(TraceFilter.isActive("PartialWildcardFilter", TraceFilter.ACTION));
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(4, UTP2.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.EVENT));
+ assertTrue(TraceFilter.isActive("PartialWildcardFilter", TraceFilter.EVENT));
+ }
+ });
+ seq.bindAction(4, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.RENDER));
+ assertTrue(TraceFilter.isActive("PartialWildcardFilter", TraceFilter.RENDER));
+ return new InvokeGetResponse(response.createResourceURL().toString());
+ }
+ });
+ seq.bindAction(5, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertTrue(TraceFilter.isActive("WildcardFilter", TraceFilter.RESOURCE));
+ assertTrue(TraceFilter.isActive("PartialWildcardFilter", TraceFilter.RESOURCE));
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestCase.java 2008-02-02 18:26:59 UTC (rev 9714)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestCase.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -26,6 +26,8 @@
import org.jboss.portal.unit.JoinPointType;
import org.jboss.portal.unit.JoinPoint;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -77,7 +79,7 @@
internalBind(requestCount, nodeId, joinPoint, action);
}
- public void internalBind(Integer count, NodeId nodeId, JoinPoint joinPoint, TestAction action)
+ private void internalBind(Integer count, NodeId nodeId, JoinPoint joinPoint, TestAction action)
{
if (action == null)
{
@@ -124,6 +126,19 @@
return null;
}
+ public Set<JoinPoint> getJoinPoints(int count)
+ {
+ Set<JoinPoint> joinPoints = new HashSet<JoinPoint>();
+ for (Key key : bindings.keySet())
+ {
+ if (key.count == count)
+ {
+ joinPoints.add(key.joinPoint);
+ }
+ }
+ return joinPoints;
+ }
+
public TestAction getAction(int count, NodeId nodeId, JoinPoint joinPoint)
{
// Try a timed action
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java 2008-02-02 18:26:59 UTC (rev 9714)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -35,6 +35,8 @@
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -50,6 +52,9 @@
final PortletTestCase portletTestCase;
/** . */
+ final Set<JoinPoint> invoked;
+
+ /** . */
RequestContext requestContext;
/** . */
@@ -64,6 +69,7 @@
this.testName = testName;
this.portletTestCase = portletTestCase;
this.requestContext = requestContext;
+ this.invoked = new HashSet<JoinPoint>();
}
public String getTestName()
@@ -71,6 +77,47 @@
return testName;
}
+ private static class JoinPointInvocation
+ {
+
+ /** . */
+ private final int requestCount;
+
+ /** . */
+ private final JoinPoint joinPoint;
+
+ private JoinPointInvocation(int requestCount, JoinPoint joinPoint)
+ {
+ this.requestCount = requestCount;
+ this.joinPoint = joinPoint;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof JoinPointInvocation)
+ {
+ JoinPointInvocation that = (JoinPointInvocation)obj;
+ return requestCount == that.requestCount && joinPoint.equals(that.joinPoint);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return requestCount + joinPoint.hashCode();
+ }
+ }
+
+ public void setInvoked(JoinPoint joinPoint)
+ {
+// invocations.add(new JoinPointInvocation(requestCount, joinPoint));
+ invoked.add(joinPoint);
+ }
+
public String getActorId(JoinPointType joinPointType)
{
return portletTestCase.getActorId(requestContext.getRequestCount(), joinPointType);
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestDriver.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestDriver.java 2008-02-02 18:26:59 UTC (rev 9714)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestDriver.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -188,6 +188,31 @@
public ResponseContext popContext(TestId testId)
{
+// // Ensuite that everything was called
+// Set<JoinPoint> expected = portletTestCase.getJoinPoints(context.requestContext.getRequestCount());
+//
+// if (!expected.equals(context.invoked))
+// {
+// Set<JoinPoint> notInvoked = new HashSet<JoinPoint>(expected);
+// notInvoked.removeAll(context.invoked);
+//
+// StringBuffer msg = new StringBuffer("Those joinpoints should have been invoked [");
+// for (Iterator<JoinPoint> i = notInvoked.iterator();i.hasNext();)
+// {
+// JoinPoint joinPoint = i.next();
+// msg.append(joinPoint);
+// if (i.hasNext())
+// {
+// msg.append(',');
+// }
+// }
+// msg.append(']');
+//
+// //
+// return new ResponseContext(new FailureResponse(Failure.createErrorFailure(msg.toString())), new HashMap<String, Serializable>());
+// }
+
+ //
return context.responseContext;
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-02-02 18:26:59 UTC (rev 9714)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-02-02 23:18:06 UTC (rev 9715)
@@ -268,7 +268,6 @@
reset();
}
- //
// Get the action
TestAction action = null;
PortletTestCase portletTestCase = getSequence(ctx.getTestName());
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-02 18:26:59 UTC (rev 9714)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-02 23:18:06 UTC (rev 9715)
@@ -358,6 +358,7 @@
<package-jsr286-tck-test test="portletrequests"/>
<package-jsr286-tck-test test="resourceserving"/>
<package-jsr286-tck-test test="portleturl"/>
+ <package-jsr286-tck-test test="portletfilter"/>
<package-jsr286-api-test test="event"/>
<package-jsr286-ext-test test="portletrequests"/>
<package-jsr286-ext-test test="portletresponses"/>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/portlet.xml 2008-02-02 23:18:06 UTC (rev 9715)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Event</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ </portlet>
+
+ <portlet>
+ <portlet-name>PrefixedUniversalTestPortletB</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP2</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Event</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ </portlet>
+
+ <filter>
+ <filter-name>PortletFilterCounter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.tck.portletfilter.PortletFilterCounter</filter-class>
+ <lifecycle>RENDER_PHASE</lifecycle>
+ </filter>
+
+ <filter>
+ <filter-name>WildcardFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.tck.portletfilter.TraceFilter</filter-class>
+ <lifecycle>ACTION_PHASE</lifecycle>
+ <lifecycle>EVENT_PHASE</lifecycle>
+ <lifecycle>RENDER_PHASE</lifecycle>
+ <lifecycle>RESOURCE_PHASE</lifecycle>
+ </filter>
+
+ <filter>
+ <filter-name>PartialWildcardFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr286.tck.portletfilter.TraceFilter</filter-class>
+ <lifecycle>ACTION_PHASE</lifecycle>
+ <lifecycle>EVENT_PHASE</lifecycle>
+ <lifecycle>RENDER_PHASE</lifecycle>
+ <lifecycle>RESOURCE_PHASE</lifecycle>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>WildcardFilter</filter-name>
+ <portlet-name>*</portlet-name>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>PartialWildcardFilter</filter-name>
+ <portlet-name>Prefixed*</portlet-name>
+ </filter-mapping>
+
+ <event-definition>
+ <name>Event</name>
+ </event-definition>
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletfilter-war/WEB-INF/web.xml 2008-02-02 23:18:06 UTC (rev 9715)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <listener>
+ <listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+</web-app>
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-02 18:26:59 UTC (rev 9714)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-02 23:18:06 UTC (rev 9715)
@@ -183,6 +183,10 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portleturl.war"/>
</generic>
+ <generic>
+ <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId" value="test-jsr286-tck-portletfilter.war"/>
+ </generic>
<!--Spec API Assertions tests-->
<generic>
16 years, 3 months
JBoss Portal SVN: r9714 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168 and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-02 13:26:59 -0500 (Sat, 02 Feb 2008)
New Revision: 9714
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ClassInstanceLifeCycle.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterChainImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterConfigImpl.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/test/src/test/build.xml
Log:
implementation of portlet filtering, no unit tests yet (but will follow).
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java 2008-02-02 14:21:03 UTC (rev 9713)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java 2008-02-02 18:26:59 UTC (rev 9714)
@@ -26,6 +26,7 @@
import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Map;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -41,7 +42,7 @@
private final String className;
/** . */
- private final LifeCyclePhase lifeCycle;
+ private final Set<LifeCyclePhase> lifeCycles;
/** . */
private final LocalizedString displayName;
@@ -55,14 +56,14 @@
public ContainerFilterInfo(
String name,
String className,
- LifeCyclePhase lifeCycle,
+ Set<LifeCyclePhase> lifeCycles,
LocalizedString displayName,
LocalizedString description,
Map<String, String> parameters)
{
this.name = name;
this.className = className;
- this.lifeCycle = lifeCycle;
+ this.lifeCycles = lifeCycles;
this.displayName = displayName;
this.description = description;
this.parameters = parameters;
@@ -78,9 +79,9 @@
return className;
}
- public LifeCyclePhase getLifeCycle()
+ public Set<LifeCyclePhase> getLifeCycles()
{
- return lifeCycle;
+ return lifeCycles;
}
public LocalizedString getDisplayName()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-02-02 14:21:03 UTC (rev 9713)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-02-02 18:26:59 UTC (rev 9714)
@@ -40,6 +40,7 @@
import org.jboss.portal.portlet.impl.metadata.PublicRenderParameterMetaData;
import org.jboss.portal.portlet.impl.metadata.ListenerMetaData;
import org.jboss.portal.portlet.impl.metadata.filter.FilterMetaData;
+import org.jboss.portal.portlet.impl.metadata.filter.FilterMappingMetaData;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.LifeCyclePhase;
import org.jboss.portal.common.util.ConversionException;
@@ -64,6 +65,7 @@
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Collections;
+import java.util.HashSet;
import java.net.URI;
import java.net.URISyntaxException;
@@ -84,6 +86,51 @@
private static final String[] BUNDLE_KEYS = {JAVAX_PORTLET + MetaInfo.TITLE, JAVAX_PORTLET + MetaInfo.SHORT_TITLE, JAVAX_PORTLET + MetaInfo.KEYWORDS};
/** . */
+ private static final List<ListenerMetaData> EMPTY_LISTENER_LIST = Collections.emptyList();
+
+ /** . */
+ private static final List<PublicRenderParameterMetaData> EMPTY_PUBLIC_RENDER_PARAMETER_LIST = Collections.emptyList();
+
+ /** . */
+ private static final List<EventDefinitionMetaData> EMPTY_EVENT_DEFINITION_LIST = Collections.emptyList();
+
+ /** . */
+ private static final List<SecurityRoleRefMetaData> EMPPTY_SECURITY_ROLE_REF_LIST = Collections.emptyList();
+
+ /** . */
+ private static final List<SecurityConstraintMetaData> EMPTY_SECURITY_CONSTRAINT_LIST = Collections.emptyList();
+
+ /** . */
+ private static final List<SupportedLocaleMetaData> EMPTY_SUPPORTED_LOCALE_LIST = Collections.emptyList();
+
+ /** . */
+ private static final List<PortletModeMetaData> EMPTY_PORTLET_MODE_LIST = Collections.emptyList();
+
+ /** . */
+ private static final List<WindowStateMetaData> EMPTY_WINDOW_STATE_LIST = Collections.emptyList();
+
+ /** . */
+ private static final Map<String,PortletPreferenceMetaData> EMPTY_PORTLET_PREFERENCE_MAP = Collections.emptyMap();
+
+ /** . */
+ private static final PortletPreferencesMetaData EMPTY_PORTLET_PREFERENCES = new PortletPreferencesMetaData();
+
+ /** . */
+ private static final List<InitParamMetaData> EMPTY_INIT_PARAM_LIST = Collections.emptyList();
+
+ /** . */
+ private static final List<String> EMPTY_STRING_LIST = Collections.emptyList();
+
+ /** . */
+ private static final List<EventDefinitionReferenceMetaData> EMPTY_EVENT_DEFINITION_REFERENCE_LIST = Collections.emptyList();
+
+ /** . */
+ private static final Map<String,FilterMappingMetaData> EMPTY_FILTER_MAPPING_MAP = Collections.emptyMap();
+
+ /** . */
+ private static final Map<String,FilterMetaData> EMPTY_FILTER_MAP = Collections.emptyMap();
+
+ /** . */
private final PortletApplication10MetaData portletApplicationMD;
/** . */
@@ -132,11 +179,11 @@
PortletApplication20MetaData tmp = (PortletApplication20MetaData)portletApplicationMD;
if (tmp.getEvents() == null)
{
- tmp.setEvents(new ArrayList<EventDefinitionMetaData>());
+ tmp.setEvents(EMPTY_EVENT_DEFINITION_LIST);
}
if (tmp.getPublicRenderParameters() == null)
{
- tmp.setPublicRenderParameters(new ArrayList<PublicRenderParameterMetaData>());
+ tmp.setPublicRenderParameters(EMPTY_PUBLIC_RENDER_PARAMETER_LIST);
}
if (tmp.getDefaultNamespace() == null)
{
@@ -151,8 +198,16 @@
}
if (tmp.getListeners() == null)
{
- tmp.setListeners(new ArrayList<ListenerMetaData>());
+ tmp.setListeners(EMPTY_LISTENER_LIST);
}
+ if (tmp.getFilters() == null)
+ {
+ tmp.setFilters(EMPTY_FILTER_MAP);
+ }
+ if (tmp.getFilterMapping() == null)
+ {
+ tmp.setFilterMapping(EMPTY_FILTER_MAPPING_MAP);
+ }
}
}
@@ -160,48 +215,48 @@
{
if (portletMD.getSecurityRoleRef() == null)
{
- portletMD.setSecurityRoleRef(new ArrayList<SecurityRoleRefMetaData>());
+ portletMD.setSecurityRoleRef(EMPPTY_SECURITY_ROLE_REF_LIST);
}
if (portletMD.getPortletApplication().getSecurityConstraints() == null)
{
- portletMD.getPortletApplication().setSecurityConstraints(new ArrayList<SecurityConstraintMetaData>());
+ portletMD.getPortletApplication().setSecurityConstraints(EMPTY_SECURITY_CONSTRAINT_LIST);
}
if (portletMD.getSupportedLocale() == null)
{
- portletMD.setSupportedLocale(new ArrayList<SupportedLocaleMetaData>());
+ portletMD.setSupportedLocale(EMPTY_SUPPORTED_LOCALE_LIST);
}
for (SupportsMetaData supportsMD : portletMD.getSupports())
{
if (supportsMD.getPortletModes() == null)
{
- supportsMD.setPortletModes(new ArrayList<PortletModeMetaData>());
+ supportsMD.setPortletModes(EMPTY_PORTLET_MODE_LIST);
}
if (supportsMD.getWindowStates() == null)
{
- supportsMD.setWindowStates(new ArrayList<WindowStateMetaData>());
+ supportsMD.setWindowStates(EMPTY_WINDOW_STATE_LIST);
}
}
if (portletMD.getPortletPreferences() == null)
{
- portletMD.setPortletPreferences(new PortletPreferencesMetaData());
+ portletMD.setPortletPreferences(EMPTY_PORTLET_PREFERENCES);
}
if (portletMD.getPortletPreferences().getPortletPreferences() == null)
{
- portletMD.getPortletPreferences().setPortletPreferences(new HashMap<String, PortletPreferenceMetaData>());
+ portletMD.getPortletPreferences().setPortletPreferences(EMPTY_PORTLET_PREFERENCE_MAP);
}
if (portletMD.getInitParams() == null)
{
- portletMD.setInitParams(new ArrayList<InitParamMetaData>());
+ portletMD.setInitParams(EMPTY_INIT_PARAM_LIST);
}
if (portletMD.getSupportedPublicRenderParameters() == null)
{
- portletMD.setSupportedPublicRenderParameters(new ArrayList<String>());
+ portletMD.setSupportedPublicRenderParameters(EMPTY_STRING_LIST);
}
for (PortletPreferenceMetaData portletPreferenceMD : portletMD.getPortletPreferences().getPortletPreferences().values())
{
if (portletPreferenceMD.getValue() == null)
{
- portletPreferenceMD.setValue(new ArrayList<String>());
+ portletPreferenceMD.setValue(EMPTY_STRING_LIST);
}
}
@@ -210,11 +265,11 @@
{
if (portletMD.getSupportedProcessingEvent() == null)
{
- portletMD.setSupportedProcessingEvent(new ArrayList<EventDefinitionReferenceMetaData>());
+ portletMD.setSupportedProcessingEvent(EMPTY_EVENT_DEFINITION_REFERENCE_LIST);
}
if (portletMD.getSupportedPublishingEvent() == null)
{
- portletMD.setSupportedPublishingEvent(new ArrayList<EventDefinitionReferenceMetaData>());
+ portletMD.setSupportedPublishingEvent(EMPTY_EVENT_DEFINITION_REFERENCE_LIST);
}
}
}
@@ -272,6 +327,7 @@
//
String defaultNamespace = XMLConstants.NULL_NS_URI;
List<ContainerListenerInfo> listeners = Collections.emptyList();
+ Map<String, ContainerFilterInfo> allFilters = new HashMap<String, ContainerFilterInfo>();
if (this.portletApplicationMD instanceof PortletApplication20MetaData)
{
PortletApplication20MetaData tmp = (PortletApplication20MetaData)this.portletApplicationMD;
@@ -311,16 +367,16 @@
}
listeners = Collections.unmodifiableList(listeners);
-
//
-// for (FilterMetaData filterMD : tmp.getFilterCollection())
-// {
-// ContainerFilterInfo filter = build(filterMD);
-// }
+ for (FilterMetaData filterMD : tmp.getFilterCollection())
+ {
+ ContainerFilterInfo filter = build(filterMD);
+ allFilters.put(filter.getName(), filter);
+ }
}
//
- return new ContainerPortletApplicationInfo(defaultNamespace, listeners);
+ return new ContainerPortletApplicationInfo(defaultNamespace, allFilters.values(), listeners);
}
private ContainerListenerInfo build(ListenerMetaData listenerMD)
@@ -339,13 +395,11 @@
initParameters.put(initParamMD.getName(), initParamMD.getValue());
}
- LifeCyclePhase lifeCycle;
-
//
return new ContainerFilterInfo(
filterMD.getFilterName(),
filterMD.getFilterClass(),
- null,
+ Collections.unmodifiableSet(new HashSet<LifeCyclePhase>(filterMD.getLifecycle())),
filterMD.getDisplayName(),
filterMD.getDescription(),
Collections.unmodifiableMap(initParameters)
@@ -425,6 +479,36 @@
ContainerNavigationInfo containerNavigation = buildContainerNavigationInfo(portletMD);
//
+ List<String> filters = new ArrayList<String>();
+ for (FilterMappingMetaData filterMappingMD : ((PortletApplication20MetaData)portletApplicationMD).getFilterMapping().values())
+ {
+ for (String portletName : filterMappingMD.getPortletNames())
+ {
+ boolean matches;
+ if (portletName.length() == 0)
+ {
+ // Do smth
+ matches = false;
+ }
+ else if (portletName.endsWith("*"))
+ {
+ String prefix = portletName.substring(0, portletName.length() - 1);
+ matches = portletMD.getPortletName().startsWith(prefix);
+ }
+ else
+ {
+ matches = portletMD.getPortletName().equals(portletName);
+ }
+
+ // Add the filter
+ if (matches)
+ {
+ filters.add(filterMappingMD.getName());
+ }
+ }
+ }
+
+ //
containerPortletInfo = new ContainerPortletInfo(
containerCapabilities,
containerPreferences,
@@ -434,6 +518,7 @@
containerSession,
containerEvents,
containerNavigation,
+ Collections.unmodifiableList(filters),
portletMD.getPortletName(),
portletMD.getPortletClass(),
Collections.unmodifiableMap(initParameters),
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java 2008-02-02 14:21:03 UTC (rev 9713)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java 2008-02-02 18:26:59 UTC (rev 9714)
@@ -23,6 +23,10 @@
package org.jboss.portal.portlet.impl.info;
import java.util.List;
+import java.util.Map;
+import java.util.LinkedHashMap;
+import java.util.Collections;
+import java.util.Collection;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -37,12 +41,24 @@
/** . */
private final List<ContainerListenerInfo> listeners;
+ /** . */
+ private final Map<String, ContainerFilterInfo> filters;
+
public ContainerPortletApplicationInfo(
String defaultNamespace,
+ Collection<ContainerFilterInfo> filters,
List<ContainerListenerInfo> listeners)
{
+ LinkedHashMap<String, ContainerFilterInfo> tmp = new LinkedHashMap<String, ContainerFilterInfo>();
+ for (ContainerFilterInfo filter : filters)
+ {
+ tmp.put(filter.getName(), filter);
+ }
+
+ //
this.defaultNamespace = defaultNamespace;
this.listeners = listeners;
+ this.filters = Collections.unmodifiableMap(tmp);
}
public String getDefaultNamespace()
@@ -54,4 +70,9 @@
{
return listeners;
}
+
+ public Map<String, ContainerFilterInfo> getFilters()
+ {
+ return filters;
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-02-02 14:21:03 UTC (rev 9713)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-02-02 18:26:59 UTC (rev 9714)
@@ -26,8 +26,9 @@
import org.jboss.portal.common.i18n.ResourceBundleManager;
import java.util.Map;
-import java.util.HashMap;
import java.util.Set;
+import java.util.List;
+import java.util.Collections;
/**
* For now implementation that use the portlet container directly.
@@ -78,6 +79,9 @@
/** . */
private final ContainerNavigationInfo navigation;
+ /** . */
+ private final List<String> filterRefs;
+
public ContainerPortletInfo(
ContainerCapabilitiesInfo capabilities,
ContainerPreferencesInfo preferences,
@@ -99,6 +103,7 @@
this.session = session;
this.events = new ContainerEventingInfo();
this.navigation = new ContainerNavigationInfo();
+ this.filterRefs = Collections.emptyList();
this.name = name;
this.className = className;
this.initParameters = initParameters;
@@ -115,6 +120,7 @@
ContainerSessionInfo session,
ContainerEventingInfo events,
ContainerNavigationInfo navigation,
+ List<String> filterRefs,
String name,
String className,
Map<String, String> initParameters,
@@ -129,6 +135,7 @@
this.session = session;
this.events = events;
this.navigation = navigation;
+ this.filterRefs = filterRefs;
this.name = name;
this.className = className;
this.initParameters = initParameters;
@@ -161,6 +168,11 @@
return initParameters.get(name);
}
+ public List<String> getFilterRefs()
+ {
+ return filterRefs;
+ }
+
public ContainerCapabilitiesInfo getCapabilities()
{
return capabilities;
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ClassInstanceLifeCycle.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ClassInstanceLifeCycle.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ClassInstanceLifeCycle.java 2008-02-02 18:26:59 UTC (rev 9714)
@@ -0,0 +1,179 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168;
+
+import org.jboss.portal.portlet.container.PortletInitializationException;
+import org.apache.log4j.Logger;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ClassInstanceLifeCycle<T>
+{
+
+ /** . */
+ private Logger log;
+
+ /** . */
+ private Class<T> expectedClass;
+
+ /** . */
+ private ClassLoader classLoader;
+
+ /** . */
+ private String className;
+
+ /** . */
+ private String type;
+
+ /** . */
+ private T instance;
+
+ public ClassInstanceLifeCycle(
+ Logger log,
+ Class<T> expectedClass,
+ ClassLoader classLoader,
+ String className,
+ String type)
+ {
+ this.log = log;
+ this.expectedClass = expectedClass;
+ this.classLoader = classLoader;
+ this.className = className;
+ this.type = type;
+ }
+
+ public void create() throws PortletInitializationException
+ {
+ T instance;
+ try
+ {
+ Class clazz = classLoader.loadClass(className);
+ if (expectedClass.isAssignableFrom(clazz))
+ {
+ Class<? extends T> castedClass = clazz.asSubclass(expectedClass);
+ Constructor<? extends T> ctor = castedClass.getConstructor();
+ instance = ctor.newInstance();
+ }
+ else
+ {
+ String msg = "Cannot create " + type + " with class " + className + " because it does not implement the expected interface " + expectedClass.getName();
+ throw new PortletInitializationException(msg);
+ }
+ }
+ catch (InvocationTargetException e)
+ {
+ String msg = "Cannot create " + type + " with class " + className + " because the class contructor threw an exception";
+ throw new PortletInitializationException(msg, e.getCause());
+ }
+ catch (IllegalAccessException e)
+ {
+ String msg = "Cannot create " + type + " with class " + className + " because the class is not accessible";
+ throw new PortletInitializationException(msg, e);
+ }
+ catch (NoSuchMethodException e)
+ {
+ String msg = "Cannot create " + type + " with class " + className + " because it does not have an no argument constructor";
+ throw new PortletInitializationException(msg, e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ String msg = "Cannot create " + type + " with class " + className + " because the class cannot be loaded";
+ throw new PortletInitializationException(msg, e);
+ }
+ catch (InstantiationException e)
+ {
+ String msg = "Cannot create " + type + " with class " + className + " because it cannot be instantiated";
+ throw new PortletInitializationException(msg, e);
+ }
+ catch (Error e)
+ {
+ String msg = "Cannot create " + type + " with class " + className + " because of an error";
+ throw new PortletInitializationException(msg, e);
+ }
+
+ //
+ final ClassLoader previousLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ //
+ start(instance);
+ }
+ catch (Exception e)
+ {
+ String msg = "The " + type + " threw an exception during init";
+ throw new PortletInitializationException(msg, e);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(previousLoader);
+ }
+
+ //
+ this.instance = instance;
+ }
+
+ public void destroy()
+ {
+ if (instance == null)
+ {
+ throw new IllegalStateException("No instance created previously");
+ }
+
+ //
+ try
+ {
+ stop(instance);
+ }
+ catch (Error e)
+ {
+ log.error("Stopping the " + type + " threw an error", e);
+ }
+ catch (Exception e)
+ {
+ log.error("Stopping the " + type + " threw an exception", e);
+ }
+ }
+
+ public T getInstance()
+ {
+ return instance;
+ }
+
+ protected void start(T instance) throws Exception
+ {
+
+ }
+
+ protected void stop(T instance)
+ {
+
+ }
+
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-02 14:21:03 UTC (rev 9713)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-02 18:26:59 UTC (rev 9714)
@@ -24,25 +24,36 @@
import org.jboss.portal.portlet.impl.jsr168.api.PortletContextImpl;
import org.jboss.portal.portlet.impl.jsr168.api.PortletURLGenerationListenerChain;
+import org.jboss.portal.portlet.impl.jsr168.api.FilterConfigImpl;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.impl.info.ContainerPortletApplicationInfo;
import org.jboss.portal.portlet.impl.info.ContainerListenerInfo;
+import org.jboss.portal.portlet.impl.info.ContainerFilterInfo;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletApplicationContext;
import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.container.PortletInitializationException;
+import org.jboss.portal.portlet.LifeCyclePhase;
import org.apache.log4j.Logger;
import javax.portlet.PortletContext;
import javax.portlet.PortletURLGenerationListener;
+import javax.portlet.filter.PortletFilter;
+import javax.portlet.filter.ActionFilter;
+import javax.portlet.filter.EventFilter;
+import javax.portlet.filter.RenderFilter;
+import javax.portlet.filter.ResourceFilter;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
import java.util.List;
import java.util.LinkedList;
import java.util.Collections;
-import java.lang.reflect.Constructor;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -51,6 +62,17 @@
public class PortletApplicationImpl implements PortletApplication
{
+ private static final EnumMap<LifeCyclePhase, Class<? extends PortletFilter>> phaseToType =
+ new EnumMap<LifeCyclePhase, Class<? extends PortletFilter>>(LifeCyclePhase.class);
+
+ static
+ {
+ phaseToType.put(LifeCyclePhase.ACTION, ActionFilter.class);
+ phaseToType.put(LifeCyclePhase.EVENT, EventFilter.class);
+ phaseToType.put(LifeCyclePhase.RENDER, RenderFilter.class);
+ phaseToType.put(LifeCyclePhase.RESOURCE, ResourceFilter.class);
+ }
+
/** Logger. */
protected final Logger log;
@@ -81,14 +103,11 @@
/** . */
protected PortletURLGenerationListener urlListener;
+ /** . */
+ protected Map<FilterKey, FilterLifecycle> filters;
+
/**
* Todo remove meta data reference and use info instead.
- *
- * @param info
- * @param metaData
- * @param jbossMetaData
- * @param context
- * @param portletAPIFactory
*/
public PortletApplicationImpl(
ContainerPortletApplicationInfo info,
@@ -145,63 +164,94 @@
public void start() throws Exception
{
+ PortletContextImpl portletContext = new PortletContextImpl(context.getServletContext());
+
+ //
+ //
List<PortletURLGenerationListener> listeners = Collections.emptyList();
for (ContainerListenerInfo listenerInfo : info.getListeners())
{
- String className = listenerInfo.getClassName();
- ClassLoader classLoader = context.getClassLoader();
try
{
- Class clazz = classLoader.loadClass(className);
- if (PortletURLGenerationListener.class.isAssignableFrom(clazz))
+ String className = listenerInfo.getClassName();
+
+ ClassInstanceLifeCycle<PortletURLGenerationListener> lifeCycle = new ClassInstanceLifeCycle<PortletURLGenerationListener>(
+ log,
+ PortletURLGenerationListener.class,
+ context.getClassLoader(),
+ className,
+ "listener"
+ );
+
+ //
+ lifeCycle.create();
+
+ //
+ if (listeners.size() == 0)
{
- Constructor ctor = clazz.getConstructor();
- PortletURLGenerationListener listener = (PortletURLGenerationListener)ctor.newInstance();
- if (listeners.size() == 0)
- {
- listeners = new LinkedList<PortletURLGenerationListener>();
- }
- listeners.add(listener);
+ listeners = new LinkedList<PortletURLGenerationListener>();
}
- else
- {
- log.info("Cannot create filter with class " + className + " because it does not implement the PortletURLGenerationListener interface");
- }
+
+ //
+ listeners.add(lifeCycle.getInstance());
}
- catch (IllegalAccessException e)
+ catch (PortletInitializationException e)
{
- log.error("Cannot create filter with class " + className + " because the class is not accessible", e);
+ log.error(e.getMessage(), e);
}
- catch (NoSuchMethodException e)
+ }
+
+ //
+ HashMap<FilterKey, FilterLifecycle> filters = new HashMap<FilterKey, FilterLifecycle>();
+ for (ContainerFilterInfo filterInfo : info.getFilters().values())
+ {
+ try
{
- log.error("Cannot create filter with class " + className + " because it does not have an no argument constructor", e);
+ String className = filterInfo.getClassName();
+ FilterLifecycle lifeCycle = new FilterLifecycle(
+ PortletFilter.class,
+ context.getClassLoader(),
+ className,
+ "filter",
+ filterInfo.getName());
+
+ //
+ lifeCycle.create();
+
+ //
+ for (LifeCyclePhase phase : filterInfo.getLifeCycles())
+ {
+ Class<? extends PortletFilter> type = phaseToType.get(phase);
+ FilterKey key = new FilterKey(filterInfo.getName(), type);
+ filters.put(key, lifeCycle);
+ }
}
- catch (ClassNotFoundException e)
+ catch (PortletInitializationException e)
{
- log.error("Cannot create filter with class " + className + " because the class cannot be loaded", e);
+ log.error(e.getMessage(), e);
}
- catch (InstantiationException e)
- {
- log.error("Cannot create filter with class " + className + " because it cannot be instantiated", e);
- }
- catch (Error e)
- {
- log.error("Cannot create filter with class " + className + " because of an error", e);
- }
}
//
this.version = metaData.getVersion();
- this.portletContext = new PortletContextImpl(context.getServletContext());
+ this.portletContext = portletContext;
this.urlListener = listeners.size() == 0 ? null : new PortletURLGenerationListenerChain(Collections.unmodifiableList(listeners));
-
+ this.filters = filters;
}
public void stop()
{
+ // Stop filters
+ for (FilterLifecycle filter : filters.values())
+ {
+ filter.destroy();
+ }
+
+ //
this.version = null;
this.portletContext = null;
this.urlListener = null;
+ this.filters = null;
}
public String getVersion()
@@ -225,6 +275,20 @@
return null;
}
+ public <T extends PortletFilter> T getFilter(String filterName, Class<T> phase)
+ {
+ FilterLifecycle lifeCycle = filters.get(new FilterKey(filterName, phase));
+
+ //
+ if (lifeCycle == null)
+ {
+ return null;
+ }
+
+ // Should be ok
+ return phase.cast(lifeCycle.getInstance());
+ }
+
// WebApp implementation ********************************************************************************************
public Set<PortletContainer> getPortletContainers()
@@ -248,4 +312,73 @@
{
return "PortletWebApp[" + metaData.getId() + "]";
}
+
+ private static class FilterKey
+ {
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final Class<? extends PortletFilter> phase;
+
+ private FilterKey(String name, Class<? extends PortletFilter> phase)
+ {
+ this.name = name;
+ this.phase = phase;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode() + name.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof FilterKey)
+ {
+ FilterKey that = (FilterKey)obj;
+ return name.equals(that.name) && phase == that.phase;
+ }
+ return false;
+ }
+ }
+
+ private class FilterLifecycle extends ClassInstanceLifeCycle<PortletFilter>
+ {
+
+ /** . */
+ private final String filterName;
+
+ private FilterLifecycle(
+ Class<PortletFilter> expectedClass,
+ ClassLoader classLoader,
+ String className,
+ String type,
+ String filterName)
+ {
+ super(log, expectedClass, classLoader, className, type);
+
+ //
+ this.filterName = filterName;
+ }
+
+ public void start(PortletFilter instance) throws Exception
+ {
+ FilterConfigImpl config = new FilterConfigImpl(filterName, portletContext);
+
+ //
+ instance.init(config);
+ }
+
+ public void stop(PortletFilter instance)
+ {
+ instance.destroy();
+ }
+ }
+
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-02-02 14:21:03 UTC (rev 9713)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-02-02 18:26:59 UTC (rev 9714)
@@ -39,6 +39,7 @@
import org.jboss.portal.portlet.impl.jsr168.api.EventResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.ResourceRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.ResourceResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.FilterChainImpl;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
@@ -61,9 +62,27 @@
import javax.portlet.UnavailableException;
import javax.portlet.EventPortlet;
import javax.portlet.ResourceServingPortlet;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.filter.PortletFilter;
+import javax.portlet.filter.ActionFilter;
+import javax.portlet.filter.EventFilter;
+import javax.portlet.filter.RenderFilter;
+import javax.portlet.filter.ResourceFilter;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.filter.FilterConfig;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -99,6 +118,21 @@
/** User data constraint. */
protected Set userDataConstraints;
+ /** . */
+ private final Invoker invoker = new Invoker();
+
+ /** . */
+ private List<ActionFilter> actionFilterList;
+
+ /** . */
+ private List<EventFilter> eventFilterList;
+
+ /** . */
+ private List<RenderFilter> renderFilterList;
+
+ /** . */
+ private List<ResourceFilter> resourceFilterList;
+
/**
* The preference validator, this is not exposed as runtime meta data as it is only used by the JSR 168 portlet
* container implementation.
@@ -201,6 +235,9 @@
this.config = config;
this.started = true;
+ //
+ buildFilterChains();
+
// Let invocation flow in
valve.open();
}
@@ -230,6 +267,37 @@
}
}
+ private void buildFilterChains()
+ {
+ List<ActionFilter> actionFilterList = builderFilterList(ActionFilter.class);
+ List<EventFilter> eventFilterList = builderFilterList(EventFilter.class);
+ List<RenderFilter> renderFilterList = builderFilterList(RenderFilter.class);
+ List<ResourceFilter> resourceFilterList = builderFilterList(ResourceFilter.class);
+
+ // Add invoker
+ actionFilterList.add(invoker);
+ eventFilterList.add(invoker);
+ renderFilterList.add(invoker);
+ resourceFilterList.add(invoker);
+
+ //
+ this.actionFilterList = Collections.unmodifiableList(actionFilterList);
+ this.eventFilterList = Collections.unmodifiableList(eventFilterList);
+ this.renderFilterList = Collections.unmodifiableList(renderFilterList);
+ this.resourceFilterList = Collections.unmodifiableList(resourceFilterList);
+ }
+
+ private <T extends PortletFilter> List<T> builderFilterList(Class<T> type)
+ {
+ ArrayList<T> list = new ArrayList<T>();
+ for (String filterRef : info.getFilterRefs())
+ {
+ T filter = application.getFilter(filterRef, type);
+ list.add(filter);
+ }
+ return list;
+ }
+
public void stop()
{
// if the portlet is not started, we shouldn't be trying to stop it...
@@ -419,7 +487,10 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE, "ACTION_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
- portlet.processAction(req, resp);
+
+ //
+ FilterChainImpl<ActionFilter> chain = new FilterChainImpl<ActionFilter>(actionFilterList, ActionFilter.class);
+ chain.doFilter(req, resp);
}
finally
{
@@ -446,7 +517,10 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE, "RENDER_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
- portlet.render(req, resp);
+
+ //
+ FilterChainImpl<RenderFilter> chain = new FilterChainImpl<RenderFilter>(renderFilterList, RenderFilter.class);
+ chain.doFilter(req, resp);
}
finally
{
@@ -466,17 +540,20 @@
//
PortletAPIFactory factory = application.getPortletAPIFactory();
- EventRequestImpl ereq = factory.createEventRequest(invocation);
- EventResponseImpl eresp = factory.createEventResponse(invocation, ereq);
+ EventRequestImpl req = factory.createEventRequest(invocation);
+ EventResponseImpl resp = factory.createEventResponse(invocation, req);
HttpServletRequest dreq = invocation.getDispatchedRequest();
try
{
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, ereq);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, eresp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE, "EVENT_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
- eventPortlet.processEvent(ereq, eresp);
+
+ //
+ FilterChainImpl<EventFilter> chain = new FilterChainImpl<EventFilter>(eventFilterList, EventFilter.class);
+ chain.doFilter(req, resp);
}
finally
{
@@ -486,7 +563,7 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
- return eresp.getResponse();
+ return resp.getResponse();
}
protected PortletInvocationResponse invokeResource(ResourceInvocation invocation) throws IOException, PortletException
@@ -506,7 +583,10 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE, "RESOURCE_SERVING_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
- eventPortlet.serveResource(req, resp);
+
+ //
+ FilterChainImpl<ResourceFilter> chain = new FilterChainImpl<ResourceFilter>(resourceFilterList, ResourceFilter.class);
+ chain.doFilter(req, resp);
}
finally
{
@@ -520,4 +600,39 @@
//
return resp.getResponse();
}
+
+ private class Invoker implements ActionFilter, EventFilter, RenderFilter, ResourceFilter
+ {
+
+ public void doFilter(ActionRequest req, ActionResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ portlet.processAction(req, resp);
+ }
+
+ public void doFilter(EventRequest req, EventResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ EventPortlet eventPortlet = (EventPortlet)portlet;
+ eventPortlet.processEvent(req, resp);
+ }
+
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ portlet.render(req, resp);
+ }
+
+ public void doFilter(ResourceRequest req, ResourceResponse resp, FilterChain chain) throws IOException, PortletException
+ {
+ ResourceServingPortlet servingPortlet = (ResourceServingPortlet)portlet;
+ servingPortlet.serveResource(req, resp);
+ }
+
+ public void init(FilterConfig filterConfig) throws PortletException
+ {
+ }
+
+ public void destroy()
+ {
+ }
+ }
+
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterChainImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterChainImpl.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterChainImpl.java 2008-02-02 18:26:59 UTC (rev 9714)
@@ -0,0 +1,165 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import javax.portlet.filter.PortletFilter;
+import javax.portlet.filter.ActionFilter;
+import javax.portlet.filter.ResourceFilter;
+import javax.portlet.filter.RenderFilter;
+import javax.portlet.filter.EventFilter;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class FilterChainImpl<T extends PortletFilter> implements FilterChain
+{
+
+ /** . */
+ private List<T> filters;
+
+ /** . */
+ private Class<T> phase;
+
+ /** . */
+ private int index;
+
+ public FilterChainImpl(List<T> filters, Class<T> phase)
+ {
+ this.filters = filters;
+ this.phase = phase;
+ this.index = 0;
+ }
+
+ public void doFilter(ActionRequest req, ActionResponse resp) throws IOException, PortletException
+ {
+ if (!ActionFilter.class.isAssignableFrom(phase))
+ {
+ throw new IllegalStateException();
+ }
+ if (index >= filters.size())
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ int currentIndex = index++;
+ try
+ {
+ PortletFilter filter = filters.get(currentIndex);
+ ActionFilter actionFilter = ActionFilter.class.cast(filter);
+ actionFilter.doFilter(req, resp, this);
+ }
+ finally
+ {
+ index--;
+ }
+ }
+
+ public void doFilter(EventRequest req, EventResponse resp) throws IOException, PortletException
+ {
+ if (!EventFilter.class.isAssignableFrom(phase))
+ {
+ throw new IllegalStateException();
+ }
+ if (index >= filters.size())
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ int currentIndex = index++;
+ try
+ {
+ PortletFilter filter = filters.get(currentIndex);
+ EventFilter eventFilter = EventFilter.class.cast(filter);
+ eventFilter.doFilter(req, resp, this);
+ }
+ finally
+ {
+ index--;
+ }
+ }
+
+ public void doFilter(RenderRequest req, RenderResponse resp) throws IOException, PortletException
+ {
+ if (!RenderFilter.class.isAssignableFrom(phase))
+ {
+ throw new IllegalStateException();
+ }
+ if (index >= filters.size())
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ int currentIndex = index++;
+ try
+ {
+ PortletFilter filter = filters.get(currentIndex);
+ RenderFilter renderFilter = RenderFilter.class.cast(filter);
+ renderFilter.doFilter(req, resp, this);
+ }
+ finally
+ {
+ index--;
+ }
+ }
+
+ public void doFilter(ResourceRequest req, ResourceResponse resp) throws IOException, PortletException
+ {
+ if (!ResourceFilter.class.isAssignableFrom(phase))
+ {
+ throw new IllegalStateException();
+ }
+ if (index >= filters.size())
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ int currentIndex = index++;
+ try
+ {
+ PortletFilter filter = filters.get(currentIndex);
+ ResourceFilter resourceFilter = ResourceFilter.class.cast(filter);
+ resourceFilter.doFilter(req, resp, this);
+ }
+ finally
+ {
+ index--;
+ }
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterConfigImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterConfigImpl.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/FilterConfigImpl.java 2008-02-02 18:26:59 UTC (rev 9714)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.common.NotYetImplemented;
+
+import javax.portlet.filter.FilterConfig;
+import javax.portlet.PortletContext;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class FilterConfigImpl implements FilterConfig
+{
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final PortletContext context;
+
+ public FilterConfigImpl(String name, PortletContext context)
+ {
+ this.name = name;
+ this.context = context;
+ }
+
+ public String getFilterName()
+ {
+ return name;
+ }
+
+ public PortletContext getPortletContext()
+ {
+ return context;
+ }
+
+ public String getInitParameter(String s)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public Enumeration getInitParameterNames()
+ {
+ throw new NotYetImplemented();
+ }
+}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-02 14:21:03 UTC (rev 9713)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-02 18:26:59 UTC (rev 9714)
@@ -16,7 +16,7 @@
<antcall target="tests.call.all"/>
<!--Cleanup-->
- <delete dir="${test.temp.dir}"/>
+ <!--<delete dir="${test.temp.dir}"/>-->
</target>
16 years, 3 months
JBoss Portal SVN: r9713 - modules/portlet/trunk/test/src/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-02 09:21:03 -0500 (Sat, 02 Feb 2008)
New Revision: 9713
Modified:
modules/portlet/trunk/test/src/test/build.xml
Log:
update build.xml to avoid to use the test/target/test-classes directory as it is used to build jar files
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-02 14:07:45 UTC (rev 9712)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-02 14:21:03 UTC (rev 9713)
@@ -256,20 +256,29 @@
<attribute name="testsuitetype"/>
<attribute name="testsuitename"/>
<sequential>
- <mkdir dir="${target}/test-classes/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war/WEB-INF/classes"/>
- <copy todir="${target}/test-classes/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war/WEB-INF/classes">
- <fileset dir="${test.temp.portlet}"
- includes="org/jboss/portal/test/portlet/@{testsuiteversion}/@{testsuitetype}/common/**"/>
- <fileset dir="${test.temp.portlet}"
- includes="org/jboss/portal/test/portlet/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}/**"/>
- <fileset dir="${test.temp.portlet}" includes="org/jboss/portal/test/portlet/framework/**"/>
+ <mkdir dir="${test.temp.dir}/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war/WEB-INF/classes"/>
+ <copy todir="${test.temp.dir}/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war/WEB-INF/classes">
+ <fileset
+ dir="${test.temp.portlet}"
+ includes="org/jboss/portal/test/portlet/@{testsuiteversion}/@{testsuitetype}/common/**"/>
+ <fileset
+ dir="${test.temp.portlet}"
+ includes="org/jboss/portal/test/portlet/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}/**"/>
+ <fileset
+ dir="${test.temp.portlet}"
+ includes="org/jboss/portal/test/portlet/framework/**"/>
</copy>
- <mkdir dir="${target}/test-classes/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war/WEB-INF/lib"/>
- <copy todir="${target}/test-classes/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war/WEB-INF/lib">
- <fileset dir="${test.temp.lib}" includes="portal-portlet-test-framework-lib.jar"/>
+ <copy todir="${test.temp.dir}/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war/WEB-INF/lib">
+ <fileset
+ dir="${test.temp.lib}"
+ includes="portal-portlet-test-framework-lib.jar"/>
</copy>
+ <copy todir="${test.temp.dir}/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war">
+ <fileset
+ dir="${target}/test-classes/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war"/>
+ </copy>
<jar jarfile="${test.temp.lib}/test-@{testsuiteversion}-@{testsuitetype}-(a){testsuitename}.war">
- <fileset dir="${target}/test-classes/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war"/>
+ <fileset dir="${test.temp.dir}/@{testsuiteversion}/@{testsuitetype}/@{testsuitename}-war"/>
</jar>
</sequential>
</macrodef>
@@ -280,6 +289,8 @@
<!--Portlet test framework lib jar-->
<jar jarfile="${test.temp.lib}/portal-portlet-test-framework-lib.jar">
+
+ <!-- -->
<fileset dir="${test.temp.portlet}" includes="org/jboss/portal/unit/**"/>
<!-- JSR 168 TLD -->
@@ -314,7 +325,6 @@
<package-tck-test test="portleturl"/>
<package-tck-test test="windowstates"/>
<package-tck-test test="portletcontext"/>
-
<package-api-test test="portletconfig"/>
<package-api-test test="portletmode"/>
<package-api-test test="windowstate"/>
@@ -328,7 +338,6 @@
<package-api-test test="renderrequest"/>
<package-api-test test="actionresponse"/>
<package-api-test test="renderresponse"/>
-
<package-ext-test test="nocache"/>
<package-ext-test test="expiringcache"/>
<package-ext-test test="neverexpiringcache"/>
@@ -339,9 +348,7 @@
<package-ext-test test="portletmode"/>
<package-ext-test test="portletconfig"/>
<package-ext-test test="taglib"/>
-
<package-misc-test test="log4j"/>
-
<package-jsr286-tck-test test="dispatcher"/>
<package-jsr286-tck-test test="portletconfig"/>
<package-jsr286-tck-test test="portletconfignonamespace"/>
@@ -351,13 +358,12 @@
<package-jsr286-tck-test test="portletrequests"/>
<package-jsr286-tck-test test="resourceserving"/>
<package-jsr286-tck-test test="portleturl"/>
-
<package-jsr286-api-test test="event"/>
-
<package-jsr286-ext-test test="portletrequests"/>
<package-jsr286-ext-test test="portletresponses"/>
<package-jsr286-ext-test test="dispatcher"/>
+ <!-- -->
<jar jarfile="${test.temp.lib}/portlet-test-lib.jar">
<fileset dir="${target}/test-classes"/>
<fileset dir="${target}/classes"/>
@@ -365,11 +371,16 @@
<!-- JBoss 4.2 portlet-test.war -->
- <copy todir="${target}/test-classes/jboss-4.2/portlet-test-war/WEB-INF/lib" flatten="true">
+ <copy todir="${test.temp.dir}/jboss-4.2/portlet-test-war">
+ <fileset dir="${target}/test-classes/portlet-test-war"/>
+ <fileset dir="${target}/test-classes/jboss-4.2/portlet-test-war"/>
+ </copy>
+ <copy todir="${test.temp.dir}/jboss-4.2/portlet-test-war/WEB-INF/lib" flatten="true">
<!-- -->
<fileset dir="${test.temp.lib}" includes="portlet-test-lib.jar"/>
+ <!-- -->
<path refid="mc.portal-common"/>
<!-- Remote plugin -->
@@ -392,16 +403,20 @@
</copy>
<mkdir dir="${test.temp.lib}/jboss-4.2"/>
<jar jarfile="${test.temp.lib}/jboss-4.2/portlet-test.war">
- <fileset dir="${target}/test-classes/jboss-4.2/portlet-test-war"/>
- <fileset dir="${target}/test-classes/portlet-test-war"/>
+ <fileset dir="${test.temp.dir}/jboss-4.2/portlet-test-war"/>
</jar>
<!-- Tomcat 6.0 portlet-test.war -->
- <copy todir="${target}/test-classes/tomcat-6.0/portlet-test-war/WEB-INF/lib" flatten="true">
+ <copy todir="${test.temp.dir}/tomcat-6.0/portlet-test-war">
+ <fileset dir="${target}/test-classes/portlet-test-war"/>
+ <fileset dir="${target}/test-classes/tomcat-6.0/portlet-test-war"/>
+ </copy>
+ <copy todir="${test.temp.dir}/tomcat-6.0/portlet-test-war/WEB-INF/lib" flatten="true">
<!-- -->
<fileset dir="${test.temp.lib}" includes="portlet-test-lib.jar"/>
+ <!-- -->
<path refid="mc.portal-common"/>
<!-- Remote plugin -->
@@ -423,8 +438,7 @@
</copy>
<mkdir dir="${test.temp.lib}/tomcat-6.0"/>
<jar jarfile="${test.temp.lib}/tomcat-6.0/portlet-test.war">
- <fileset dir="${target}/test-classes/tomcat-6.0/portlet-test-war"/>
- <fileset dir="${target}/test-classes/portlet-test-war"/>
+ <fileset dir="${test.temp.dir}/tomcat-6.0/portlet-test-war"/>
</jar>
<!-- Strip cargo manager war filename-->
@@ -647,7 +661,8 @@
<classpath>
<pathelement location="${target}/classes"/>
- <pathelement location="${target}/test-classes"/>
+ <pathelement location="${test.temp.lib}"/>
+ <!--<pathelement location="${target}/test-classes"/>-->
<pathelement location="${target}/test-classes/test"/>
<pathelement path="${test_classpath}"/>
</classpath>
@@ -664,7 +679,7 @@
</jar>
<!-- simple-portal.war -->
- <copy todir="${target}/test-classes/simple-portal-war/WEB-INF/lib" flatten="true">
+ <copy todir="${test.temp.dir}/simple-portal-war/WEB-INF/lib" flatten="true">
<!-- -->
<fileset dir="${target}" includes="portlet-test-lib.jar"/>
@@ -702,7 +717,7 @@
</copy>
<jar jarfile="${target}/simple-portal.war">
- <fileset dir="${target}/test-classes/simple-portal-war"/>
+ <fileset dir="${test.temp.dir}/simple-portal-war"/>
</jar>
<delete file="${target}/portlet-test-lib.jar"/>
16 years, 3 months
JBoss Portal SVN: r9712 - in modules/test/trunk: remote/src/main/java/org/jboss/unit/remote/driver/handler/http and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-02 09:07:45 -0500 (Sat, 02 Feb 2008)
New Revision: 9712
Modified:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/RemoteTestDriverClient.java
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/handler/http/HTTPConversation.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/deployment/Deployer.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/deployment/Deployment.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/opends/OpenDSService.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/opends/OpenDSUtil.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/agent/GenericTestAgent.java
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/runner/BaseRunner.java
Log:
update jboss unit to use jboss logging
Modified: modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/RemoteTestDriverClient.java
===================================================================
--- modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/RemoteTestDriverClient.java 2008-02-02 02:16:21 UTC (rev 9711)
+++ modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/RemoteTestDriverClient.java 2008-02-02 14:07:45 UTC (rev 9712)
@@ -44,6 +44,7 @@
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.info.TestInfo;
import org.jboss.unit.info.impl.SimpleTestInfo;
+import org.jboss.logging.Logger;
import java.net.URL;
@@ -54,6 +55,9 @@
public class RemoteTestDriverClient extends BasicBootstrap implements TestDriver
{
+ /** . */
+ private static Logger log = org.jboss.logging.Logger.getLogger(RemoteTestDriverClient.class);
+
// Config
/** Need to make initial node id configurable somehow. */
@@ -152,11 +156,18 @@
this.serverName = context.getProperty("serverName");
//
+ log.debug("Initializing remote test driving client");
+ log.debug("Archive path = " + archivePath);
+ log.debug("Server name = " + serverName);
+
+ //
+ log.debug("Booting kernel");
run();
// Install our self first
try
{
+ log.debug("Installing TestDriver bean");
AbstractBeanMetaData bmd = new AbstractBeanMetaData("TestDriver", getClass().getName());
AbstractConstructorMetaData cmd = new AbstractConstructorMetaData();
bmd.setConstructor(cmd);
@@ -168,13 +179,21 @@
}
catch (Throwable throwable)
{
- throw new DriverException("Could not start the kernel", throwable);
+ throw new DriverException("Could not install the TestDriver bean", throwable);
}
// Now deploy beans
try
{
- URL url = getClass().getResource("/org/jboss/unit/remote/driver/jboss-beans.xml");
+ String location = "/org/jboss/unit/remote/driver/jboss-beans.xml";
+ URL url = getClass().getResource(location);
+ if (url == null)
+ {
+ log.debug("The file jboss-beans.xml supposed to be located under " + location + " could not be found");
+ }
+
+ //
+ log.debug("Now deploying the beans with url " + url);
beanDeployer = new BeanXMLDeployer(getKernel());
deployment = beanDeployer.deploy(url);
beanDeployer.validate();
@@ -183,9 +202,14 @@
String archiveId = context.getProperty("archiveId");
if (archiveId != null)
{
+ log.debug("Going to deploy " + archiveId);
Node node = nodeManager.getNode(NodeId.DEFAULT);
deployer.deploy(archivePath, archiveId, node);
}
+ else
+ {
+ log.debug("No archive id was provided");
+ }
}
catch (Throwable throwable)
{
Modified: modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/handler/http/HTTPConversation.java
===================================================================
--- modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/handler/http/HTTPConversation.java 2008-02-02 02:16:21 UTC (rev 9711)
+++ modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/handler/http/HTTPConversation.java 2008-02-02 14:07:45 UTC (rev 9712)
@@ -34,7 +34,7 @@
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.apache.log4j.Logger;
+import org.jboss.logging.Logger;
import org.jboss.unit.remote.http.HttpRequest;
import org.jboss.unit.remote.http.HttpHeaders;
import org.jboss.unit.remote.http.HttpHeader;
@@ -67,7 +67,7 @@
{
/** . */
- private final Logger log = Logger.getLogger(getClass());
+ private final org.jboss.logging.Logger log = Logger.getLogger(getClass());
/** . */
private final HttpClient client;
Modified: modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/deployment/Deployer.java
===================================================================
--- modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/deployment/Deployer.java 2008-02-02 02:16:21 UTC (rev 9711)
+++ modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/deployment/Deployer.java 2008-02-02 14:07:45 UTC (rev 9712)
@@ -41,6 +41,9 @@
{
/** . */
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(Deployer.class);
+
+ /** . */
private Map<URL,Deployment> deployments;
public void create()
@@ -85,7 +88,16 @@
public void deploy(File parent, String childName, Node[] nodes) throws Exception
{
- deploy(new File(parent, childName).toURL(), nodes);
+ File file = new File(parent, childName);
+ if (!file.exists())
+ {
+ String msg = "Cannot deploy inexisting file " + file.getAbsolutePath();
+ log.error(msg);
+ throw new IllegalArgumentException(msg);
+ }
+
+ //
+ deploy(file.toURL(), nodes);
}
public void deploy(String url, Node node) throws Exception
Modified: modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/deployment/Deployment.java
===================================================================
--- modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/deployment/Deployment.java 2008-02-02 02:16:21 UTC (rev 9711)
+++ modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/deployment/Deployment.java 2008-02-02 14:07:45 UTC (rev 9712)
@@ -23,7 +23,7 @@
package org.jboss.portal.test.framework.deployment;
-import org.apache.log4j.Logger;
+import org.jboss.logging.Logger;
import org.jboss.portal.test.framework.agent.TestAgent;
import org.jboss.portal.test.framework.server.Node;
Modified: modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java
===================================================================
--- modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java 2008-02-02 02:16:21 UTC (rev 9711)
+++ modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/HibernateSupport.java 2008-02-02 14:07:45 UTC (rev 9712)
@@ -35,7 +35,7 @@
import org.jboss.portal.common.io.IOTools;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
-import org.apache.log4j.Logger;
+import org.jboss.logging.Logger;
import javax.transaction.Synchronization;
import java.util.Collection;
@@ -115,11 +115,11 @@
//
if (jndiName == null)
{
- log = Logger.getLogger(HibernateSupport.class);
+ log = org.jboss.logging.Logger.getLogger(HibernateSupport.class);
}
else
{
- log = Logger.getLogger(jndiName);
+ log = org.jboss.logging.Logger.getLogger(jndiName);
}
}
Modified: modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/opends/OpenDSService.java
===================================================================
--- modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/opends/OpenDSService.java 2008-02-02 02:16:21 UTC (rev 9711)
+++ modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/opends/OpenDSService.java 2008-02-02 14:07:45 UTC (rev 9712)
@@ -24,7 +24,6 @@
package org.jboss.portal.test.framework.embedded.opends;
import org.opends.server.core.DirectoryServer;
-import org.apache.log4j.Logger;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -44,7 +43,7 @@
public class OpenDSService implements OpenDSServiceMBean
{
- private static final Logger log = Logger.getLogger(OpenDSService.class);
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(OpenDSService.class);
public static String objectName = "portal.test:service=OpenDSService";
Modified: modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/opends/OpenDSUtil.java
===================================================================
--- modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/opends/OpenDSUtil.java 2008-02-02 02:16:21 UTC (rev 9711)
+++ modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/embedded/opends/OpenDSUtil.java 2008-02-02 14:07:45 UTC (rev 9712)
@@ -27,7 +27,6 @@
import org.opends.server.tools.LDAPDelete;
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.LDAPSearch;
-import org.apache.log4j.Logger;
import java.net.URL;
import java.io.File;
@@ -44,7 +43,7 @@
*/
public class OpenDSUtil
{
- private static final Logger log = Logger.getLogger(OpenDSUtil.class);
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(OpenDSUtil.class);
public OpenDSUtil()
{
Modified: modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/agent/GenericTestAgent.java
===================================================================
--- modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/agent/GenericTestAgent.java 2008-02-02 02:16:21 UTC (rev 9711)
+++ modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/agent/GenericTestAgent.java 2008-02-02 14:07:45 UTC (rev 9712)
@@ -33,6 +33,7 @@
import org.codehaus.cargo.container.configuration.Configuration;
import org.codehaus.cargo.container.property.RemotePropertySet;
import org.codehaus.cargo.container.Container;
+import org.jboss.logging.Logger;
import java.net.URL;
import java.net.URISyntaxException;
@@ -46,6 +47,9 @@
{
/** . */
+ private static Logger log = org.jboss.logging.Logger.getLogger(GenericTestAgent.class);
+
+ /** . */
private Deployer cargoDeployer;
/** . */
@@ -115,13 +119,17 @@
public void deploy(URL url) throws Exception
{
Deployable deployable = createDeployable(url);
+ log.debug("Going to deploy " + url);
cargoDeployer.deploy(deployable);
+ log.debug("Deployed " + url);
}
public void undeploy(URL url) throws Exception
{
Deployable deployable = createDeployable(url);
+ log.debug("Going to undeploy " + url);
cargoDeployer.undeploy(deployable);
+ log.debug("Undeployed " + url);
}
private Deployable createDeployable(URL url) throws URISyntaxException, IllegalArgumentException
Modified: modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/runner/BaseRunner.java
===================================================================
--- modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/runner/BaseRunner.java 2008-02-02 02:16:21 UTC (rev 9711)
+++ modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/runner/BaseRunner.java 2008-02-02 14:07:45 UTC (rev 9712)
@@ -26,7 +26,6 @@
import org.jboss.portal.test.framework.server.NodeManager;
import org.jboss.portal.test.framework.server.NodeId;
import org.jboss.portal.test.framework.mc.TestRuntimeContext;
-import org.apache.log4j.Logger;
import org.apache.log4j.Appender;
import org.apache.log4j.SimpleLayout;
import org.apache.log4j.Level;
@@ -47,8 +46,8 @@
static
{
Appender appender = new ConsoleAppender(new SimpleLayout());
- Logger.getRoot().addAppender(appender);
- Logger.getRoot().setLevel(Level.INFO);
+ org.jboss.logging.Logger.getRoot().addAppender(appender);
+ org.jboss.logging.Logger.getRoot().setLevel(Level.INFO);
}
/** . */
16 years, 3 months
JBoss Portal SVN: r9711 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-01 21:16:21 -0500 (Fri, 01 Feb 2008)
New Revision: 9711
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/ListenedURLUpdateTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceURLParametersTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml
Log:
- added a test case for resource url parameters
- added test case for url listener to test modifications done during listening
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/ListenedURLUpdateTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/ListenedURLUpdateTestCase.java 2008-02-02 02:00:40 UTC (rev 9710)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/ListenedURLUpdateTestCase.java 2008-02-02 02:16:21 UTC (rev 9711)
@@ -72,8 +72,8 @@
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
- URLGenerationListener1.delegate = updater;
- URLGenerationListener2.delegate = null;
+ URLGenerationListener1.delegate = updater1;
+ URLGenerationListener2.delegate = updater2;
//
PortletURL actionURL = response.createActionURL();
@@ -143,7 +143,7 @@
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
- assertParameterMap(Collections.singletonMap("foo", new String[]{"fooResource"}), request);
+ assertParameterMap(Collections.singletonMap("foo", new String[]{"fooResource","fooRender"}), request);
assertEquals("foo_resource_id", request.getResourceID());
assertEquals(ResourceURL.PORTLET, request.getCacheability());
@@ -153,43 +153,32 @@
});
}
- private static final PortletURLGenerationListener updater = new PortletURLGenerationListener()
+ private static final PortletURLGenerationListener updater1 = new PortletURLGenerationListener()
{
-
-
-
public void filterActionURL(PortletURL portletURL)
{
try
{
portletURL.setPortletMode(PortletMode.EDIT);
- portletURL.setWindowState(WindowState.MAXIMIZED);
- portletURL.setParameter("foo", "fooAction");
}
catch (Exception e)
{
}
}
-
public void filterRenderURL(PortletURL portletURL)
{
try
{
portletURL.setPortletMode(PortletMode.VIEW);
- portletURL.setWindowState(WindowState.NORMAL);
- portletURL.setParameter("foo", "fooRender");
}
catch (Exception e)
{
}
}
-
public void filterResourceURL(ResourceURL resourceURL)
{
try
{
- resourceURL.setParameter("foo", "fooResource");
- resourceURL.setResourceID("foo_resource_id");
resourceURL.setCacheability(ResourceURL.PORTLET);
}
catch (Exception e)
@@ -198,5 +187,50 @@
}
};
+ private static final PortletURLGenerationListener updater2 = new PortletURLGenerationListener()
+ {
+ public void filterActionURL(PortletURL portletURL)
+ {
+ try
+ {
+ if (portletURL.getPortletMode() == PortletMode.EDIT)
+ {
+ portletURL.setWindowState(WindowState.MAXIMIZED);
+ portletURL.setParameter("foo", "fooAction");
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ public void filterRenderURL(PortletURL portletURL)
+ {
+ try
+ {
+ if (portletURL.getPortletMode() == PortletMode.VIEW)
+ {
+ portletURL.setWindowState(WindowState.NORMAL);
+ portletURL.setParameter("foo", "fooRender");
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ public void filterResourceURL(ResourceURL resourceURL)
+ {
+ try
+ {
+ if (ResourceURL.PORTLET.equals(resourceURL.getCacheability()))
+ {
+ resourceURL.setParameter("foo", "fooResource");
+ resourceURL.setResourceID("foo_resource_id");
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ };
}
\ No newline at end of file
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceURLParametersTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceURLParametersTestCase.java 2008-02-02 02:00:40 UTC (rev 9710)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceURLParametersTestCase.java 2008-02-02 02:16:21 UTC (rev 9711)
@@ -65,7 +65,7 @@
ResourceURL url = response.createResourceURL();
//
- url.setParameter("foo", new String[]{"foo_resource"});
+ url.setParameter("resource", new String[]{"resource_value"});
//
return new InvokeGetResponse(url.toString());
@@ -75,7 +75,7 @@
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
- Map<String, String[]> expectedParameters = Collections.singletonMap("foo", new String[]{"foo_resource"});
+ Map<String, String[]> expectedParameters = Collections.singletonMap("resource", new String[]{"resource_value"});
assertParameterMap(expectedParameters, request);
assertParameterMap(expectedParameters, request.getPrivateParameterMap());
assertParameterMap(new HashMap<String, String[]>(), request.getPrivateRenderParameterMap());
@@ -85,15 +85,15 @@
ResourceURL url = response.createResourceURL();
//
- url.setParameter("foo", new String[]{"foo_resource"});
- url.setParameter("bar", new String[]{"bar_resource"});
+ url.setParameter("resource", new String[]{"resource_value"});
+ url.setParameter("resource_form", new String[]{"resource_form_value1"});
//
InvokePostResponse post = new InvokePostResponse(url.toString());
post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
HttpRequest.Form form = new HttpRequest.Form();
- form.addParameter("bar", new String[]{"bar_form"});
- form.addParameter("juu", new String[]{"juu_form"});
+ form.addParameter("form", new String[]{"form_value"});
+ form.addParameter("resource_form", new String[]{"resource_form_value2"});
post.setBody(form);
//
@@ -105,9 +105,9 @@
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
- expectedParameters.put("foo", new String[]{"foo_resource"});
- expectedParameters.put("bar", new String[]{"bar_resource", "bar_form"});
- expectedParameters.put("juu", new String[]{"juu_form"});
+ expectedParameters.put("resource", new String[]{"resource_value"});
+ expectedParameters.put("resource_form", new String[]{"resource_form_value1", "resource_form_value2"});
+ expectedParameters.put("form", new String[]{"form_value"});
assertParameterMap(expectedParameters, request);
assertParameterMap(expectedParameters, request.getPrivateParameterMap());
assertParameterMap(new HashMap<String, String[]>(), request.getPrivateRenderParameterMap());
@@ -115,9 +115,10 @@
//
PortletURL renderURL = response.createRenderURL();
- renderURL.setParameter("daa", "daa_render");
- renderURL.setParameter("wee", "wee_render");
- renderURL.setParameter("zii", "zii_render");
+ renderURL.setParameter("render", "render_value");
+ renderURL.setParameter("resource_render", "resource_render_value2");
+ renderURL.setParameter("form_render", "form_render_value2");
+ renderURL.setParameter("resource_form_render", "resource_form_render_value3");
//
return new InvokeGetResponse(renderURL.toString());
@@ -130,8 +131,8 @@
ResourceURL url = response.createResourceURL();
//
- url.setParameter("foo", new String[]{"foo_resource"});
- url.setParameter("daa", new String[]{"daa_resource"});
+ url.setParameter("resource", new String[]{"resource_value"});
+ url.setParameter("resource_render", new String[]{"resource_render_value1"});
//
return new InvokeGetResponse(url.toString());
@@ -141,74 +142,158 @@
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
- Map<String, String[]> expectedPrivateParameters = new HashMap<String, String[]>();
- expectedPrivateParameters.put("foo", new String[]{"foo_resource"});
- expectedPrivateParameters.put("daa", new String[]{"daa_resource"});
Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
- expectedParameters.put("foo", new String[]{"foo_resource"});
- expectedParameters.put("daa", new String[]{"daa_resource","daa_render"});
- expectedParameters.put("wee", new String[]{"wee_render"});
- expectedParameters.put("zii", new String[]{"zii_render"});
+ expectedParameters.put("resource", new String[]{"resource_value"});
+ expectedParameters.put("resource_render", new String[]{"resource_render_value1","resource_render_value2"});
+ expectedParameters.put("render", new String[]{"render_value"});
+ expectedParameters.put("form_render", new String[]{"form_render_value2"});
+ expectedParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
Map<String, String[]> expectedPrivateRenderParameters = new HashMap<String, String[]>();
- expectedPrivateRenderParameters.put("daa", new String[]{"daa_render"});
- expectedPrivateRenderParameters.put("wee", new String[]{"wee_render"});
- expectedPrivateRenderParameters.put("zii", new String[]{"zii_render"});
+ expectedPrivateRenderParameters.put("render", new String[]{"render_value"});
+ expectedPrivateRenderParameters.put("resource_render", new String[]{"resource_render_value2"});
+ expectedPrivateRenderParameters.put("form_render", new String[]{"form_render_value2"});
+ expectedPrivateRenderParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
assertParameterMap(expectedParameters, request);
-// assertParameterMap(expectedPrivateParameters, request.getPrivateParameterMap());
-// assertParameterMap(expectedPrivateRenderParameters, request.getPrivateRenderParameterMap());
-// assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
+ assertParameterMap(expectedParameters, request.getPrivateParameterMap());
+ assertParameterMap(expectedPrivateRenderParameters, request.getPrivateRenderParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
//
- return new EndTestResponse();
+ ResourceURL url = response.createResourceURL();
+
+ //
+ url.setParameter("resource", new String[]{"resource_value"});
+ url.setParameter("resource_form", new String[]{"resource_form_value1"});
+ url.setParameter("resource_render", new String[]{"resource_render_value1"});
+ url.setParameter("resource_form_render", new String[]{"resource_form_render_value1"});
+
+ //
+ InvokePostResponse post = new InvokePostResponse(url.toString());
+ post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
+ HttpRequest.Form form = new HttpRequest.Form();
+ form.addParameter("form", new String[]{"form_value"});
+ form.addParameter("resource_form", new String[]{"resource_form_value2"});
+ form.addParameter("form_render", new String[]{"form_render_value1"});
+ form.addParameter("resource_form_render", new String[]{"resource_form_render_value2"});
+ post.setBody(form);
+
+ //
+ return post;
}
});
+ seq.bindAction(5, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
+ expectedParameters.put("resource", new String[]{"resource_value"});
+ expectedParameters.put("resource_form", new String[]{"resource_form_value1","resource_form_value2"});
+ expectedParameters.put("resource_render", new String[]{"resource_render_value1","resource_render_value2"});
+ expectedParameters.put("resource_form_render", new String[]{"resource_form_render_value1","resource_form_render_value2","resource_form_render_value3"});
+ expectedParameters.put("form", new String[]{"form_value"});
+ expectedParameters.put("form_render", new String[]{"form_render_value1","form_render_value2"});
+ expectedParameters.put("render", new String[]{"render_value"});
+ Map<String, String[]> expectedPrivateRenderParameters = new HashMap<String, String[]>();
+ expectedPrivateRenderParameters.put("render", new String[]{"render_value"});
+ expectedPrivateRenderParameters.put("resource_render", new String[]{"resource_render_value2"});
+ expectedPrivateRenderParameters.put("form_render", new String[]{"form_render_value2"});
+ expectedPrivateRenderParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
+ assertParameterMap(expectedParameters, request);
+ assertParameterMap(expectedParameters, request.getPrivateParameterMap());
+ assertParameterMap(expectedPrivateRenderParameters, request.getPrivateRenderParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
+ //
+ PortletURL renderURL = response.createRenderURL();
+ renderURL.setParameter("render", "render_value");
+ renderURL.setParameter("resource_render", "resource_render_value2");
+ renderURL.setParameter("form_render", "form_render_value2");
+ renderURL.setParameter("resource_form_render", "resource_form_render_value3");
+ renderURL.setParameter("public", "public_value");
+ renderURL.setParameter("resource_public", "resource_public_value2");
+ renderURL.setParameter("form_public", "form_public_value2");
+ renderURL.setParameter("resource_form_public", "resource_form_public_value3");
+ //
+ return new InvokeGetResponse(renderURL.toString());
+ }
+ });
+ seq.bindAction(6, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ //
+ ResourceURL url = response.createResourceURL();
+ //
+ url.setParameter("resource", new String[]{"resource_value"});
+ url.setParameter("resource_form", new String[]{"resource_form_value1"});
+ url.setParameter("resource_render", new String[]{"resource_render_value1"});
+ url.setParameter("resource_form_render", new String[]{"resource_form_render_value1"});
+ url.setParameter("resource_public", new String[]{"resource_public_value1"});
+ url.setParameter("resource_form_public", new String[]{"resource_form_public_value1"});
+ //
+ InvokePostResponse post = new InvokePostResponse(url.toString());
+ post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
+ HttpRequest.Form form = new HttpRequest.Form();
+ form.addParameter("form", new String[]{"form_value"});
+ form.addParameter("resource_form", new String[]{"resource_form_value2"});
+ form.addParameter("form_render", new String[]{"form_render_value1"});
+ form.addParameter("resource_form_render", new String[]{"resource_form_render_value2"});
+ form.addParameter("form_public", new String[]{"form_public_value1"});
+ form.addParameter("resource_form_public", new String[]{"resource_form_public_value2"});
+ post.setBody(form);
+ //
+ return post;
+ }
+ });
+ seq.bindAction(7, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
+ expectedParameters.put("resource", new String[]{"resource_value"});
+ expectedParameters.put("form", new String[]{"form_value"});
+ expectedParameters.put("resource_form", new String[]{"resource_form_value1","resource_form_value2"});
+ expectedParameters.put("resource_render", new String[]{"resource_render_value1","resource_render_value2"});
+ expectedParameters.put("resource_form_render", new String[]{"resource_form_render_value1","resource_form_render_value2","resource_form_render_value3"});
+ expectedParameters.put("form_render", new String[]{"form_render_value1","form_render_value2"});
+ expectedParameters.put("render", new String[]{"render_value"});
+ expectedParameters.put("resource_public", new String[]{"resource_public_value1","resource_public_value2"});
+ expectedParameters.put("resource_form_public", new String[]{"resource_form_public_value1","resource_form_public_value2","resource_form_public_value3"});
+ expectedParameters.put("form_public", new String[]{"form_public_value1","form_public_value2"});
+ expectedParameters.put("public", new String[]{"public_value"});
+ Map<String, String[]> expectedPrivateRenderParameters = new HashMap<String, String[]>();
+ expectedPrivateRenderParameters.put("resource_render", new String[]{"resource_render_value2"});
+ expectedPrivateRenderParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
+ expectedPrivateRenderParameters.put("form_render", new String[]{"form_render_value2"});
+ expectedPrivateRenderParameters.put("render", new String[]{"render_value"});
+ Map<String, String[]> expectedPrivateParameters = new HashMap<String, String[]>();
+ expectedPrivateParameters.put("resource", new String[]{"resource_value"});
+ expectedPrivateParameters.put("form", new String[]{"form_value"});
+ expectedPrivateParameters.put("resource_form", new String[]{"resource_form_value1","resource_form_value2"});
+ expectedPrivateParameters.put("resource_render", new String[]{"resource_render_value1","resource_render_value2"});
+ expectedPrivateParameters.put("resource_form_render", new String[]{"resource_form_render_value1","resource_form_render_value2","resource_form_render_value3"});
+ expectedPrivateParameters.put("form_render", new String[]{"form_render_value1","form_render_value2"});
+ expectedPrivateParameters.put("render", new String[]{"render_value"});
+ expectedPrivateParameters.put("resource_public", new String[]{"resource_public_value1"});
+ expectedPrivateParameters.put("resource_form_public", new String[]{"resource_form_public_value1","resource_form_public_value2"});
+ expectedPrivateParameters.put("form_public", new String[]{"form_public_value1"});
+ Map<String, String[]> expectedPublicParameters = new HashMap<String, String[]>();
+ expectedPublicParameters.put("resource_public", new String[]{"resource_public_value2"});
+ expectedPublicParameters.put("resource_form_public", new String[]{"resource_form_public_value3"});
+ expectedPublicParameters.put("form_public", new String[]{"form_public_value2"});
+ expectedPublicParameters.put("public", new String[]{"public_value"});
+ assertParameterMap(expectedParameters, request);
+ assertParameterMap(expectedPrivateParameters, request.getPrivateParameterMap());
+ assertParameterMap(expectedPrivateRenderParameters, request.getPrivateRenderParameterMap());
+ assertParameterMap(expectedPublicParameters, request.getPublicParameterMap());
-// seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
-// {
-// PortletURL url = response.createRenderURL();
-//
-// //
-// url.setParameter("bar", new String[]{"bar_render"});
-// url.setParameter("juu", new String[]{"juu_render"});
-//
-// //
-// return new InvokeGetResponse(url.toString());
-// }
-// });
-// seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
-// {
-// ResourceURL url = response.createResourceURL();
-//
-// //
-// url.setParameter("foo", new String[]{"foo_resource"});
-// url.setParameter("bar", new String[]{"bar_resource"});
-//
-// //
-// return new InvokeGetResponse(url.toString());
-// }
-// });
-// seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
-// {
-// Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
-// expectedParameters.put("bar", new String[]{"bar_resource","bar_render"});
-// expectedParameters.put("foo", new String[]{"foo_resource"});
-// expectedParameters.put("juu", new String[]{"juu_render"});
-// assertParameterMap(expectedParameters, request);
-//
-// //
-// return new EndTestResponse();
-// }
-// });
+ //
+ return new EndTestResponse();
+ }
+ });
}
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java 2008-02-02 02:00:40 UTC (rev 9710)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java 2008-02-02 02:16:21 UTC (rev 9711)
@@ -78,7 +78,9 @@
for (Map.Entry<String, String[]> entry : expectedMap.entrySet())
{
String expectedValue = entry.getValue()[0];
- assertEquals(expectedValue, request.getParameter(entry.getKey()));
+ String actualValue = request.getParameter(entry.getKey());
+ assertEquals("Was expecting value " + expectedValue + " for key " + entry.getKey() + " but instead have " +
+ actualValue, expectedValue, actualValue);
}
// Test getParameterValues(String name)
@@ -110,7 +112,8 @@
protected final void assertParameterMap(Map<String, String[]> expectedMap, Map<String, String[]> map) throws AssertionError
{
assertNotNull(map);
- assertEquals(expectedMap.size(), map.size());
+ assertEquals(expectedMap.keySet(), map.keySet());
+// assertEquals(map.keySet(), expectedMap.keySet());
for (Map.Entry<String, String[]> entry : expectedMap.entrySet())
{
String[] expectedValues = map.get(entry.getKey());
Modified: modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml 2008-02-02 02:00:40 UTC (rev 9710)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml 2008-02-02 02:16:21 UTC (rev 9711)
@@ -33,6 +33,30 @@
<supports>
<mime-type>text/html</mime-type>
</supports>
+ <supported-public-render-parameter>public</supported-public-render-parameter>
+ <supported-public-render-parameter>resource_public</supported-public-render-parameter>
+ <supported-public-render-parameter>form_public</supported-public-render-parameter>
+ <supported-public-render-parameter>resource_form_public</supported-public-render-parameter>
</portlet>
+ <public-render-parameter>
+ <identifier>public</identifier>
+ <name>public</name>
+ </public-render-parameter>
+
+ <public-render-parameter>
+ <identifier>resource_public</identifier>
+ <name>resource_public</name>
+ </public-render-parameter>
+
+ <public-render-parameter>
+ <identifier>form_public</identifier>
+ <name>form_public</name>
+ </public-render-parameter>
+
+ <public-render-parameter>
+ <identifier>resource_form_public</identifier>
+ <name>resource_form_public</name>
+ </public-render-parameter>
+
</portlet-app>
16 years, 3 months
JBoss Portal SVN: r9710 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common/util/typedmap and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-01 21:00:40 -0500 (Fri, 01 Feb 2008)
New Revision: 9710
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/AbstractTypedMap.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/typedmap/TypedMapKeySetTestCase.java
Log:
implemented abstract typed map key set equals and hashcode methods
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/AbstractTypedMap.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/AbstractTypedMap.java 2008-02-01 23:56:02 UTC (rev 9709)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/AbstractTypedMap.java 2008-02-02 02:00:40 UTC (rev 9710)
@@ -182,6 +182,15 @@
return !(left == null || right == null) && converter.equals(left, right);
}
+ /** . */
+ private KeySet keySet;
+
+ /** . */
+ private TypedEntrySet entrySet;
+
+ /** . */
+ private ValueCollection values;
+
public abstract Converter<EK, IK> getKeyConverter();
public abstract Converter<EV, IV> getValueConverter();
@@ -212,7 +221,11 @@
public final Set<EK> keySet()
{
- return new KeySet();
+ if (keySet == null)
+ {
+ keySet = new KeySet();
+ }
+ return keySet;
}
public final EV put(EK ek, EV ev)
@@ -298,7 +311,11 @@
public final Set<Entry<EK, EV>> entrySet()
{
- return new TypedEntrySet();
+ if (entrySet == null)
+ {
+ entrySet = new TypedEntrySet();
+ }
+ return entrySet;
}
public final void putAll(Map<? extends EK, ? extends EV> em)
@@ -309,7 +326,11 @@
public final Collection<EV> values()
{
- return new ValueCollection();
+ if (values == null)
+ {
+ values = new ValueCollection();
+ }
+ return values;
}
/** Compare to parameters objects. */
@@ -665,6 +686,69 @@
{
super(getDelegate().keySet(), getKeyConverter().unwrapper, getKeyConverter().wrapper);
}
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof Set)
+ {
+ Set that = (Set)obj;
+
+ //
+ if (size() != that.size())
+ {
+ return false;
+ }
+
+ //
+ for (Object o : that)
+ {
+ try
+ {
+ if (!contains(o))
+ {
+ return false;
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ catch (ClassCastException e)
+ {
+ return false;
+ }
+ catch (NullPointerException e)
+ {
+ return false;
+ }
+ }
+
+ //
+ return true;
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ int hashCode = 0;
+
+ //
+ for (Object o : this)
+ {
+ if (o != null)
+ {
+ hashCode += o.hashCode();
+ }
+ }
+
+ //
+ return hashCode;
+ }
}
private final class ValueCollection extends TypedCollection<EV,IV>
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/typedmap/TypedMapKeySetTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/typedmap/TypedMapKeySetTestCase.java 2008-02-01 23:56:02 UTC (rev 9709)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/typedmap/TypedMapKeySetTestCase.java 2008-02-02 02:00:40 UTC (rev 9710)
@@ -28,6 +28,7 @@
import java.util.HashMap;
import java.util.Set;
import java.util.Iterator;
+import java.util.HashSet;
import org.jboss.portal.common.util.Tools;
@@ -668,7 +669,14 @@
public void testEquals()
{
- // todo
+ Set<String> same = new HashSet<String>();
+ same.add("zero");
+ same.add("one");
+
+ assertTrue(keys.equals(same));
+
+
+
}
public void testHashCode()
16 years, 3 months
JBoss Portal SVN: r9709 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-01 18:56:02 -0500 (Fri, 01 Feb 2008)
New Revision: 9709
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/ListenedURLUpdateTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceURLParametersTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/MutablePageNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageNavigationalState.java
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PageNavigationalState.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListenerTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceIDTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml
Log:
- update the controlleur to make the page navigational state immutable in order to preserve the container request not modified
- added more test cases ...
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -26,9 +26,11 @@
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
import org.jboss.portal.portlet.impl.jsr168.ResourceRequestParameterMap;
import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.common.util.ParameterMap;
import javax.portlet.ResourceRequest;
import java.util.Map;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -59,7 +61,17 @@
public Map<String, String[]> getPrivateRenderParameterMap()
{
- return ((ResourceRequestParameterMap)requestParameterMap).getPrivateRenderParameters();
+ ParameterMap parameters = ((ResourceRequestParameterMap)requestParameterMap).getPrivateRenderParameters();
+
+ //
+ if (parameters != null)
+ {
+ return Collections.unmodifiableMap(parameters);
+ }
+ else
+ {
+ return Collections.emptyMap();
+ }
}
public String getCacheability()
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/ListenedURLUpdateTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/ListenedURLUpdateTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/ListenedURLUpdateTestCase.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -0,0 +1,202 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portleturl;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.unit.actions.PortletActionTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+import static org.jboss.unit.api.Assert.assertEquals;
+import org.jboss.unit.api.Assert;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletURL;
+import javax.portlet.PortletMode;
+import javax.portlet.ResourceURL;
+import javax.portlet.BaseURL;
+import javax.portlet.PortletRequest;
+import javax.portlet.MimeResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.PortletURLGenerationListener;
+import javax.portlet.PortletModeException;
+import javax.portlet.WindowState;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_50})
+public class ListenedURLUpdateTestCase
+{
+ public ListenedURLUpdateTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ URLGenerationListener1.delegate = updater;
+ URLGenerationListener2.delegate = null;
+
+ //
+ PortletURL actionURL = response.createActionURL();
+
+ //
+ String s = actionURL.toString();
+
+ //
+ assertEquals(null, actionURL.getPortletMode());
+ assertEquals(null, actionURL.getWindowState());
+ assertEquals(0, actionURL.getParameterMap().size());
+
+ //
+ return new InvokeGetResponse(s);
+ }
+ });
+ seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(Collections.singletonMap("foo", new String[]{"fooAction"}), request);
+ assertEquals(PortletMode.EDIT, request.getPortletMode());
+ assertEquals(WindowState.MAXIMIZED, request.getWindowState());
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ PortletURL renderURL = response.createRenderURL();
+
+ //
+ String s = renderURL.toString();
+
+ //
+ assertEquals(null, renderURL.getPortletMode());
+ assertEquals(null, renderURL.getWindowState());
+ assertEquals(0, renderURL.getParameterMap().size());
+
+ //
+ return new InvokeGetResponse(s);
+ }
+ });
+ seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(Collections.singletonMap("foo", new String[]{"fooRender"}), request);
+ assertEquals(PortletMode.VIEW, request.getPortletMode());
+ assertEquals(WindowState.NORMAL, request.getWindowState());
+
+ //
+ ResourceURL resourceURL = response.createResourceURL();
+
+ //
+ String s = resourceURL.toString();
+
+ //
+ assertEquals(ResourceURL.PAGE, resourceURL.getCacheability());
+ assertEquals(0, resourceURL.getParameterMap().size());
+
+ //
+ return new InvokeGetResponse(s);
+ }
+ });
+ seq.bindAction(3, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(Collections.singletonMap("foo", new String[]{"fooResource"}), request);
+ assertEquals("foo_resource_id", request.getResourceID());
+ assertEquals(ResourceURL.PORTLET, request.getCacheability());
+
+
+ return new EndTestResponse();
+ }
+ });
+ }
+
+ private static final PortletURLGenerationListener updater = new PortletURLGenerationListener()
+ {
+
+
+
+ public void filterActionURL(PortletURL portletURL)
+ {
+ try
+ {
+ portletURL.setPortletMode(PortletMode.EDIT);
+ portletURL.setWindowState(WindowState.MAXIMIZED);
+ portletURL.setParameter("foo", "fooAction");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void filterRenderURL(PortletURL portletURL)
+ {
+ try
+ {
+ portletURL.setPortletMode(PortletMode.VIEW);
+ portletURL.setWindowState(WindowState.NORMAL);
+ portletURL.setParameter("foo", "fooRender");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void filterResourceURL(ResourceURL resourceURL)
+ {
+ try
+ {
+ resourceURL.setParameter("foo", "fooResource");
+ resourceURL.setResourceID("foo_resource_id");
+ resourceURL.setCacheability(ResourceURL.PORTLET);
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ };
+
+
+}
\ No newline at end of file
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListenerTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListenerTestCase.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListenerTestCase.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -65,6 +65,10 @@
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
+ URLGenerationListener1.delegate = CallbackQueue.createListener("l1");
+ URLGenerationListener2.delegate = CallbackQueue.createListener("l2");
+
+ //
test(response, URLRenderer.ToString);
test(response, URLRenderer.Write);
test(response, URLRenderer.WriteXMLEspaced);
@@ -91,8 +95,6 @@
{
CallbackQueue.clear();
PortletURL actionURL = response.createActionURL();
- URLGenerationListener1.delegate = CallbackQueue.createListener("l1");
- URLGenerationListener2.delegate = CallbackQueue.createListener("l2");
assertEquals(0, CallbackQueue.size());
// Assert initial state
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/DowngradeCacheabilityTestCase.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -29,6 +29,7 @@
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.actions.PortletResourceTestAction;
import org.jboss.portal.test.portlet.framework.UTP2;
+import org.jboss.portal.test.portlet.framework.UTP1;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
@@ -73,7 +74,7 @@
{
public DowngradeCacheabilityTestCase(PortletTestCase seq)
{
- seq.bindAction(0, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
@@ -84,7 +85,7 @@
return new InvokeGetResponse(resourceURL.toString());
}
});
- seq.bindAction(1, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
@@ -133,7 +134,7 @@
return new InvokeGetResponse(resourceURL.toString());
}
});
- seq.bindAction(2, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
@@ -145,7 +146,7 @@
return new InvokeGetResponse(resourceURL.toString());
}
});
- seq.bindAction(3, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ seq.bindAction(3, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
@@ -205,7 +206,7 @@
return new InvokeGetResponse(resourceURL.toString());
}
});
- seq.bindAction(4, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ seq.bindAction(4, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/HTTPMethodTestCase.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -29,6 +29,7 @@
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.actions.PortletResourceTestAction;
import org.jboss.portal.test.portlet.framework.UTP4;
+import org.jboss.portal.test.portlet.framework.UTP1;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
@@ -61,7 +62,7 @@
{
public HTTPMethodTestCase(PortletTestCase seq)
{
- seq.bindAction(0, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
@@ -69,7 +70,7 @@
return new InvokeGetResponse(resourceURL.toString());
}
});
- seq.bindAction(1, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
@@ -81,7 +82,7 @@
return post;
}
});
- seq.bindAction(2, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceIDTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceIDTestCase.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceIDTestCase.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -29,6 +29,7 @@
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.actions.PortletResourceTestAction;
import org.jboss.portal.test.portlet.framework.UTP3;
+import org.jboss.portal.test.portlet.framework.UTP1;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
@@ -61,7 +62,7 @@
{
public ResourceIDTestCase(PortletTestCase seq)
{
- seq.bindAction(0, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
@@ -69,7 +70,7 @@
return new InvokeGetResponse(resourceURL.toString());
}
});
- seq.bindAction(1, UTP3.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
@@ -79,7 +80,7 @@
return new InvokeGetResponse(resourceURL.toString());
}
});
- seq.bindAction(2, UTP3.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
{
protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceURLParametersTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceURLParametersTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceURLParametersTestCase.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -0,0 +1,214 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.resourceserving;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
+import org.jboss.unit.remote.http.HttpRequest;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletURL;
+import javax.portlet.ResourceURL;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR286_128})
+public class ResourceURLParametersTestCase
+{
+
+ public ResourceURLParametersTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ ResourceURL url = response.createResourceURL();
+
+ //
+ url.setParameter("foo", new String[]{"foo_resource"});
+
+ //
+ return new InvokeGetResponse(url.toString());
+ }
+ });
+ seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String[]> expectedParameters = Collections.singletonMap("foo", new String[]{"foo_resource"});
+ assertParameterMap(expectedParameters, request);
+ assertParameterMap(expectedParameters, request.getPrivateParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateRenderParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
+
+ //
+ ResourceURL url = response.createResourceURL();
+
+ //
+ url.setParameter("foo", new String[]{"foo_resource"});
+ url.setParameter("bar", new String[]{"bar_resource"});
+
+ //
+ InvokePostResponse post = new InvokePostResponse(url.toString());
+ post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
+ HttpRequest.Form form = new HttpRequest.Form();
+ form.addParameter("bar", new String[]{"bar_form"});
+ form.addParameter("juu", new String[]{"juu_form"});
+ post.setBody(form);
+
+ //
+ return post;
+ }
+ });
+ seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
+ expectedParameters.put("foo", new String[]{"foo_resource"});
+ expectedParameters.put("bar", new String[]{"bar_resource", "bar_form"});
+ expectedParameters.put("juu", new String[]{"juu_form"});
+ assertParameterMap(expectedParameters, request);
+ assertParameterMap(expectedParameters, request.getPrivateParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateRenderParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
+
+ //
+ PortletURL renderURL = response.createRenderURL();
+ renderURL.setParameter("daa", "daa_render");
+ renderURL.setParameter("wee", "wee_render");
+ renderURL.setParameter("zii", "zii_render");
+
+ //
+ return new InvokeGetResponse(renderURL.toString());
+ }
+ });
+ seq.bindAction(3, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ ResourceURL url = response.createResourceURL();
+
+ //
+ url.setParameter("foo", new String[]{"foo_resource"});
+ url.setParameter("daa", new String[]{"daa_resource"});
+
+ //
+ return new InvokeGetResponse(url.toString());
+ }
+ });
+ seq.bindAction(4, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String[]> expectedPrivateParameters = new HashMap<String, String[]>();
+ expectedPrivateParameters.put("foo", new String[]{"foo_resource"});
+ expectedPrivateParameters.put("daa", new String[]{"daa_resource"});
+ Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
+ expectedParameters.put("foo", new String[]{"foo_resource"});
+ expectedParameters.put("daa", new String[]{"daa_resource","daa_render"});
+ expectedParameters.put("wee", new String[]{"wee_render"});
+ expectedParameters.put("zii", new String[]{"zii_render"});
+ Map<String, String[]> expectedPrivateRenderParameters = new HashMap<String, String[]>();
+ expectedPrivateRenderParameters.put("daa", new String[]{"daa_render"});
+ expectedPrivateRenderParameters.put("wee", new String[]{"wee_render"});
+ expectedPrivateRenderParameters.put("zii", new String[]{"zii_render"});
+ assertParameterMap(expectedParameters, request);
+// assertParameterMap(expectedPrivateParameters, request.getPrivateParameterMap());
+// assertParameterMap(expectedPrivateRenderParameters, request.getPrivateRenderParameterMap());
+// assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
+
+ //
+ return new EndTestResponse();
+ }
+ });
+
+
+
+
+
+
+// seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+// {
+// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+// {
+// PortletURL url = response.createRenderURL();
+//
+// //
+// url.setParameter("bar", new String[]{"bar_render"});
+// url.setParameter("juu", new String[]{"juu_render"});
+//
+// //
+// return new InvokeGetResponse(url.toString());
+// }
+// });
+// seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+// {
+// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+// {
+// ResourceURL url = response.createResourceURL();
+//
+// //
+// url.setParameter("foo", new String[]{"foo_resource"});
+// url.setParameter("bar", new String[]{"bar_resource"});
+//
+// //
+// return new InvokeGetResponse(url.toString());
+// }
+// });
+// seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+// {
+// protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+// {
+// Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
+// expectedParameters.put("bar", new String[]{"bar_resource","bar_render"});
+// expectedParameters.put("foo", new String[]{"foo_resource"});
+// expectedParameters.put("juu", new String[]{"juu_render"});
+// assertParameterMap(expectedParameters, request);
+//
+// //
+// return new EndTestResponse();
+// }
+// });
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -221,6 +221,11 @@
//
response = ((PortletEventTestAction)action).execute(this, req, resp, ctx);
}
+ else if (action == null)
+ {
+ response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
+ " " + NodeId.locate() + " " + actionJoinPoint + " is null"));
+ }
else
{
response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
@@ -291,6 +296,11 @@
//
response = ((PortletRenderTestAction)action).execute(this, req, resp, ctx);
}
+ else if (action == null)
+ {
+ response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
+ " " + NodeId.locate() + " " + resourceJoinPoint + " is null"));
+ }
else
{
response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
@@ -346,6 +356,11 @@
// Get the result that must exist since it is the only joinpoint invoked during this request
response = ((PortletResourceTestAction)action).execute(this, req, resp, ctx);
}
+ else if (action == null)
+ {
+ response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
+ " " + NodeId.locate() + " " + resourceJoinPoint + " is null"));
+ }
else
{
response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PageNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PageNavigationalState.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PageNavigationalState.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -1,110 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test;
-
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.ParameterInfo;
-
-import javax.xml.namespace.QName;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.zip.GZIPOutputStream;
-import java.util.zip.GZIPInputStream;
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PageNavigationalState implements Serializable
-{
-
- /** . */
- private final Map<String, WindowNavigationalState> windows = new HashMap<String, WindowNavigationalState>();
-
- /** . */
- private final Map<QName, String[]> page = new HashMap<QName, String[]>();
-
- public WindowNavigationalState getWindowNavigationalState(String windowId)
- {
- return windows.get(windowId);
- }
-
- public void setWindowNavigationalState(String windowId, WindowNavigationalState windowNS)
- {
- windows.put(windowId, windowNS);
- }
-
- public Map<QName, String[]> getPageNavigationalState()
- {
- return page;
- }
-
- public ParameterMap getPublicNavigationalState(Portlet portlet)
- {
- PortletInfo portletInfo = portlet.getInfo();
- Map<QName, String[]> pm = page;
- ParameterMap publicNavigationalState = null;
- for (ParameterInfo parameterInfo : portletInfo.getNavigation().getPublicParameters())
- {
- String[] parameterValue = pm.get(parameterInfo.getName());
- if (parameterValue != null)
- {
- String parameterId = parameterInfo.getId();
- if (publicNavigationalState == null)
- {
- publicNavigationalState = new ParameterMap();
- }
-
- //
- publicNavigationalState.put(parameterId, parameterValue);
- }
- }
- return publicNavigationalState;
- }
-
- public static byte[] serialize(PageNavigationalState object) throws IOException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream zos = new GZIPOutputStream(baos);
- ObjectOutputStream oos = new ObjectOutputStream(zos);
- oos.writeObject(object);
- oos.close();
- return baos.toByteArray();
- }
-
- public static PageNavigationalState unserialize(byte[] bytes) throws IOException, ClassNotFoundException
- {
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- GZIPInputStream zis = new GZIPInputStream(bais);
- ObjectInputStream ois = new ObjectInputStream(zis);
- return (PageNavigationalState)ois.readObject();
- }
-}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -35,6 +35,7 @@
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.io.IOTools;
import static org.jboss.portal.portlet.test.URLParameterConstants.*;
+import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/MutablePageNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/MutablePageNavigationalState.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/MutablePageNavigationalState.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.controller;
+
+import org.jboss.portal.portlet.test.WindowNavigationalState;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MutablePageNavigationalState extends PageNavigationalState
+{
+
+ public MutablePageNavigationalState()
+ {
+ }
+
+ public MutablePageNavigationalState(PageNavigationalState original)
+ {
+ super(original);
+ }
+
+ public void setWindowNavigationalState(String windowId, WindowNavigationalState windowNS)
+ {
+ windows.put(windowId, windowNS);
+ }
+
+ public void setPublicNavigationalState(QName name, String[] value)
+ {
+ // We clone the value in order to keep the state not mutated by a side effect
+ page.put(name, value.clone());
+ }
+
+ public void removePublicNavigationalState(QName name)
+ {
+ page.remove(name);
+ }
+}
\ No newline at end of file
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageNavigationalState.java (from rev 9707, modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PageNavigationalState.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageNavigationalState.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageNavigationalState.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -0,0 +1,117 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.controller;
+
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.test.WindowNavigationalState;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.ParameterInfo;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.zip.GZIPOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PageNavigationalState implements Serializable
+{
+
+ /** . */
+ protected final Map<String, WindowNavigationalState> windows;
+
+ /** . */
+ protected final Map<QName, String[]> page;
+
+ public PageNavigationalState()
+ {
+ this.windows = new HashMap<String, WindowNavigationalState>();
+ this.page = new HashMap<QName, String[]>();
+ }
+
+ public PageNavigationalState(PageNavigationalState original)
+ {
+ this.windows = new HashMap<String, WindowNavigationalState>(original.windows);
+ this.page = new HashMap<QName, String[]>(original.page);
+ }
+
+ public WindowNavigationalState getWindowNavigationalState(String windowId)
+ {
+ return windows.get(windowId);
+ }
+
+ public ParameterMap getPublicNavigationalState(Portlet portlet)
+ {
+ ParameterMap publicNavigationalState = null;
+ for (ParameterInfo parameterInfo : portlet.getInfo().getNavigation().getPublicParameters())
+ {
+ String[] parameterValue = page.get(parameterInfo.getName());
+
+ //
+ if (parameterValue != null)
+ {
+ String parameterId = parameterInfo.getId();
+
+ // Lazy create
+ if (publicNavigationalState == null)
+ {
+ publicNavigationalState = new ParameterMap();
+ }
+
+ // We clone the value here so we keep the internal state not potentially changed
+ publicNavigationalState.put(parameterId, parameterValue.clone());
+ }
+ }
+
+ //
+ return publicNavigationalState;
+ }
+
+ public static byte[] serialize(PageNavigationalState object) throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream zos = new GZIPOutputStream(baos);
+ ObjectOutputStream oos = new ObjectOutputStream(zos);
+ oos.writeObject(object);
+ oos.close();
+ return baos.toByteArray();
+ }
+
+ public static PageNavigationalState unserialize(byte[] bytes) throws IOException, ClassNotFoundException
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ GZIPInputStream zis = new GZIPInputStream(bais);
+ ObjectInputStream ois = new ObjectInputStream(zis);
+ return (PageNavigationalState)ois.readObject();
+ }
+}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -45,7 +45,7 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.spi.PortalContext;
-import org.jboss.portal.portlet.test.PageNavigationalState;
+import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import org.jboss.portal.portlet.test.PortletURLRenderer;
import org.jboss.portal.portlet.test.TestInstanceContext;
import org.jboss.portal.portlet.test.TestRenderContext;
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -36,7 +36,7 @@
import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.test.PageNavigationalState;
+import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import org.jboss.portal.portlet.test.StringCodec;
import static org.jboss.portal.portlet.test.URLParameterConstants.*;
import org.jboss.portal.portlet.test.WindowNavigationalState;
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -27,7 +27,7 @@
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
-import org.jboss.portal.portlet.test.PageNavigationalState;
+import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import org.jboss.portal.portlet.test.PortletURLRenderer;
import org.jboss.portal.portlet.test.TestActionContext;
import org.jboss.portal.portlet.test.TestEventContext;
@@ -71,8 +71,14 @@
{
PortletControllerContext context = portletRequest.controllerContext;
+ // The page navigational state we will operate on during the request
+ // Either we have nothing in the request so we create a new one
+ // Or we have one but we copy it as we should not modify the input state provided
+ MutablePageNavigationalState pageState = portletRequest.pageState == null ? new MutablePageNavigationalState() : new MutablePageNavigationalState(portletRequest.pageState);
+
//
PortletContext portletContext = portletRequest.controllerContext.getPortlet(portletRequest.portletId).getContext();
+
//
ResponseProperties requestProperties = new ResponseProperties();
@@ -100,7 +106,7 @@
if (response instanceof UpdateNavigationalStateResponse)
{
UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;
- updateNavigationalState(context, portletRequest.portletId, updateResponse, portletRequest.pageState);
+ updateNavigationalState(context, portletRequest.portletId, updateResponse, pageState);
//
ResponseProperties update = updateResponse.getProperties();
@@ -129,7 +135,7 @@
Event event = eventQueue.removeFirst();
//
- PortletInvocationResponse eventResponse = deliverEvent(context, event, portletRequest.pageState, requestProperties.getCookies());
+ PortletInvocationResponse eventResponse = deliverEvent(context, event, pageState, requestProperties.getCookies());
//
if (eventResponse instanceof UpdateNavigationalStateResponse)
@@ -137,7 +143,7 @@
UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)eventResponse;
// Update ns
- updateNavigationalState(context, event.getPortletContext().getId(), update, portletRequest.pageState);
+ updateNavigationalState(context, event.getPortletContext().getId(), update, pageState);
// Add events if any
for (StateResponse.Event portletEvent : update.getEvents())
@@ -201,7 +207,7 @@
*/
//
- controller.render(context, requestProperties, portletRequest.pageState);
+ controller.render(context, requestProperties, pageState);
}
PortletInvocationResponse invoke(PortletRequest portletRequest) throws PortletInvokerException
@@ -346,7 +352,7 @@
}
private void updateNavigationalState(PortletControllerContext context, String portletId,
- UpdateNavigationalStateResponse update, PageNavigationalState pageState)
+ UpdateNavigationalStateResponse update, MutablePageNavigationalState pageState)
throws PortletInvokerException
{
Portlet portlet = context.getPortlet(portletId);
@@ -384,7 +390,6 @@
if (publicNS != null)
{
NavigationInfo navigationInfo = portlet.getInfo().getNavigation();
- Map<QName, String[]> pageNS = pageState.getPageNavigationalState();
for (Map.Entry<String, String[]> entry : publicNS.entrySet())
{
String id = entry.getKey();
@@ -397,11 +402,11 @@
String[] value = entry.getValue();
if (value.length > 0)
{
- pageNS.put(name, value);
+ pageState.setPublicNavigationalState(name, value);
}
else
{
- pageNS.remove(name);
+ pageState.removePublicNavigationalState(name);
}
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -42,7 +42,7 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
-import org.jboss.portal.portlet.test.PageNavigationalState;
+import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import org.jboss.portal.portlet.test.PortletURLRenderer;
import org.jboss.portal.portlet.test.ResourceTestContext;
import org.jboss.portal.portlet.test.TestInstanceContext;
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java 2008-02-01 23:56:02 UTC (rev 9709)
@@ -26,7 +26,7 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
-import org.jboss.portal.portlet.test.PageNavigationalState;
+import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import static org.jboss.portal.portlet.test.controller.PortletController.ControllerRequest;
import static org.jboss.portal.portlet.test.controller.PortletController.ViewRequest;
Modified: modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml 2008-02-01 22:58:18 UTC (rev 9708)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml 2008-02-01 23:56:02 UTC (rev 9709)
@@ -35,28 +35,4 @@
</supports>
</portlet>
- <portlet>
- <portlet-name>UniversalTestPortletB</portlet-name>
- <portlet-class>org.jboss.portal.test.portlet.framework.UTP2</portlet-class>
- <supports>
- <mime-type>text/html</mime-type>
- </supports>
- </portlet>
-
- <portlet>
- <portlet-name>UniversalTestPortletC</portlet-name>
- <portlet-class>org.jboss.portal.test.portlet.framework.UTP3</portlet-class>
- <supports>
- <mime-type>text/html</mime-type>
- </supports>
- </portlet>
-
- <portlet>
- <portlet-name>UniversalTestPortletD</portlet-name>
- <portlet-class>org.jboss.portal.test.portlet.framework.UTP4</portlet-class>
- <supports>
- <mime-type>text/html</mime-type>
- </supports>
- </portlet>
-
</portlet-app>
16 years, 3 months