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...
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>