[jboss-svn-commits] JBoss Portal SVN: r5473 - in trunk/wsrp: . src/main/org/jboss/portal/test/wsrp src/main/org/jboss/portal/test/wsrp/other

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Oct 17 13:02:28 EDT 2006


Author: chris.laprun at jboss.com
Date: 2006-10-17 13:02:25 -0400 (Tue, 17 Oct 2006)
New Revision: 5473

Added:
   trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/
   trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
   trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java
Removed:
   trunk/wsrp/src/main/org/jboss/portal/test/wsrp/ProducerSessionInformationTestCase.java
   trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPPortletURLTest.java
Modified:
   trunk/wsrp/build.xml
Log:
- Moved other tests to other sub-directory
- Updated build to adapt to the new structure and to include tests that weren't run.

Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml	2006-10-17 00:12:37 UTC (rev 5472)
+++ trunk/wsrp/build.xml	2006-10-17 17:02:25 UTC (rev 5473)
@@ -343,7 +343,8 @@
    <target name="package-other-test" description="Generates the test artifacts" depends="compile">
       <jar jarfile="${build.lib.test}/test-other-lib.jar">
           <fileset dir="${build.classes}/">
-             <include name="org/jboss/portal/test/wsrp/*TestCase.class"/>
+             <include name="org/jboss/portal/test/wsrp/other/*TestCase.class"/>
+             <include name="org/jboss/portal/test/wsrp/handler/*.class"/>
           </fileset>
       </jar>
    </target>
@@ -518,7 +519,7 @@
             <jvmarg value="-Xdebug"/>
             <jvmarg value="-Xnoagent"/>
             <jvmarg value="-Djava.compiler=NONE"/>
-            <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787"/>
+            <!--<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787"/>-->
             <sysproperty key="test.root" value="${build.lib}"/>
          </x-sysproperty>
          <x-classpath>
@@ -543,7 +544,7 @@
             <jvmarg value="-Xdebug"/>
             <jvmarg value="-Xnoagent"/>
             <jvmarg value="-Djava.compiler=NONE"/>
-            <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787"/>
+            <!--<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787"/>-->
             <sysproperty key="test.root" value="${build.lib}"/>
          </x-sysproperty>
          <x-classpath>
@@ -567,7 +568,7 @@
             <jvmarg value="-Xdebug"/>
             <jvmarg value="-Xnoagent"/>
             <jvmarg value="-Djava.compiler=NONE"/>
-            <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787"/>
+            <!--<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787"/>-->
             <sysproperty key="test.root" value="${build.lib}"/>
          </x-sysproperty>
          <x-classpath>
@@ -585,7 +586,9 @@
    <target name="other-test" depends="package-other-test">
       <execute-tests>
          <x-test>
