Author: julien(a)jboss.com
Date: 2008-02-09 07:14:27 -0500 (Sat, 09 Feb 2008)
New Revision: 9888
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalStateSerialization.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/WindowNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java
Log:
extract page navigational state serialization for better reusability
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-09
12:08:11 UTC (rev 9887)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-09
12:14:27 UTC (rev 9888)
@@ -43,7 +43,7 @@
class PageNavigationalStateImpl implements PageNavigationalState, Serializable
{
- /** We don't save it. */
+ /** . */
protected final StateControllerContextImpl context;
/** . */
@@ -116,6 +116,11 @@
return publicNavigationalState;
}
+ public Set<QName> getPublicNames()
+ {
+ return page.keySet();
+ }
+
public String[] getPublicNavigationalState(QName name)
{
return page.get(name).clone();
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-09
12:08:11 UTC (rev 9887)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-09
12:14:27 UTC (rev 9888)
@@ -25,24 +25,7 @@
import org.jboss.portal.portlet.controller.PortletControllerContext;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.StateControllerContext;
-import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.ParametersStateString;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
-import org.jboss.portal.common.io.UndeclaredIOException;
-import javax.xml.namespace.QName;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.DataOutputStream;
-import java.io.DataInputStream;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-import java.util.Map;
-import java.util.HashMap;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
@@ -50,35 +33,8 @@
public class StateControllerContextImpl implements StateControllerContext
{
- /** . */
- private static final Map<WindowState, Integer> windowStateToCode = new
HashMap<WindowState, Integer>();
/** . */
- private static final Map<Mode, Integer> modeToCode = new HashMap<Mode,
Integer>();
-
- /** . */
- private static final Map<Integer, WindowState> codeToWindowState = new
HashMap<Integer, WindowState>();
-
- /** . */
- private static final Map<Integer, Mode> codeToMode = new HashMap<Integer,
Mode>();
-
- static
- {
- windowStateToCode.put(WindowState.NORMAL, 1);
- windowStateToCode.put(WindowState.MINIMIZED, 2);
- windowStateToCode.put(WindowState.MAXIMIZED, 3);
- codeToWindowState.put(1, WindowState.NORMAL);
- codeToWindowState.put(2, WindowState.MINIMIZED);
- codeToWindowState.put(3, WindowState.MAXIMIZED);
- modeToCode.put(Mode.VIEW, 1);
- modeToCode.put(Mode.EDIT, 2);
- modeToCode.put(Mode.HELP, 3);
- codeToMode.put(1, Mode.VIEW);
- codeToMode.put(2, Mode.EDIT);
- codeToMode.put(3, Mode.HELP);
- }
-
- /** . */
protected final PortletControllerContext portletControllerContext;
public StateControllerContextImpl(PortletControllerContext portletControllerContext)
@@ -101,167 +57,4 @@
{
return new PageNavigationalStateImpl(this, modifiable);
}
-
- public byte[] serialize(PageNavigationalState object)
- {
- try
- {
- PageNavigationalStateImpl pageState = (PageNavigationalStateImpl)object;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream zos = new GZIPOutputStream(baos);
- DataOutputStream out = new DataOutputStream(zos);
-
- //
- out.writeInt(pageState.windows.size());
- for (Map.Entry<String, WindowNavigationalState> entry :
pageState.windows.entrySet())
- {
- out.writeUTF(entry.getKey());
- WindowNavigationalState windowNS = entry.getValue();
- byte header = 0;
- int decision = 0;
- if (windowNS.getPortletNavigationalState() != null)
- {
- header |= 1;
- decision |= 1;
- }
- if (windowNS.getWindowState() != null)
- {
- Integer value = windowStateToCode.get(windowNS.getWindowState());
- if (value != null)
- {
- header |= value << 1;
- }
- else
- {
- header |= 4 << 1;
- decision |= 2;
- }
- }
- if (windowNS.getMode() != null)
- {
- Integer value = modeToCode.get(windowNS.getMode());
- if (value != null)
- {
- header |= value << 4;
- }
- else
- {
- header |= 4 << 4;
- decision |= 4;
- }
- }
- out.writeByte(header);
- if ((decision & 1) != 0)
- {
- windowNS.getPortletNavigationalState().writeTo(out);
- }
- if ((decision & 2) != 0)
- {
- out.writeUTF(windowNS.getWindowState().toString());
- }
- if ((decision & 4) != 0)
- {
- out.writeUTF(windowNS.getMode().toString());
- }
- }
-
- //
- Map<QName, String[]> publicNS = pageState.page;
- out.writeInt(publicNS.size());
- for (Map.Entry<QName, String[]> entry : publicNS.entrySet())
- {
- QName name = entry.getKey();
- out.writeUTF(name.getNamespaceURI());
- out.writeUTF(name.getLocalPart());
- String[] values = entry.getValue();
- int length = values.length;
- out.writeInt(length);
- for (String value : values)
- {
- out.writeUTF(value);
- }
- }
-
- //
- out.close();
- return baos.toByteArray();
- }
- catch (IOException e)
- {
- throw new UndeclaredIOException(e);
- }
- }
-
- public PageNavigationalState unserialize(byte[] bytes, boolean modifiable)
- {
- try
- {
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- GZIPInputStream zis = new GZIPInputStream(bais);
- DataInputStream in = new DataInputStream(zis);
- PageNavigationalStateImpl pageState = new PageNavigationalStateImpl(this,
modifiable);
-
- //
- int size = in.readInt();
- while (size-- > 0)
- {
- String windowId = in.readUTF();
- byte header = in.readByte();
- StateString portletNS = null;
- if ((header & 1) != 0)
- {
- portletNS = ParametersStateString.create(in);
- }
- WindowState windowState = null;
- int windowStateHeader = (header & (7 << 1)) >> 1;
- switch (windowStateHeader)
- {
- case 0:
- break;
- case 4:
- windowState = WindowState.create(in.readUTF());
- break;
- default:
- windowState = codeToWindowState.get(windowStateHeader);
- }
- Mode mode = null;
- int modeStateHeader = (header & (7 << (1 + 3))) >> (1 + 3);
- switch (modeStateHeader)
- {
- case 0:
- break;
- case 4:
- mode = Mode.create(in.readUTF());
- break;
- default:
- mode = codeToMode.get(modeStateHeader);
- }
- WindowNavigationalState windowNS = new WindowNavigationalState(portletNS,
mode, windowState);
- pageState.windows.put(windowId, windowNS);
- }
-
- //
- size = in.readInt();
- while (size-- > 0)
- {
- String namespaceURI = in.readUTF();
- String localName = in.readUTF();
- QName name = new QName(namespaceURI, localName);
- int length = in.readInt();
- String[] values = new String[length];
- for (int i = 0;i < length;i++)
- {
- values[i] = in.readUTF();
- }
- pageState.page.put(name, values);
- }
-
- //
- return pageState;
- }
- catch (IOException e)
- {
- throw new UndeclaredIOException(e);
- }
- }
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-02-09
12:08:11 UTC (rev 9887)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-02-09
12:14:27 UTC (rev 9888)
@@ -77,6 +77,13 @@
ParameterMap getPublicNavigationalState(String windowId) throws
IllegalArgumentException;
/**
+ * Returns the set of public names.
+ *
+ * @return the public names
+ */
+ Set<QName> getPublicNames();
+
+ /**
* Update the public navigational state of a window. The interpretation of what should
be updated is left up to the
* implementor. An example of implementation would use the mapping between qname and
name provided by the referenced
* portlet info.
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalStateSerialization.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalStateSerialization.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalStateSerialization.java 2008-02-09
12:14:27 UTC (rev 9888)
@@ -0,0 +1,234 @@
+/******************************************************************************
+ * 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.portlet.controller.state;
+
+import org.jboss.portal.common.io.Serialization;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+
+import javax.xml.namespace.QName;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.DataOutputStream;
+import java.io.DataInputStream;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * Implement serialization of a page navigational state in a compact manner.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PageNavigationalStateSerialization implements
Serialization<PageNavigationalState>
+{
+
+ /** . */
+ private static final Map<WindowState, Integer> windowStateToCode = new
HashMap<WindowState, Integer>();
+
+ /** . */
+ private static final Map<Mode, Integer> modeToCode = new HashMap<Mode,
Integer>();
+
+ /** . */
+ private static final Map<Integer, WindowState> codeToWindowState = new
HashMap<Integer, WindowState>();
+
+ /** . */
+ private static final Map<Integer, Mode> codeToMode = new HashMap<Integer,
Mode>();
+
+ static
+ {
+ windowStateToCode.put(WindowState.NORMAL, 1);
+ windowStateToCode.put(WindowState.MINIMIZED, 2);
+ windowStateToCode.put(WindowState.MAXIMIZED, 3);
+ codeToWindowState.put(1, WindowState.NORMAL);
+ codeToWindowState.put(2, WindowState.MINIMIZED);
+ codeToWindowState.put(3, WindowState.MAXIMIZED);
+ modeToCode.put(Mode.VIEW, 1);
+ modeToCode.put(Mode.EDIT, 2);
+ modeToCode.put(Mode.HELP, 3);
+ codeToMode.put(1, Mode.VIEW);
+ codeToMode.put(2, Mode.EDIT);
+ codeToMode.put(3, Mode.HELP);
+ }
+
+ /** . */
+ private final StateControllerContext context;
+
+ public PageNavigationalStateSerialization(StateControllerContext context)
+ {
+ if (context == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.context = context;
+ }
+
+ public void serialize(PageNavigationalState pageState, OutputStream out) throws
IOException, IllegalArgumentException
+ {
+ DataOutputStream data = out instanceof DataOutputStream ? (DataOutputStream)out :
new DataOutputStream(out);
+
+ //
+ data.writeInt(pageState.getWindowIds().size());
+ for (String windowId : pageState.getWindowIds())
+ {
+ data.writeUTF(windowId);
+ WindowNavigationalState windowNS =
pageState.getWindowNavigationalState(windowId);
+ byte header = 0;
+ int decision = 0;
+ if (windowNS.getPortletNavigationalState() != null)
+ {
+ header |= 1;
+ decision |= 1;
+ }
+ if (windowNS.getWindowState() != null)
+ {
+ Integer value = windowStateToCode.get(windowNS.getWindowState());
+ if (value != null)
+ {
+ header |= value << 1;
+ }
+ else
+ {
+ header |= 4 << 1;
+ decision |= 2;
+ }
+ }
+ if (windowNS.getMode() != null)
+ {
+ Integer value = modeToCode.get(windowNS.getMode());
+ if (value != null)
+ {
+ header |= value << 4;
+ }
+ else
+ {
+ header |= 4 << 4;
+ decision |= 4;
+ }
+ }
+ data.writeByte(header);
+ if ((decision & 1) != 0)
+ {
+ windowNS.getPortletNavigationalState().writeTo(data);
+ }
+ if ((decision & 2) != 0)
+ {
+ data.writeUTF(windowNS.getWindowState().toString());
+ }
+ if ((decision & 4) != 0)
+ {
+ data.writeUTF(windowNS.getMode().toString());
+ }
+ }
+
+ //
+ Set<QName> publicNames = pageState.getPublicNames();
+ data.writeInt(publicNames.size());
+ for (QName name : pageState.getPublicNames())
+ {
+ data.writeUTF(name.getNamespaceURI());
+ data.writeUTF(name.getLocalPart());
+ String[] values = pageState.getPublicNavigationalState(name);
+ int length = values.length;
+ data.writeInt(length);
+ for (String value : values)
+ {
+ data.writeUTF(value);
+ }
+ }
+
+ // Need to flush before returning otherwise bytes may stay in the buffer when we
allocated
+ // a data stream
+ data.flush();
+ }
+
+ public PageNavigationalState unserialize(InputStream in) throws IOException,
IllegalArgumentException
+ {
+ DataInputStream data = in instanceof DataInputStream ? (DataInputStream)in : new
DataInputStream(in);
+
+ //
+ PageNavigationalState pageNS = context.createPageState(true);
+
+ //
+ int size = data.readInt();
+ while (size-- > 0)
+ {
+ String windowId = data.readUTF();
+ byte header = data.readByte();
+ StateString portletNS = null;
+ if ((header & 1) != 0)
+ {
+ portletNS = ParametersStateString.create(data);
+ }
+ WindowState windowState = null;
+ int windowStateHeader = (header & (7 << 1)) >> 1;
+ switch (windowStateHeader)
+ {
+ case 0:
+ break;
+ case 4:
+ windowState = WindowState.create(data.readUTF());
+ break;
+ default:
+ windowState = codeToWindowState.get(windowStateHeader);
+ }
+ Mode mode = null;
+ int modeStateHeader = (header & (7 << (1 + 3))) >> (1 + 3);
+ switch (modeStateHeader)
+ {
+ case 0:
+ break;
+ case 4:
+ mode = Mode.create(data.readUTF());
+ break;
+ default:
+ mode = codeToMode.get(modeStateHeader);
+ }
+ WindowNavigationalState windowNS = new WindowNavigationalState(portletNS, mode,
windowState);
+ pageNS.setWindowNavigationalState(windowId, windowNS);
+ }
+
+ //
+ size = data.readInt();
+ while (size-- > 0)
+ {
+ String namespaceURI = data.readUTF();
+ String localName = data.readUTF();
+ QName name = new QName(namespaceURI, localName);
+ int length = data.readInt();
+ String[] values = new String[length];
+ for (int i = 0;i < length;i++)
+ {
+ values[i] = data.readUTF();
+ }
+ pageNS.setPublicNavigationalState(name, values);
+ }
+
+ //
+ return pageNS;
+ }
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/WindowNavigationalState.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/WindowNavigationalState.java 2008-02-09
12:08:11 UTC (rev 9887)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/WindowNavigationalState.java 2008-02-09
12:14:27 UTC (rev 9888)
@@ -30,6 +30,7 @@
/**
* The navigational state of a window that contains the portlet navigational state, the
mode and window state.
+ * This class is immutable.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-09
12:08:11 UTC (rev 9887)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-09
12:14:27 UTC (rev 9888)
@@ -27,6 +27,7 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.common.io.Serialization;
+import org.jboss.portal.common.io.SerializationFilter;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.ParameterMap;
@@ -48,6 +49,7 @@
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
@@ -116,6 +118,9 @@
{
StateControllerContextImpl tmp = new StateControllerContextImpl(this);
+ //
+ PageNavigationalStateSerialization serialization = new
PageNavigationalStateSerialization(tmp);
+
// The nav state provided with the request
// Unmarshall portal navigational state if it is provided
PageNavigationalState pageState = null;
@@ -123,7 +128,7 @@
if (context != null)
{
byte[] bytes = Base64.decode(context, true);
- pageState = tmp.unserialize(bytes, false);
+ pageState = IOTools.unserialize(serialization, SerializationFilter.COMPRESSOR,
bytes);
}
// The type of invocation
@@ -239,7 +244,7 @@
else
{
byte[] bytes =
Base64.decode(req.getParameter(PUBLIC_NAVIGATIONAL_STATE_CHANGES), true);
- Map<String, String[]> publicNavigationalStateChanges =
IOTools.unserialize(Serialization.PARAMETER_MAP, bytes);
+ Map<String, String[]> publicNavigationalStateChanges =
IOTools.unserialize(Serialization.PARAMETER_MAP, SerializationFilter.COMPRESSOR, bytes);
//
request = new PortletRenderRequest(
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-09
12:08:11 UTC (rev 9887)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-09
12:14:27 UTC (rev 9888)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.common.io.Serialization;
+import org.jboss.portal.common.io.SerializationFilter;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Base64;
@@ -37,6 +38,7 @@
import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
import static org.jboss.portal.portlet.test.URLParameterConstants.*;
import javax.servlet.http.HttpServletRequest;
@@ -56,6 +58,9 @@
final StateControllerContextImpl stateContext;
/** . */
+ final PageNavigationalStateSerialization serialization;
+
+ /** . */
final HttpServletRequest clientReq;
/** . */
@@ -74,6 +79,7 @@
this.pageNS = pageNS;
this.clientReq = clientReq;
this.clientResp = clientResp;
+ this.serialization = new PageNavigationalStateSerialization(stateContext);
}
private String renderURL(Map<String, String> parameters, Boolean wantSecure,
Boolean wantAuthenticated, boolean relative)
@@ -116,7 +122,7 @@
String pageState = null;
if (pageNS != null)
{
- byte[] bytes = stateContext.serialize(pageNS);
+ byte[] bytes = IOTools.serialize(serialization, SerializationFilter.COMPRESSOR,
pageNS);
pageState = Base64.encodeBytes(bytes, true);
}
@@ -169,7 +175,7 @@
String pageState = null;
if (pageNS != null)
{
- byte[] bytes = stateContext.serialize(pageNS);
+ byte[] bytes = IOTools.serialize(serialization, SerializationFilter.COMPRESSOR,
pageNS);
pageState = Base64.encodeBytes(bytes, true);
}
@@ -216,7 +222,7 @@
//
Map<String, String[]> changes =
renderURL.getPublicNavigationalStateChanges();
- byte[] bytes = IOTools.serialize(Serialization.PARAMETER_MAP, changes);
+ byte[] bytes = IOTools.serialize(Serialization.PARAMETER_MAP,
SerializationFilter.COMPRESSOR, changes);
String ns = Base64.encodeBytes(bytes, true);
parameters.put(PUBLIC_NAVIGATIONAL_STATE_CHANGES, ns);
Modified:
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java
===================================================================
---
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java 2008-02-09
12:08:11 UTC (rev 9887)
+++
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java 2008-02-09
12:14:27 UTC (rev 9888)
@@ -27,6 +27,7 @@
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
import org.jboss.portal.portlet.controller.event.EventControllerContext;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -38,6 +39,8 @@
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.io.SerializationFilter;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import static org.jboss.unit.api.Assert.*;
@@ -96,8 +99,8 @@
private void assertMarshallable(PageNavigationalState pageNS)
{
- byte[] bytes = cc.serialize(pageNS);
- PageNavigationalState expectedPageNS = cc.unserialize(bytes, true);
+ byte[] bytes = IOTools.serialize(new PageNavigationalStateSerialization(cc),
/*SerializationFilter.COMPRESSOR, */pageNS);
+ PageNavigationalState expectedPageNS = IOTools.unserialize(new
PageNavigationalStateSerialization(cc), /*SerializationFilter.COMPRESSOR, */bytes);
assertEquals(expectedPageNS.getWindowIds(), pageNS.getWindowIds());
for (String windowId : expectedPageNS.getWindowIds())
{