Author: chris.laprun(a)jboss.com
Date: 2009-02-10 07:39:07 -0500 (Tue, 10 Feb 2009)
New Revision: 12803
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
Log:
- JBPORTAL-2306: Fixed WSRPPortletURL.toString() method to properly add WSRP end rewriting
token.
- Added test case.
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java 2009-02-09
20:56:52 UTC (rev 12802)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java 2009-02-10
12:39:07 UTC (rev 12803)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -51,7 +51,7 @@
public void testResource()
{
String expected =
"wsrp_rewrite?wsrp-urlType=resource&wsrp-url=http%3A%2F%2Ftest.com%2Fimages%2Ftest.gif"
+
- "&wsrp-requiresRewrite=true/wsrp_rewrite";
+ "&wsrp-requiresRewrite=true/wsrp_rewrite";
WSRPPortletURL url = WSRPPortletURL.create(expected);
assertEquals("http://test.com/images/test.gif", url.toString());
@@ -61,7 +61,7 @@
public void testSecureInteraction()
{
String expected =
"wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-secureURL=true" +
-
"&wsrp-navigationalState=a8h4K5JD9&wsrp-interactionState=fg4h923mdk/wsrp_rewrite";
+
"&wsrp-navigationalState=a8h4K5JD9&wsrp-interactionState=fg4h923mdk/wsrp_rewrite";
WSRPPortletURL url = WSRPPortletURL.create(expected);
assertTrue(url instanceof WSRPActionURL);
@@ -195,25 +195,27 @@
checkInvalidURL(invalid, "Should have detected invalid URL: ",
"invalidURL");
}
- private void checkInvalidURL(String invalid, String message, String
mustBeInException)
+ public void testNullURL()
{
try
{
- WSRPPortletURL.create(invalid);
- fail(message + mustBeInException);
+ WSRPPortletURL.create(null);
+ fail("Should have detected null URL");
}
catch (IllegalArgumentException e)
{
- assertTrue(e.getLocalizedMessage().contains(mustBeInException));
+ // expected
}
}
- public void testNullURL()
+ public void testInvalidURLType()
{
+ String wrongURLType =
"wsrp_rewrite?wsrp-urlType=pipo&wsrp-mode=help/wsrp_rewrite";
+
try
{
- WSRPPortletURL.create(null);
- fail("Should have detected null URL");
+ WSRPPortletURL.create(wrongURLType);
+ fail("Should have detected wrong URL type");
}
catch (IllegalArgumentException e)
{
@@ -221,18 +223,36 @@
}
}
- public void testInvalidURLType()
+ public void testProperEndTokenInRelaxedMode()
{
- String wrongURLType =
"wsrp_rewrite?wsrp-urlType=pipo&wsrp-mode=help/wsrp_rewrite";
+ WSRPPortletURL.setStrict(false);
+ WSRPPortletURL url = new WSRPPortletURL()
+ {
+ @Override
+ protected String getURLType()
+ {
+ return WSRPRewritingConstants.URL_TYPE_BLOCKING_ACTION;
+ }
+
+ @Override
+ protected void appendEnd(StringBuffer sb)
+ {
+ }
+ };
+ assertTrue(url.toString().contains(WSRPRewritingConstants.END_WSRP_REWRITE));
+ }
+
+ private void checkInvalidURL(String invalid, String message, String
mustBeInException)
+ {
try
{
- WSRPPortletURL.create(wrongURLType);
- fail("Should have detected wrong URL type");
+ WSRPPortletURL.create(invalid);
+ fail(message + mustBeInException);
}
catch (IllegalArgumentException e)
{
- // expected
+ assertTrue(e.getLocalizedMessage().contains(mustBeInException));
}
}
}
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java 2009-02-09
20:56:52 UTC (rev 12802)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java 2009-02-10
12:39:07 UTC (rev 12803)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -20,6 +20,7 @@
* 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.wsrp;
import org.jboss.portal.Mode;
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2009-02-09
20:56:52 UTC (rev 12802)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2009-02-10
12:39:07 UTC (rev 12803)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -369,19 +369,15 @@
else
{
// we're in relaxed mode so we need to deal with extra params if they exist
- StringBuffer extras = null;
if (extraParams != null && !extraParams.isEmpty())
{
- extras = new StringBuffer();
+ StringBuffer extras = new StringBuffer();
for (Map.Entry<String, String> entry : extraParams.entrySet())
{
createURLParameter(extras, entry.getKey(), entry.getValue());
}
- }
- // if we had extra params, we need to figure out where thwy should be positioned
wrt end token
- if (extras != null)
- {
+ // if we had extra params, we need to figure out where thwy should be
positioned wrt end token
if (extraParamsAfterEndToken)
{
sb.append(WSRPRewritingConstants.END_WSRP_REWRITE);
@@ -393,6 +389,10 @@
sb.append(WSRPRewritingConstants.END_WSRP_REWRITE);
}
}
+ else
+ {
+ sb.append(WSRPRewritingConstants.END_WSRP_REWRITE);
+ }
}
return sb.toString();
}