Author: julien(a)jboss.com
Date: 2008-01-22 16:45:20 -0500 (Tue, 22 Jan 2008)
New Revision: 9572
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterWithPortletURLTestCase.java
Modified:
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
added test case for PortletURL.removePublicRenderParameter(String name) method
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterWithPortletURLTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterWithPortletURLTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterWithPortletURLTestCase.java 2008-01-22
21:45:20 UTC (rev 9572)
@@ -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.test.portlet.jsr286.ext.portletrequests;
+
+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.unit.actions.PortletActionTestAction;
+import org.jboss.portal.test.portlet.framework.UTP2;
+import org.jboss.portal.test.portlet.framework.UTP3;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+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.ActionRequest;
+import javax.portlet.ActionResponse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Test that removePublicRenderParameter method on PortletURL removes the render
parameter
+ * in the context of a render url and does nothing in the context of an action url.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class RemovePublicRenderParameterWithPortletURLTestCase
+{
+
+ /** . */
+ private final Map<String, String[]> expectedPublicRenderParameterMap =
Collections.singletonMap("foo", new String[]{"foo_value"});
+
+ public RemovePublicRenderParameterWithPortletURLTestCase(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
+ {
+ PortletURL renderURL = response.createRenderURL();
+ renderURL.setParameter("foo", "foo_value");
+ return new InvokeGetResponse(renderURL.toString());
+ }
+ });
+ seq.bindAction(1, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap,
request.getPublicParameterMap());
+
+ //
+ PortletURL renderURL = response.createRenderURL();
+ renderURL.removePublicRenderParameter("foo");
+ return new InvokeGetResponse(renderURL.toString());
+ }
+ });
+ seq.bindAction(2, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(new HashMap<String, String[]>(), request);
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPrivateParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPublicParameterMap());
+
+ //
+ PortletURL renderURL = response.createRenderURL();
+ renderURL.setParameter("foo", "foo_value");
+ return new InvokeGetResponse(renderURL.toString());
+ }
+ });
+ seq.bindAction(2, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(new HashMap<String, String[]>(), request);
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPrivateParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPublicParameterMap());
+ return null;
+ }
+ });
+ seq.bindAction(3, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap,
request.getPublicParameterMap());
+
+ //
+ PortletURL actionURL = response.createActionURL();
+ actionURL.removePublicRenderParameter("foo");
+ return new InvokeGetResponse(actionURL.toString());
+ }
+ });
+ seq.bindAction(3, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap,
request.getPublicParameterMap());
+ return null;
+ }
+ });
+ seq.bindAction(4, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap,
request.getPublicParameterMap());
+ }
+ });
+ seq.bindAction(4, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap,
request.getPublicParameterMap());
+ return new EndTestResponse();
+ }
+ });
+ seq.bindAction(4, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(),
request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap,
request.getPublicParameterMap());
+ return null;
+ }
+ });
+ }
+}
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-01-22
21:44:40 UTC (rev 9571)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-22
21:45:20 UTC (rev 9572)
@@ -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-dispatcher.war"/>
@@ -133,6 +140,7 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr168-ext-session.war"/>
</generic>
+-->
<!--
<generic>
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
@@ -147,8 +155,11 @@
<property name="archiveId"
value="test-jsr168-ext-nocache.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-portletconfig.war"/>
@@ -178,11 +189,14 @@
<property name="archiveId"
value="test-jsr286-tck-resourceserving.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-->
<generic>