-            <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.ProducerSessionInformationTestCase"/>
+            <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.ProducerSessionInformationTestCase"/>
+            <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.WSRPPortletURLTestCase"/>
+            <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>
          </x-test>
          <x-sysproperty>
             <sysproperty key="test.root" value="${build.lib}"/>

Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/ProducerSessionInformationTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/ProducerSessionInformationTestCase.java	2006-10-17 00:12:37 UTC (rev 5472)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/ProducerSessionInformationTestCase.java	2006-10-17 17:02:25 UTC (rev 5473)
@@ -1,157 +0,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.                   *
- ******************************************************************************/
-
-package org.jboss.portal.test.wsrp;
-
-import junit.framework.TestCase;
-import org.apache.commons.httpclient.Cookie;
-import org.jboss.portal.wsrp.WSRPConstants;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.ProducerSessionInformationTestCase">Chris
- *         Laprun</a>
- * @version $Revision$
- * @since 2.4
- */
-public class ProducerSessionInformationTestCase extends TestCase
-{
-   ProducerSessionInformation info;
-
-   protected void setUp() throws Exception
-   {
-      info = new ProducerSessionInformation();
-   }
-
-   public void testUserCookie() throws Exception
-   {
-      assertNull(info.getUserCookie());
-
-      Cookie[] cookies = new Cookie[]{createCookie("name", "value", 1)};
-      info.setUserCookie(cookies);
-
-      assertEquals("name=value", info.getUserCookie());
-
-      // wait for cookie expiration
-      Thread.sleep(1000);
-      assertNull(info.getUserCookie()); // we shouldn't have a cookie now
-
-      cookies = new Cookie[]{createCookie("name1", "value1", 1), createCookie("name2", "value2", 3)};
-      info.setUserCookie(cookies);
-      assertEquals("name1=value1;name2=value2", info.getUserCookie());
-
-      Thread.sleep(1000);
-      assertEquals("name2=value2", info.getUserCookie());
-
-      try
-      {
-         info.setUserCookie(null);
-         fail("Should have thrown an IllegalArgumentException");
-      }
-      catch (IllegalArgumentException e)
-      {
-         //expected
-      }
-   }
-
-   public void testGroupCookies() throws Exception
-   {
-      String groupId = "groupId";
-
-      try
-      {
-         info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1", "value1", 1), createCookie("name2", "value2", -1)});
-         fail("Cannot add group cookie if not perGroup");
-      }
-      catch (IllegalStateException e)
-      {
-         //expected
-      }
-
-      info.setPerGroupCookies(true);
-      info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1", "value1", 1),
-         createCookie("name2", "value2", WSRPConstants.SESSION_NEVER_EXPIRES)});
-
-      assertEquals("name1=value1;name2=value2", info.getGroupCookieFor(groupId));
-
-      Thread.sleep(1000);
-      assertEquals("name2=value2", info.getGroupCookieFor(groupId));
-
-      info.clearGroupCookies();
-      assertNull(info.getGroupCookieFor(groupId));
-   }
-
-   public void testSessionForPortlet() throws Exception
-   {
-      String handle = "handle";
-      String handle2 = "handle2";
-      String sid = "id";
-      String sid2 = "id2";
-
-      assertNull(info.getSessionIdForPortlet(handle));
-      assertEquals(0, info.getNumberOfSessions());
-
-      info.addSessionForPortlet(handle, WSRPTypeFactory.createSessionContext(sid, 1));
-      info.addSessionForPortlet(handle2, WSRPTypeFactory.createSessionContext(sid2, 3));
-
-      assertNull(info.getSessionIdForPortlet("unknown"));
-
-      assertEquals(sid, info.getSessionIdForPortlet(handle));
-      assertEquals(2, info.getNumberOfSessions());
-
-      Thread.sleep(1000);
-      assertNull(info.getSessionIdForPortlet(handle));
-      assertEquals(sid2, info.getSessionIdForPortlet(handle2));
-      assertEquals(1, info.getNumberOfSessions());
-
-      info.removeSessionIdForPortlet(handle2);
-      assertEquals(0, info.getNumberOfSessions());
-   }
-
-   public void testReplaceUserCookies() throws Exception
-   {
-      info.setUserCookie(new Cookie[]{createCookie("name", "value", 1)});
-
-      info.replaceUserCookiesWith(null);
-      assertEquals("name=value", info.getUserCookie());
-
-      ProducerSessionInformation other = new ProducerSessionInformation();
-
-      info.replaceUserCookiesWith(other);
-      assertEquals("name=value", info.getUserCookie());
-
-      other.setUserCookie(new Cookie[]{createCookie("name2", "value2", 1)});
-      info.replaceUserCookiesWith(other);
-      assertEquals("name2=value2", info.getUserCookie());
-
-      Thread.sleep(1000);
-      info.replaceUserCookiesWith(other);
-      assertNull(info.getUserCookie());
-   }
-
-   private Cookie createCookie(String name, String value, int secondsBeforeExpiration)
-   {
-      return new Cookie("domain", name, value, "path", secondsBeforeExpiration, false);
-   }
-}

Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPPortletURLTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPPortletURLTest.java	2006-10-17 00:12:37 UTC (rev 5472)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPPortletURLTest.java	2006-10-17 17:02:25 UTC (rev 5473)
@@ -1,102 +0,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.                   *
- ******************************************************************************/
-
-package org.jboss.portal.test.wsrp;
-
-import junit.framework.TestCase;
-import org.jboss.portal.wsrp.WSRPActionURL;
-import org.jboss.portal.wsrp.WSRPPortletURL;
-import org.jboss.portal.wsrp.WSRPRenderURL;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.4 (Apr 28, 2006)
- */
-public class WSRPPortletURLTest extends TestCase
-{
-   /** Load a resource http://test.com/images/test.gif */
-   public void testResource()
-   {
-      // julien : cannot be tested properly for now
-
-//      String expected = "wsrp_rewrite?wsrp-urlType=resource&amp;wsrp-url=http%3A%2F%2Ftest.com%2Fimages%2Ftest.gif" +
-//         "&amp;wsrp-requiresRewrite=true/wsrp_rewrite";
-//      WSRPPortletURL url = WSRPPortletURL.create(expected);
-//
-//      assertEquals(WSRPRewritingConstants.URL_TYPE_RESOURCE, url.getURLType());
-//      assertEquals("http%3A%2F%2Ftest.com%2Fimages%2Ftest.gif", url.getRawParameterValueFor(WSRPRewritingConstants.RESOURCE_URL));
-//      assertEquals("true", url.getRawParameterValueFor(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE));
-   }
-
-   /** Declare a secure interaction back to the Portlet */
-   public void testSecureInteraction()
-   {
-      String expected = "wsrp_rewrite?wsrp-urlType=blockingAction&amp;wsrp-secureURL=true" +
-         "&amp;wsrp-navigationalState=a8h4K5JD9&amp;wsrp-interactionState=fg4h923mdk/wsrp_rewrite";
-      WSRPPortletURL url = WSRPPortletURL.create(expected);
-
-      assertTrue(url instanceof WSRPActionURL);
-      WSRPActionURL actionURL = (WSRPActionURL)url;
-      assertTrue(url.isSecure());
-      assertEquals("a8h4K5JD9", actionURL.getNavigationalState().getStringValue());
-      assertEquals("fg4h923mdk", actionURL.getInteractionState().getStringValue());
-   }
-
-   /** Request the Consumer render the Portlet in a different mode and window state */
-   public void testDifferentModeAndWindowState()
-   {
-      String expected = "wsrp_rewrite?wsrp-urlType=render&amp;wsrp-mode=help&amp;wsrp-windowState=maximized/wsrp_rewrite";
-      WSRPPortletURL url = WSRPPortletURL.create(expected);
-
-      assertTrue(url instanceof WSRPRenderURL);
-      assertEquals("help", url.getMode().toString());
-      assertEquals("maximized", url.getWindowState().toString());
-   }
-
-   public void testMinimal()
-   {
-      String minimalURLType = "wsrp_rewrite?wsrp-urlType=render/wsrp_rewrite";
-      WSRPPortletURL url = WSRPPortletURL.create(minimalURLType);
-
-      assertTrue(url instanceof WSRPRenderURL);
-   }
-
-   public void testRobustness()
-   {
-      String wrongURLType = "wsrp_rewrite?wsrp-urlType=pipo&amp;wsrp-mode=help/wsrp_rewrite";
-
-      try
-      {
-         WSRPPortletURL url = WSRPPortletURL.create(wrongURLType);
-         fail("Should have detected wrong URL type");
-
-         url = WSRPPortletURL.create(null);
-         fail("Should have detected null URL");
-      }
-      catch (IllegalArgumentException e)
-      {
-         // expected
-      }
-   }
-}

Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java (from rev 5472, trunk/wsrp/src/main/org/jboss/portal/test/wsrp/ProducerSessionInformationTestCase.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/ProducerSessionInformationTestCase.java	2006-10-17 00:12:37 UTC (rev 5472)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java	2006-10-17 17:02:25 UTC (rev 5473)
@@ -0,0 +1,157 @@
+/******************************************************************************
+ * 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.other;
+
+import junit.framework.TestCase;
+import org.apache.commons.httpclient.Cookie;
+import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.other.ProducerSessionInformationTestCase">Chris
+ *         Laprun</a>
+ * @version $Revision$
+ * @since 2.4
+ */
+public class ProducerSessionInformationTestCase extends TestCase
+{
+   ProducerSessionInformation info;
+
+   protected void setUp() throws Exception
+   {
+      info = new ProducerSessionInformation();
+   }
+
+   public void testUserCookie() throws Exception
+   {
+      assertNull(info.getUserCookie());
+
+      Cookie[] cookies = new Cookie[]{createCookie("name", "value", 1)};
+      info.setUserCookie(cookies);
+
+      assertEquals("name=value", info.getUserCookie());
+
+      // wait for cookie expiration
+      Thread.sleep(1000);
+      assertNull(info.getUserCookie()); // we shouldn't have a cookie now
+
+      cookies = new Cookie[]{createCookie("name1", "value1", 1), createCookie("name2", "value2", 3)};
+      info.setUserCookie(cookies);
+      assertEquals("name1=value1;name2=value2", info.getUserCookie());
+
+      Thread.sleep(1000);
+      assertEquals("name2=value2", info.getUserCookie());
+
+      try
+      {
+         info.setUserCookie(null);
+         fail("Should have thrown an IllegalArgumentException");
+      }
+      catch (IllegalArgumentException e)
+      {
+         //expected
+      }
+   }
+
+   public void testGroupCookies() throws Exception
+   {
+      String groupId = "groupId";
+
+      try
+      {
+         info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1", "value1", 1), createCookie("name2", "value2", -1)});
+         fail("Cannot add group cookie if not perGroup");
+      }
+      catch (IllegalStateException e)
+      {
+         //expected
+      }
+
+      info.setPerGroupCookies(true);
+      info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1", "value1", 1),
+         createCookie("name2", "value2", WSRPConstants.SESSION_NEVER_EXPIRES)});
+
+      assertEquals("name1=value1;name2=value2", info.getGroupCookieFor(groupId));
+
+      Thread.sleep(1000);
+      assertEquals("name2=value2", info.getGroupCookieFor(groupId));
+
+      info.clearGroupCookies();
+      assertNull(info.getGroupCookieFor(groupId));
+   }
+
+   public void testSessionForPortlet() throws Exception
+   {
+      String handle = "handle";
+      String handle2 = "handle2";
+      String sid = "id";
+      String sid2 = "id2";
+
+      assertNull(info.getSessionIdForPortlet(handle));
+      assertEquals(0, info.getNumberOfSessions());
+
+      info.addSessionForPortlet(handle, WSRPTypeFactory.createSessionContext(sid, 1));
+      info.addSessionForPortlet(handle2, WSRPTypeFactory.createSessionContext(sid2, 3));
+
+      assertNull(info.getSessionIdForPortlet("unknown"));
+
+      assertEquals(sid, info.getSessionIdForPortlet(handle));
+      assertEquals(2, info.getNumberOfSessions());
+
+      Thread.sleep(1000);
+      assertNull(info.getSessionIdForPortlet(handle));
+      assertEquals(sid2, info.getSessionIdForPortlet(handle2));
+      assertEquals(1, info.getNumberOfSessions());
+
+      info.removeSessionIdForPortlet(handle2);
+      assertEquals(0, info.getNumberOfSessions());
+   }
+
+   public void testReplaceUserCookies() throws Exception
+   {
+      info.setUserCookie(new Cookie[]{createCookie("name", "value", 1)});
+
+      info.replaceUserCookiesWith(null);
+      assertEquals("name=value", info.getUserCookie());
+
+      ProducerSessionInformation other = new ProducerSessionInformation();
+
+      info.replaceUserCookiesWith(other);
+      assertEquals("name=value", info.getUserCookie());
+
+      other.setUserCookie(new Cookie[]{createCookie("name2", "value2", 1)});
+      info.replaceUserCookiesWith(other);
+      assertEquals("name2=value2", info.getUserCookie());
+
+      Thread.sleep(1000);
+      info.replaceUserCookiesWith(other);
+      assertNull(info.getUserCookie());
+   }
+
+   private Cookie createCookie(String name, String value, int secondsBeforeExpiration)
+   {
+      return new Cookie("domain", name, value, "path", secondsBeforeExpiration, false);
+   }
+}


Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java (from rev 5472, trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPPortletURLTest.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPPortletURLTest.java	2006-10-17 00:12:37 UTC (rev 5472)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java	2006-10-17 17:02:25 UTC (rev 5473)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * 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.other;
+
+import junit.framework.TestCase;
+import org.jboss.portal.wsrp.WSRPActionURL;
+import org.jboss.portal.wsrp.WSRPPortletURL;
+import org.jboss.portal.wsrp.WSRPRenderURL;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.4 (Apr 28, 2006)
+ */
+public class WSRPPortletURLTestCase extends TestCase
+{
+   /** Load a resource http://test.com/images/test.gif */
+   public void testResource()
+   {
+      // julien : cannot be tested properly for now
+
+//      String expected = "wsrp_rewrite?wsrp-urlType=resource&amp;wsrp-url=http%3A%2F%2Ftest.com%2Fimages%2Ftest.gif" +
+//         "&amp;wsrp-requiresRewrite=true/wsrp_rewrite";
+//      WSRPPortletURL url = WSRPPortletURL.create(expected);
+//
+//      assertEquals(WSRPRewritingConstants.URL_TYPE_RESOURCE, url.getURLType());
+//      assertEquals("http%3A%2F%2Ftest.com%2Fimages%2Ftest.gif", url.getRawParameterValueFor(WSRPRewritingConstants.RESOURCE_URL));
+//      assertEquals("true", url.getRawParameterValueFor(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE));
+   }
+
+   /** Declare a secure interaction back to the Portlet */
+   public void testSecureInteraction()
+   {
+      String expected = "wsrp_rewrite?wsrp-urlType=blockingAction&amp;wsrp-secureURL=true" +
+         "&amp;wsrp-navigationalState=a8h4K5JD9&amp;wsrp-interactionState=fg4h923mdk/wsrp_rewrite";
+      WSRPPortletURL url = WSRPPortletURL.create(expected);
+
+      assertTrue(url instanceof WSRPActionURL);
+      WSRPActionURL actionURL = (WSRPActionURL)url;
+      assertTrue(url.isSecure());
+      assertEquals("a8h4K5JD9", actionURL.getNavigationalState().getStringValue());
+      assertEquals("fg4h923mdk", actionURL.getInteractionState().getStringValue());
+   }
+
+   /** Request the Consumer render the Portlet in a different mode and window state */
+   public void testDifferentModeAndWindowState()
+   {
+      String expected = "wsrp_rewrite?wsrp-urlType=render&amp;wsrp-mode=help&amp;wsrp-windowState=maximized/wsrp_rewrite";
+      WSRPPortletURL url = WSRPPortletURL.create(expected);
+
+      assertTrue(url instanceof WSRPRenderURL);
+      assertEquals("help", url.getMode().toString());
+      assertEquals("maximized", url.getWindowState().toString());
+   }
+
+   public void testMinimal()
+   {
+      String minimalURLType = "wsrp_rewrite?wsrp-urlType=render/wsrp_rewrite";
+      WSRPPortletURL url = WSRPPortletURL.create(minimalURLType);
+
+      assertTrue(url instanceof WSRPRenderURL);
+   }
+
+   public void testRobustness()
+   {
+      String wrongURLType = "wsrp_rewrite?wsrp-urlType=pipo&amp;wsrp-mode=help/wsrp_rewrite";
+
+      try
+      {
+         WSRPPortletURL url = WSRPPortletURL.create(wrongURLType);
+         fail("Should have detected wrong URL type");
+
+         url = WSRPPortletURL.create(null);
+         fail("Should have detected null URL");
+      }
+      catch (IllegalArgumentException e)
+      {
+         // expected
+      }
+   }
+}


Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list