Author: mmillson
Date: 2008-03-18 21:11:08 -0400 (Tue, 18 Mar 2008)
New Revision: 10323
Modified:
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-1956/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-1956/portlet/src/main/org/jboss/portal/test/portlet/ParametersTestCase.java
Log:
Fix Portal navigational state replication for [JBPORTAL-1956].
Modified:
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-1956/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java
===================================================================
---
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-1956/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java 2008-03-19
01:02:18 UTC (rev 10322)
+++
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-1956/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java 2008-03-19
01:11:08 UTC (rev 10323)
@@ -25,6 +25,9 @@
import org.jboss.portal.common.util.ParameterMap;
import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -149,4 +152,26 @@
return new PortletParameters(map);
}
}
+
+ private void writeObject(ObjectOutputStream out) throws IOException
+ {
+ out.writeInt(size());
+ for (Iterator i = entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Entry)i.next();
+ out.writeObject(entry.getKey());
+ out.writeObject(entry.getValue());
+ }
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException
+ {
+ int size = in.readInt();
+ while (size-- > 0)
+ {
+ String key = (String)in.readObject();
+ String[] values = (String[])in.readObject();
+ put(key, values);
+ }
+ }
}
Modified:
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-1956/portlet/src/main/org/jboss/portal/test/portlet/ParametersTestCase.java
===================================================================
---
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-1956/portlet/src/main/org/jboss/portal/test/portlet/ParametersTestCase.java 2008-03-19
01:02:18 UTC (rev 10322)
+++
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-1956/portlet/src/main/org/jboss/portal/test/portlet/ParametersTestCase.java 2008-03-19
01:11:08 UTC (rev 10323)
@@ -23,11 +23,15 @@
package org.jboss.portal.test.portlet;
import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.portlet.PortletParameters;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import java.util.Collections;
+import java.util.Set;
+import java.io.IOException;
import junit.framework.TestCase;
@@ -300,6 +304,17 @@
assertNull(param.getValue("a"));
}
+ public void testSerialization() throws IOException
+ {
+ param.setValue("foo", "bar");
+ PortletParameters clone = (PortletParameters)IOTools.clone(param);
+ assertNotNull(clone);
+ Set keys = clone.keySet();
+ assertEquals(1, keys.size());
+ assertTrue(keys.contains("foo"));
+ assertEquals("bar", clone.getValue("foo"));
+ }
+
public Class[] buildExceptionClasses()
{
return new Class[]