[jboss-svn-commits] JBoss Portal SVN: r5541 - in trunk/wsrp/src: main/org/jboss/portal/test/wsrp/portlet main/org/jboss/portal/test/wsrp/v1/producer main/org/jboss/portal/wsrp main/org/jboss/portal/wsrp/producer resources/tests resources/tests/test-multivalued-portlet-war resources/tests/test-multivalued-portlet-war/WEB-INF
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 31 17:08:34 EST 2006
Author: chris.laprun at jboss.com
Date: 2006-10-31 17:08:29 -0500 (Tue, 31 Oct 2006)
New Revision: 5541
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/MultiValuedPortlet.java
trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/
trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/WEB-INF/
trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/WEB-INF/portlet.xml
trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/WEB-INF/web.xml
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/ResponseDebugFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
Log:
- JBPORTAL-1095: fixed incorrect handling of multi-valued form parameters.
- Added test case.
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/MultiValuedPortlet.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/MultiValuedPortlet.java 2006-10-31 22:06:41 UTC (rev 5540)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/MultiValuedPortlet.java 2006-10-31 22:08:29 UTC (rev 5541)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * 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.wsrp.portlet;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.portlet.MultiValuedPortlet">Chris
+ * Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class MultiValuedPortlet extends GenericPortlet
+{
+ private static final String MULTI = "multi";
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws PortletModeException, IOException
+ {
+ String[] multi = req.getParameterValues(MULTI);
+
+ if (multi != null)
+ {
+ resp.setRenderParameter(MULTI, multi);
+ }
+ resp.setPortletMode(PortletMode.VIEW);
+ }
+
+ protected void doView(RenderRequest request, RenderResponse response) throws IOException
+ {
+ response.setContentType("text/html");
+ Writer writer = response.getWriter();
+ writer.write("multi: ");
+ String[] values = request.getParameterValues(MULTI);
+ if (values != null)
+ {
+ StringBuffer sb = new StringBuffer(32);
+ for (int i = 0; i < values.length; i++)
+ {
+ sb.append(values[i]);
+ if (i != values.length - 1)
+ {
+ sb.append(", ");
+ }
+ }
+ writer.write(sb.toString());
+ }
+ }
+}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2006-10-31 22:06:41 UTC (rev 5540)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2006-10-31 22:08:29 UTC (rev 5541)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.wsrp.v1.producer;
+import org.jboss.portal.common.junit.ExtendedAssert;
import org.jboss.portal.wsrp.WSRPActionURL;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPPortletURL;
@@ -42,7 +43,6 @@
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UpdateResponse;
import org.jboss.portal.wsrp.handler.RequestHeaderClientHandler;
-import org.jboss.portal.common.junit.ExtendedAssert;
import java.rmi.RemoteException;
@@ -187,56 +187,11 @@
undeploy(sessionPortletArchive);
}
- private void checkMarkupResponseWithSession(MarkupResponse response, int count) throws RemoteException, InvalidRegistrationFault, OperationFailedFault
- {
- ExtendedAssert.assertNotNull(response);
-
- // Markup context
- MarkupContext markupContext = response.getMarkupContext();
- ExtendedAssert.assertNotNull(markupContext);
- ExtendedAssert.assertEquals("<p>" + count + "</p><div><a href=\"wsrp_rewrite?wsrp-urlType=render" +
- "&wsrp-navigationalState=JBPNS_/wsrp_rewrite\">render</a></div>", markupContext.getMarkupString());
-
- // checking session
- ProducerSessionInformation sessionInfo = RequestHeaderClientHandler.getCurrentProducerSessionInformation();
- ExtendedAssert.assertNotNull(sessionInfo);
- ExtendedAssert.assertTrue(sessionInfo.getUserCookie().lastIndexOf("JSESSIONID") != -1);
- }
-
public void testPerformBlockingInteractionNoRedirect() throws Exception
{
checkPBIAndGetNavigationalState("RHAT");
}
- private String checkPBIAndGetNavigationalState(String symbol) throws Exception
- {
- PerformBlockingInteraction performBlockingInteraction =
- WSRPTypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
- InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();
- NamedString[] formParams = {new NamedString("symbol", symbol)};
- interactionParams.setFormParameters(formParams);
-
- BlockingInteractionResponse response = markupService.performBlockingInteraction(performBlockingInteraction);
- ExtendedAssert.assertNotNull(response);
-
- // this is not a redirect...
- ExtendedAssert.assertNull(response.getRedirectURL());
-
- // check update response
- UpdateResponse updateResponse = response.getUpdateResponse();
- ExtendedAssert.assertNotNull(updateResponse);
- // request was readOnly so no updated portlet context
- ExtendedAssert.assertNull(updateResponse.getPortletContext());
-
- String navigationalState = updateResponse.getNavigationalState();
- ExtendedAssert.assertNotNull(navigationalState);
- ExtendedAssert.assertEquals(updateResponse.getNewMode(), WSRPConstants.VIEW_MODE);
- MarkupContext markupContext = updateResponse.getMarkupContext();
- ExtendedAssert.assertNull(markupContext); // we don't return markup for now
-
- return navigationalState;
- }
-
public void testPerformBlockingInteractionRedirect() throws Exception
{
PerformBlockingInteraction performBlockingInteraction =
@@ -421,6 +376,84 @@
undeploy(userContextPortletArchive);
}
+ public void testGetMarkupMultiValuedFormParams() throws Exception
+ {
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
+ String multiValuedPortletArchive = "test-multivalued-portlet.war";
+ deploy(multiValuedPortletArchive);
+
+ PerformBlockingInteraction action =
+ WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+ action.getInteractionParams().setFormParameters(new NamedString[]{new NamedString("multi", "value1")});
+ BlockingInteractionResponse actionResponse = markupService.performBlockingInteraction(action);
+ GetMarkup markupRequest = createMarkupRequest(multiValuedPortletArchive);
+ markupRequest.getMarkupParams().setNavigationalState(actionResponse.getUpdateResponse().getNavigationalState());
+ MarkupResponse response = markupService.getMarkup(markupRequest);
+ checkMarkupResponse(response, "multi: value1");
+
+ action.getInteractionParams().setFormParameters(new NamedString[]{
+ new NamedString("multi", "value1"), new NamedString("multi", "value2")});
+ actionResponse = markupService.performBlockingInteraction(action);
+ markupRequest = createMarkupRequest(multiValuedPortletArchive);
+ markupRequest.getMarkupParams().setNavigationalState(actionResponse.getUpdateResponse().getNavigationalState());
+ response = markupService.getMarkup(markupRequest);
+ checkMarkupResponse(response, "multi: value1, value2");
+
+ action.getInteractionParams().setFormParameters(new NamedString[]{});
+ actionResponse = markupService.performBlockingInteraction(action);
+ markupRequest = createMarkupRequest(multiValuedPortletArchive);
+ markupRequest.getMarkupParams().setNavigationalState(actionResponse.getUpdateResponse().getNavigationalState());
+ response = markupService.getMarkup(markupRequest);
+ checkMarkupResponse(response, "multi: ");
+
+ undeploy(multiValuedPortletArchive);
+ }
+
+ private String checkPBIAndGetNavigationalState(String symbol) throws Exception
+ {
+ PerformBlockingInteraction performBlockingInteraction =
+ WSRPTypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
+ InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();
+ NamedString[] formParams = {new NamedString("symbol", symbol)};
+ interactionParams.setFormParameters(formParams);
+
+ BlockingInteractionResponse response = markupService.performBlockingInteraction(performBlockingInteraction);
+ ExtendedAssert.assertNotNull(response);
+
+ // this is not a redirect...
+ ExtendedAssert.assertNull(response.getRedirectURL());
+
+ // check update response
+ UpdateResponse updateResponse = response.getUpdateResponse();
+ ExtendedAssert.assertNotNull(updateResponse);
+ // request was readOnly so no updated portlet context
+ ExtendedAssert.assertNull(updateResponse.getPortletContext());
+
+ String navigationalState = updateResponse.getNavigationalState();
+ ExtendedAssert.assertNotNull(navigationalState);
+ ExtendedAssert.assertEquals(updateResponse.getNewMode(), WSRPConstants.VIEW_MODE);
+ MarkupContext markupContext = updateResponse.getMarkupContext();
+ ExtendedAssert.assertNull(markupContext); // we don't return markup for now
+
+ return navigationalState;
+ }
+
+ private void checkMarkupResponseWithSession(MarkupResponse response, int count) throws RemoteException, InvalidRegistrationFault, OperationFailedFault
+ {
+ ExtendedAssert.assertNotNull(response);
+
+ // Markup context
+ MarkupContext markupContext = response.getMarkupContext();
+ ExtendedAssert.assertNotNull(markupContext);
+ ExtendedAssert.assertEquals("<p>" + count + "</p><div><a href=\"wsrp_rewrite?wsrp-urlType=render" +
+ "&wsrp-navigationalState=JBPNS_/wsrp_rewrite\">render</a></div>", markupContext.getMarkupString());
+
+ // checking session
+ ProducerSessionInformation sessionInfo = RequestHeaderClientHandler.getCurrentProducerSessionInformation();
+ ExtendedAssert.assertNotNull(sessionInfo);
+ ExtendedAssert.assertTrue(sessionInfo.getUserCookie().lastIndexOf("JSESSIONID") != -1);
+ }
+
private MarkupContext checkMarkupResponse(MarkupResponse response, String markupString)
{
ExtendedAssert.assertNotNull(response);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/ResponseDebugFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/ResponseDebugFactory.java 2006-10-31 22:06:41 UTC (rev 5540)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/ResponseDebugFactory.java 2006-10-31 22:08:29 UTC (rev 5541)
@@ -58,16 +58,23 @@
buffer.append("### List of offered portlets: \n");
PortletDescription[] portlets = sd.getOfferedPortlets();
- for (int i = 0; i < portlets.length; i++)
+ if (portlets != null)
{
- PortletDescription portlet = portlets[i];
- String index = "[" + i + "]";
- buffer.append(index).append("portletHandle : ").append(portlet.getPortletHandle()).append("\n");
- buffer.append(index).append("description : ").append(toString(portlet.getDescription())).append("\n");
- buffer.append(index).append("shortTitle : ").append(toString(portlet.getShortTitle())).append("\n");
- buffer.append(index).append("title : ").append(toString(portlet.getTitle())).append("\n");
- buffer.append(index).append("displayName : ").append(toString(portlet.getDisplayName())).append("\n");
+ for (int i = 0; i < portlets.length; i++)
+ {
+ PortletDescription portlet = portlets[i];
+ String index = "[" + i + "]";
+ buffer.append(index).append("portletHandle : ").append(portlet.getPortletHandle()).append("\n");
+ buffer.append(index).append("description : ").append(toString(portlet.getDescription())).append("\n");
+ buffer.append(index).append("shortTitle : ").append(toString(portlet.getShortTitle())).append("\n");
+ buffer.append(index).append("title : ").append(toString(portlet.getTitle())).append("\n");
+ buffer.append(index).append("displayName : ").append(toString(portlet.getDisplayName())).append("\n");
+ }
}
+ else
+ {
+ buffer.append("no offered portlets");
+ }
return buffer;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-10-31 22:06:41 UTC (rev 5540)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-10-31 22:08:29 UTC (rev 5541)
@@ -320,7 +320,7 @@
Parameters parameters;
NamedString[] formParams = interactionParams.getFormParameters();
- if (formParams != null)
+ if (formParams != null && formParams.length > 0)
{
int length = formParams.length;
Map params = new HashMap(length);
@@ -334,9 +334,9 @@
// handle multi-valued parameters...
String[] oldValues = (String[])params.get(paramName);
int valuesLength = oldValues.length;
- String[] newValues = new String[valuesLength];
- System.arraycopy(oldValues, 0, newValues, 0, valuesLength - 1);
- newValues[length] = paramValue;
+ String[] newValues = new String[valuesLength + 1];
+ System.arraycopy(oldValues, 0, newValues, 0, valuesLength);
+ newValues[valuesLength] = paramValue;
params.put(paramName, newValues);
}
else
Added: trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/WEB-INF/portlet.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/WEB-INF/portlet.xml 2006-10-31 22:06:41 UTC (rev 5540)
+++ trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/WEB-INF/portlet.xml 2006-10-31 22:08:29 UTC (rev 5541)
@@ -0,0 +1,43 @@
+<?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_1_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0">
+ <portlet>
+ <portlet-name>Multi-valued Test Portlet</portlet-name>
+ <portlet-class>org.jboss.portal.test.wsrp.portlet.MultiValuedPortlet</portlet-class>
+ <expiration-cache>15</expiration-cache>
+
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>view</portlet-mode>
+ </supports>
+
+ <portlet-info>
+ <title>title</title>
+ </portlet-info>
+ </portlet>
+
+</portlet-app>
\ No newline at end of file
Added: trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/WEB-INF/web.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/WEB-INF/web.xml 2006-10-31 22:06:41 UTC (rev 5540)
+++ trunk/wsrp/src/resources/tests/test-multivalued-portlet-war/WEB-INF/web.xml 2006-10-31 22:08:29 UTC (rev 5541)
@@ -0,0 +1,30 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<web-app version="2.4"
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+</web-app>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list