Author: julien(a)jboss.com
Date: 2008-03-19 09:27:45 -0400 (Wed, 19 Mar 2008)
New Revision: 10333
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/RepeatedFilter.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/RepeatedFilterTestCase.java
Modified:
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/portlet.xml
Log:
JBPORTAL-1958 : Cannot map the same filter on 2 different portlets (if declared
separately) (test case)
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/RepeatedFilter.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/RepeatedFilter.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/RepeatedFilter.java 2008-03-19
13:27:45 UTC (rev 10333)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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 javax.portlet.filter.FilterConfig;
+import javax.portlet.filter.RenderFilter;
+import javax.portlet.filter.FilterChain;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class RepeatedFilter implements RenderFilter
+{
+
+ /** . */
+ public static final Set<String> names = new HashSet<String>();
+
+ public void init(FilterConfig config) throws PortletException
+ {
+ }
+
+ public void doFilter(RenderRequest req, RenderResponse resp, FilterChain chain) throws
IOException, PortletException
+ {
+ chain.doFilter(req, resp);
+ String name = (String)req.getAttribute("NAME");
+ if (name != null)
+ {
+ names.add(name);
+ }
+ }
+
+ public void destroy()
+ {
+ }
+}
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/RepeatedFilterTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/RepeatedFilterTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletfilter/RepeatedFilterTestCase.java 2008-03-19
13:27:45 UTC (rev 10333)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.base.AbstractUniversalTestPortlet;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP2;
+import org.jboss.portal.test.portlet.framework.UTP3;
+import org.jboss.portal.common.util.Tools;
+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 java.io.IOException;
+
+/**
+ * Test that a portlet filter mapped 2 times in the descriptor is applied on
+ * each portlet.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase()
+public class RepeatedFilterTestCase
+{
+
+ private String name1;
+ private String name2;
+
+ public RepeatedFilterTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ name1 =
((AbstractUniversalTestPortlet)portlet).getPortletConfig().getPortletName();
+ request.setAttribute("NAME", name1);
+
+ //
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(0, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ name2 =
((AbstractUniversalTestPortlet)portlet).getPortletConfig().getPortletName();
+ request.setAttribute("NAME", name2);
+
+ //
+ return null;
+ }
+ });
+ seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals(Tools.toSet(name1, name2), RepeatedFilter.names);
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified:
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 2008-03-19
13:00:56 UTC (rev 10332)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletfilter-war/WEB-INF/portlet.xml 2008-03-19
13:27:45 UTC (rev 10333)
@@ -35,6 +35,22 @@
</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>
+
<filter>
<filter-name>FilterConfigFilter</filter-name>
<filter-class>org.jboss.portal.test.portlet.jsr286.ext.portletfilter.FilterConfigFilter</filter-class>
@@ -49,4 +65,20 @@
</init-param>
</filter>
+ <filter>
+ <filter-name>RepeatedFilter</filter-name>
+
<filter-class>org.jboss.portal.test.portlet.jsr286.ext.portletfilter.RepeatedFilter</filter-class>
+ <lifecycle>RENDER_PHASE</lifecycle>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>RepeatedFilter</filter-name>
+ <portlet-name>UniversalTestPortletB</portlet-name>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>RepeatedFilter</filter-name>
+ <portlet-name>UniversalTestPortletC</portlet-name>
+ </filter-mapping>
+
</portlet-app>