Author: chris.laprun(a)jboss.com
Date: 2008-07-10 17:48:11 -0400 (Thu, 10 Jul 2008)
New Revision: 11415
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/other/AbsoluteURLReplacementGeneratorTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ResourceNoEncodeURLPortlet.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/jboss-portlet.xml
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/web.xml
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/gif/
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/gif/logo.gif
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/build.xml
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockHttpServletRequest.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
Log:
- JBPORTAL-2067: Fixed several issues, added more tests.
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/build.xml 2008-07-10 18:20:05 UTC (rev 11414)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/build.xml 2008-07-10 21:48:11 UTC (rev 11415)
@@ -23,13 +23,13 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<!DOCTYPE project [
- <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
- <!ENTITY buildmagic SYSTEM
"../tools/etc/buildfragments/buildmagic.ent">
- <!ENTITY tools SYSTEM "../tools/etc/buildfragments/tools.ent">
- <!ENTITY modules SYSTEM "../tools/etc/buildfragments/modules.ent">
- <!ENTITY defaults SYSTEM
"../tools/etc/buildfragments/defaults.ent">
- <!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent">
- ]>
+ <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+ <!ENTITY buildmagic SYSTEM
"../tools/etc/buildfragments/buildmagic.ent">
+ <!ENTITY tools SYSTEM
"../tools/etc/buildfragments/tools.ent">
+ <!ENTITY modules SYSTEM
"../tools/etc/buildfragments/modules.ent">
+ <!ENTITY defaults SYSTEM
"../tools/etc/buildfragments/defaults.ent">
+ <!ENTITY targets SYSTEM
"../tools/etc/buildfragments/targets.ent">
+ ]>
<!-- $Id$ -->
@@ -45,11 +45,7 @@
<project default="main" name="WSRP for JBoss Portal"
xmlns:server="http://jboss.org/ns/test/ant/server">
- <!--| Include the common build elements. |-->
- <!--| |-->
- <!--| This defines several different targets, properties and paths. |-->
- <!--| It also sets up the basic extention tasks amoung other things. |-->
- <!--+====================================================================+-->
+ <!--| Include the common build elements.
|--><!--|
|--><!--| This defines several different targets, properties and paths.
|--><!--| It also sets up the basic extention tasks amoung other things.
|--><!--+====================================================================+-->
&buildmagic;
&modules;
@@ -57,9 +53,7 @@
&tools;
&targets;
- <!-- ================================================================== -->
- <!-- Initialization -->
- <!-- ================================================================== -->
+ <!-- ==================================================================
--><!-- Initialization
--><!-- ================================================================== -->
<!--
| Initialize the build system. Must depend on '_buildmagic:init'.
@@ -78,24 +72,19 @@
<pathelement
location="${project.tools}/lib/cargo-core-uberjar-0.8.jar"/>
</path>
<taskdef
- name="deploy"
- classname="org.jboss.portal.common.ant.Deploy"
- classpathref="portal.task.classpath"/>
+ name="deploy"
+ classname="org.jboss.portal.common.ant.Deploy"
+ classpathref="portal.task.classpath"/>
<taskdef
- name="undeploy"
- classname="org.jboss.portal.common.ant.Undeploy"
- classpathref="portal.task.classpath"/>
+ name="undeploy"
+ classname="org.jboss.portal.common.ant.Undeploy"
+ classpathref="portal.task.classpath"/>
<target name="init" depends="_buildmagic:init">
<!-- Add module specific elements here -->
</target>
- <!--+====================================================================+-->
- <!--| Configuration |-->
- <!--| |-->
- <!--| This target is invoked by the Buildmagic initialization logic |-->
- <!--| and should contain module specific configuration elements. |-->
- <!--+====================================================================+-->
+
<!--+====================================================================+--><!--|
Configuration |--><!--|
|--><!--| This target is
invoked by the Buildmagic initialization logic |--><!--| and should contain
module specific configuration elements.
|--><!--+====================================================================+-->
<target name="configure" unless="configure.disable">
@@ -174,9 +163,7 @@
<path refid="jboss.portal-faces.classpath"/>
</path>
- <!--+=======================================+-->
- <!--| Override any default properties here. |-->
- <!--+=======================================+-->
+ <!--+=======================================+--><!--| Override any default
properties here. |--><!--+=======================================+-->
<!-- Classes generated from WSDL are in a non-standard location so need to
override properties -->
<property name="build.gen" value="${module.source}"/>
@@ -202,9 +189,7 @@
<call target="configure-explode"/>
<call target="configure-jbossaop"/>
- <!--+=======================================+-->
- <!--| Define module specific elements here. |-->
- <!--+=======================================+-->
+ <!--+=======================================+--><!--| Define module
specific elements here. |--><!--+=======================================+-->
<property name="javadoc.private" value="true"/>
<property name="javadoc.protected" value="false"/>
@@ -224,9 +209,9 @@
<path refid="qdox.qdox.classpath"/>
</path>
<taskdef
- name="aopc"
- classname="org.jboss.aop.ant.AopC"
- classpathref="jbossaop.task.classpath"/>
+ name="aopc"
+ classname="org.jboss.aop.ant.AopC"
+ classpathref="jbossaop.task.classpath"/>
</target>
<target name="configure-explode">
@@ -239,13 +224,7 @@
classpathref="explode.task.classpath"/>
</target>
- <!--+====================================================================+-->
- <!--| Compile |-->
- <!--| |-->
- <!--| This target should depend on other compile-* targets for each |-->
- <!--| different type of compile that needs to be performed, short of |-->
- <!--| documentation compiles. |-->
- <!--+====================================================================+-->
+
<!--+====================================================================+--><!--|
Compile |--><!--|
|--><!--| This target
should depend on other compile-* targets for each |--><!--| different type of
compile that needs to be performed, short of |--><!--| documentation compiles.
|--><!--+====================================================================+-->
<target name="compile"
description="Compile all source files."
@@ -285,13 +264,7 @@
<property name="compile.disable" value="true"/>
</target>
- <!--+====================================================================+-->
- <!--| Generate Output |-->
- <!--| |-->
- <!--| Generates the target output for this module. Target output is |-->
- <!--| the output which is meant to be released or used by external |-->
- <!--| modules. |-->
- <!--+====================================================================+-->
+
<!--+====================================================================+--><!--|
Generate Output |--><!--|
|--><!--| Generates the
target output for this module. Target output is |--><!--| the output which is
meant to be released or used by external |--><!--| modules.
|--><!--+====================================================================+-->
<target name="output" description="Generate WSRP Service
archive." depends="compile">
<mkdir dir="${build.lib}"/>
@@ -339,9 +312,7 @@
name="portal-wsrp-exploded.sar"/>
</target>
- <!-- ================================================================== -->
- <!-- Cleaning -->
- <!-- ================================================================== -->
+ <!-- ==================================================================
--><!-- Cleaning
--><!-- ================================================================== -->
<!-- Clean up all build output -->
<target name="clean" depends="_default:clean">
@@ -349,28 +320,20 @@
<!-- Add module specific elements here. -->
</target>
- <!--+====================================================================+-->
- <!--| Documents |-->
- <!--| |-->
- <!--| Generate all documentation for this module. |-->
- <!--+====================================================================+-->
+
<!--+====================================================================+--><!--|
Documents |--><!--|
|--><!--| Generate all
documentation for this module.
|--><!--+====================================================================+-->
<target name="docs" depends="_default:docs">
<!-- Add module specific elements here. -->
</target>
- <!-- ================================================================== -->
- <!-- Misc. -->
- <!-- ================================================================== -->
+ <!-- ==================================================================
--><!-- Misc.
--><!-- ================================================================== -->
<target name="main" depends="most"/>
<target name="all" depends="_default:all, explode"/>
<target name="most" depends="_default:most"/>
<target name="help" depends="_default:help"/>
- <!-- ================================================================== -->
- <!-- Deployment -->
- <!-- ================================================================== -->
+ <!-- ==================================================================
--><!-- Deployment
--><!-- ================================================================== -->
<!-- Deployment of test agent -->
<target name="agent-deploy" depends="init">
@@ -418,9 +381,7 @@
<undeploy file="${build.lib.test}/test-wsrp-consumer.sar"
config="default"/>
</target>
- <!-- ================================================================== -->
- <!-- Tests -->
- <!-- ================================================================== -->
+ <!-- ==================================================================
--><!-- Tests
--><!-- ================================================================== -->
<target name="package-deployment-test" description="Generates the
deployment test artifacts" depends="compile">
<jar jarfile="${build.lib.test}/test-deployment-lib.jar">
@@ -627,9 +588,11 @@
<!-- Resourceportlet test portlet -->
<package-test-portlet archiveName="resource"
portletName="Resource"/>
- <!-- Multipart test portlet -->
- <!--<package-test-portlet archiveName="multipart"
portletName="Multipart"/>-->
+ <!-- Non URL Encoded Resource test portlet -->
+ <package-test-portlet archiveName="resourcenoencodeurl"
portletName="ResourceNoEncodeURL"/>
+ <!-- Multipart test portlet --><!--<package-test-portlet
archiveName="multipart" portletName="Multipart"/>-->
+
<!-- Application scope test portlet -->
<jar
jarfile="${build.lib.test}/test-applicationscope-portlet.war">
<fileset
dir="${build.resources.test}/test-applicationscope-portlet-war"/>
@@ -646,9 +609,7 @@
description="Packages all the test-related artifacts. Does NOT compile
classes so this should be done before
calling this task."/>
- <!-- ================================================================== -->
- <!-- Tests -->
- <!-- ================================================================== -->
+ <!-- ==================================================================
--><!-- Tests
--><!-- ================================================================== -->
<target name="clean-test">
<!-- remove generated test xml files -->
@@ -887,6 +848,8 @@
<execute-tests>
<x-test>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.WSRPPortletURLTestCase"/>
+ <test todir="${test.reports}"
+
name="org.jboss.portal.test.wsrp.other.AbsoluteURLReplacementGeneratorTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.UserContextConverterTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.RegistrationPropertyDescriptionTestCase"/>
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockHttpServletRequest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockHttpServletRequest.java 2008-07-10
18:20:05 UTC (rev 11414)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockHttpServletRequest.java 2008-07-10
21:48:11 UTC (rev 11415)
@@ -41,6 +41,9 @@
private HttpSession session;
private Map attrs;
+ public static String scheme = "http";
+ public static String serverName = "test";
+ public static Integer serverPort = 1234;
public MockHttpServletRequest(HttpSession session)
{
@@ -89,7 +92,20 @@
{
String name = (String)args[0];
attrs.remove(name);
+ return null;
}
+ if ("getScheme".equals(methodName))
+ {
+ return scheme;
+ }
+ if ("getServerName".equals(methodName))
+ {
+ return serverName;
+ }
+ if ("getServerPort".equals(methodName))
+ {
+ return serverPort;
+ }
throw new UnsupportedOperationException("MockHttpServletRequest does not
support: " + method);
}
}
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/other/AbsoluteURLReplacementGeneratorTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/other/AbsoluteURLReplacementGeneratorTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/other/AbsoluteURLReplacementGeneratorTestCase.java 2008-07-10
21:48:11 UTC (rev 11415)
@@ -0,0 +1,71 @@
+/*
+* 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.wsrp.other;
+
+import junit.framework.TestCase;
+import org.jboss.portal.test.wsrp.framework.support.MockHttpServletRequest;
+import static org.jboss.portal.test.wsrp.framework.support.MockHttpServletRequest.*;
+import org.jboss.portal.wsrp.producer.AbsoluteURLReplacementGenerator;
+import static org.jboss.portal.wsrp.producer.AbsoluteURLReplacementGenerator.PORT_END;
+import static org.jboss.portal.wsrp.producer.AbsoluteURLReplacementGenerator.SCH_END;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Proxy;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class AbsoluteURLReplacementGeneratorTestCase extends TestCase
+{
+ private AbsoluteURLReplacementGenerator gen;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ MockHttpServletRequest mockRequest = new MockHttpServletRequest(null);
+ HttpServletRequest request =
(HttpServletRequest)Proxy.newProxyInstance(getClass().getClassLoader(),
+ new Class[]{HttpServletRequest.class}, mockRequest);
+ gen = new AbsoluteURLReplacementGenerator(request);
+ }
+
+ public void testNonAbsoluteURL()
+ {
+ String url = "foo";
+ assertEquals(url, gen.getAbsoluteURLFor(url));
+ }
+
+ public void testAbsoluteURL()
+ {
+ String url = "/foo";
+ assertEquals(scheme + SCH_END + serverName + PORT_END + serverPort + url,
gen.getAbsoluteURLFor(url));
+ }
+
+ public void testWSRPEncodedURL()
+ {
+ String url =
"wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState=JBPNS_/wsrp_rewrite";
+ assertEquals(url, gen.getAbsoluteURLFor(url));
+ }
+}
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ResourceNoEncodeURLPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ResourceNoEncodeURLPortlet.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ResourceNoEncodeURLPortlet.java 2008-07-10
21:48:11 UTC (rev 11415)
@@ -0,0 +1,44 @@
+/*
+* 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.wsrp.portlet;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ResourceNoEncodeURLPortlet extends GenericPortlet
+{
+ protected void doView(RenderRequest request, RenderResponse response) throws
PortletException, IOException
+ {
+ response.setContentType("text/html");
+ Writer writer = response.getWriter();
+ writer.write("<img src='" + request.getContextPath() +
"/gif/logo.gif'/>");
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2008-07-10
18:20:05 UTC (rev 11414)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2008-07-10
21:48:11 UTC (rev 11415)
@@ -60,7 +60,7 @@
private static final String DEFAULT_MARKUP_PORTLET_WAR =
"test-markup-portlet.war";
public MarkupTestCase()
- throws Exception
+ throws Exception
{
super("MarkupTestCase", DEFAULT_MARKUP_PORTLET_WAR);
}
@@ -115,8 +115,8 @@
MarkupResponse response = markupService.getMarkup(getMarkup);
checkMarkupResponse(response, "<form method='post'
action='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp" +
- "-interactionState=JBPNS_/wsrp_rewrite'
id='wsrp_rewrite_portfolioManager'><table><tr><td>Stock
symbol</t" +
- "d><td><input
name='symbol'/></td></tr><tr><td><input
type='submit'
value='Submit'></td></tr></table></form>");
+ "-interactionState=JBPNS_/wsrp_rewrite'
id='wsrp_rewrite_portfolioManager'><table><tr><td>Stock
symbol</t" +
+ "d><td><input
name='symbol'/></td></tr><tr><td><input
type='submit'
value='Submit'></td></tr></table></form>");
}
public void testGetMarkupRenderParameters() throws Exception
@@ -154,7 +154,7 @@
// let's see now if we can increment the counter
PerformBlockingInteraction performBlockingInteraction =
-
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
interactionParams.setInteractionState(incrementAction.getInteractionState().getStringValue());
markupService.performBlockingInteraction(performBlockingInteraction);
@@ -222,7 +222,7 @@
public void testPerformBlockingInteractionRedirect() throws Exception
{
PerformBlockingInteraction performBlockingInteraction =
- WSRPTypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
+
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
NamedString[] formParams = {new NamedString("symbol", "HELP")};
// crappy way but this is a test! ;)
interactionParams.setFormParameters(formParams);
@@ -389,7 +389,7 @@
MarkupResponse response = markupService.getMarkup(getMarkup);
checkMarkupResponse(response,
"wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState=JBPNS_/wsrp_rewrite\n"
+
-
"wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=JBPNS_/wsrp_rewrite");
+
"wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=JBPNS_/wsrp_rewrite");
}
finally
{
@@ -426,7 +426,7 @@
try
{
PerformBlockingInteraction action =
-
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
action.getInteractionParams().setFormParameters(new NamedString[]{new
NamedString("multi", "value1")});
BlockingInteractionResponse actionResponse =
markupService.performBlockingInteraction(action);
GetMarkup markupRequest = createMarkupRequestForCurrentlyDeployedPortlet();
@@ -435,7 +435,7 @@
checkMarkupResponse(response, "multi: value1");
action.getInteractionParams().setFormParameters(new NamedString[]{
- new NamedString("multi", "value1"), new
NamedString("multi", "value2")});
+ new NamedString("multi", "value1"), new
NamedString("multi", "value2")});
actionResponse = markupService.performBlockingInteraction(action);
markupRequest = createMarkupRequestForCurrentlyDeployedPortlet();
markupRequest.getMarkupParams().setNavigationalState(actionResponse.getUpdateResponse().getNavigationalState());
@@ -524,6 +524,32 @@
}
}
+ public void testGetMarkupWithNonURLEncodedResource() throws Exception
+ {
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
+ String archive = "test-resourcenoencodeurl-portlet.war";
+ deploy(archive);
+
+ try
+ {
+ GetMarkup gm = createMarkupRequestForCurrentlyDeployedPortlet();
+ MarkupResponse res = markupService.getMarkup(gm);
+ String markupString = res.getMarkupContext().getMarkupString();
+
+ // accept either localhost or 127.0.0.1 for the host part of the generated
markup
+ String markupStart = "<img src='http://";
+ String markupEnd =
":8080/test-resourcenoencodeurl-portlet/gif/logo.gif'/>";
+ String localhostMarkup = markupStart + "localhost" + markupEnd;
+ String homeIPMarkup = markupStart + "127.0.0.1" + markupEnd;
+ boolean result = localhostMarkup.equals(markupString) ||
homeIPMarkup.equals(markupString);
+ ExtendedAssert.assertTrue(result);
+ }
+ finally
+ {
+ undeploy(archive);
+ }
+ }
+
public void testApplicationScopeVariableHandling() throws Exception
{
undeploy(DEFAULT_MARKUP_PORTLET_WAR);
@@ -566,7 +592,7 @@
private String checkPBIAndGetNavigationalState(String symbol) throws Exception
{
PerformBlockingInteraction performBlockingInteraction =
- WSRPTypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
+
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getDefaultHandle());
InteractionParams interactionParams =
performBlockingInteraction.getInteractionParams();
NamedString[] formParams = {new NamedString("symbol", symbol)};
interactionParams.setFormParameters(formParams);
@@ -633,4 +659,4 @@
{
return DEFAULT_MARKUP_PORTLET_WAR;
}
-}
\ No newline at end of file
+}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java 2008-07-10
18:20:05 UTC (rev 11414)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/AbsoluteURLReplacementGenerator.java 2008-07-10
21:48:11 UTC (rev 11415)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.producer;
import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.wsrp.WSRPRewritingConstants;
import javax.servlet.http.HttpServletRequest;
@@ -33,8 +34,9 @@
public class AbsoluteURLReplacementGenerator extends URLTools.URLReplacementGenerator
{
private String serverAddress;
- static final String SCH_END = "://";
- static final String PORT_END = ":";
+ public static final String SCH_END = "://";
+ public static final String PORT_END = ":";
+ public static final String SLASH = "/";
public AbsoluteURLReplacementGenerator(HttpServletRequest request)
{
@@ -50,13 +52,32 @@
return getAbsoluteURLFor(urlMatch.getURLAsString());
}
+ /**
+ * todo: public only for tests
+ *
+ * @param url
+ * @return
+ */
public String getAbsoluteURLFor(String url)
{
- if (!URLTools.isNetworkURL(url))
+ return getAbsoluteURLFor(url, true);
+ }
+
+ String getAbsoluteURLFor(String url, boolean checkWSRPToken)
+ {
+ // We don't encode URL through this API when it is a wsrp URL
+ if (checkWSRPToken &&
url.startsWith(WSRPRewritingConstants.BEGIN_WSRP_REWRITE))
{
+ return url;
+ }
+
+ if (!URLTools.isNetworkURL(url) && url.startsWith(SLASH))
+ {
return serverAddress + url;
}
-
- return url;
+ else
+ {
+ return url;
+ }
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java 2008-07-10
18:20:05 UTC (rev 11414)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPPortletInvocationContext.java 2008-07-10
21:48:11 UTC (rev 11415)
@@ -100,33 +100,25 @@
/** Override the default behavior in order to avoid to encode when it is producer
written URL. */
public String encodeResourceURL(String url)
{
- if (url != null)
+ if (url != null &&
!url.startsWith(WSRPRewritingConstants.BEGIN_WSRP_REWRITE))
{
- if (url.startsWith(WSRPRewritingConstants.BEGIN_WSRP_REWRITE))
- {
- // We don't encode URL through this API when it is a wsrp URL
- return url;
- }
- else
- {
- // make root relative URLs absolute
- url = new
AbsoluteURLReplacementGenerator(getClientRequest()).getAbsoluteURLFor(url);
+ // make root relative URLs absolute. Optimization: we don't recheck the
precense of the WSRP token.
+ url = new
AbsoluteURLReplacementGenerator(getClientRequest()).getAbsoluteURLFor(url, false);
- // properly encode the URL
- url = URLTools.encodeXWWWFormURL(url);
+ // properly encode the URL
+ url = URLTools.encodeXWWWFormURL(url);
- // build the WSRP resource URL with rewrite tokens
- StringBuffer sb = new StringBuffer(url.length() * 2);
-
sb.append(WSRPRewritingConstants.BEGIN_WSRP_REWRITE).append(WSRPRewritingConstants.URL_TYPE_NAME)
-
.append(EQ).append(WSRPRewritingConstants.URL_TYPE_RESOURCE).append(AMP)
- .append(WSRPRewritingConstants.RESOURCE_URL).append(EQ).append(url)
-
.append(AMP).append(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE)
- .append(EQ_TRUE).append(WSRPRewritingConstants.END_WSRP_REWRITE);
- return sb.toString();
- }
+ // build the WSRP resource URL with rewrite tokens
+ StringBuffer sb = new StringBuffer(url.length() * 2);
+
sb.append(WSRPRewritingConstants.BEGIN_WSRP_REWRITE).append(WSRPRewritingConstants.URL_TYPE_NAME)
+
.append(EQ).append(WSRPRewritingConstants.URL_TYPE_RESOURCE).append(AMP)
+ .append(WSRPRewritingConstants.RESOURCE_URL).append(EQ).append(url)
+ .append(AMP).append(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE)
+ .append(EQ_TRUE).append(WSRPRewritingConstants.END_WSRP_REWRITE);
+ return sb.toString();
}
- return null;
+ return url;
}
/**
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/jboss-portlet.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/jboss-portlet.xml
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/jboss-portlet.xml 2008-07-10
21:48:11 UTC (rev 11415)
@@ -0,0 +1,28 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2007, 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>
+ <portlet>
+ <portlet-name>Resource Non URL Encoded Test Portlet</portlet-name>
+ <remotable>true</remotable>
+ </portlet>
+</portlet-app>
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/portlet.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/portlet.xml
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/portlet.xml 2008-07-10
21:48:11 UTC (rev 11415)
@@ -0,0 +1,42 @@
+<?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...
version="1.0">
+ <portlet>
+ <portlet-name>Resource Non URL Encoded Test Portlet</portlet-name>
+
<portlet-class>org.jboss.portal.test.wsrp.portlet.ResourceNoEncodeURLPortlet</portlet-class>
+
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>view</portlet-mode>
+ </supports>
+
+ <portlet-info>
+ <title>Non URL Encoded Resource Test</title>
+ </portlet-info>
+ </portlet>
+
+</portlet-app>
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/web.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/web.xml
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/WEB-INF/web.xml 2008-07-10
21:48:11 UTC (rev 11415)
@@ -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>
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/gif/logo.gif
===================================================================
(Binary files differ)
Property changes on:
branches/JBoss_Portal_Branch_2_6/wsrp/src/resources/tests/test-resourcenoencodeurl-portlet-war/gif/logo.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream