[portal-commits] JBoss Portal SVN: r6003 - in trunk: portlet/src/main/org/jboss/portal/portlet/state/consumer and 2 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Fri Jan 12 18:32:52 EST 2007


Author: julien at jboss.com
Date: 2007-01-12 18:32:39 -0500 (Fri, 12 Jan 2007)
New Revision: 6003

Added:
   trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortlet.java
   trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortlet.java
Modified:
   trunk/common/src/main/org/jboss/portal/common/junit/ExtendedAssert.java
   trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java
   trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/state/LocalStoreProducerStatefulPortletInvokerTestCase.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
   trunk/portlet/src/main/org/jboss/portal/test/portlet/state/RemoteStoreProducerStatefulPortletInvokerTestCase.java
Log:
-the Portlet returned by getPortlet was not returning the right PortletContext value but rather the one of the portlet originating from the delegate PortletInvoker
- udpated clone test case to test portlet context equality

Modified: trunk/common/src/main/org/jboss/portal/common/junit/ExtendedAssert.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/junit/ExtendedAssert.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/common/src/main/org/jboss/portal/common/junit/ExtendedAssert.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -39,7 +39,7 @@
    /** @see #assertEquals(Object[],Object[]) */
    public static void assertEquals(Object[] expected, Object[] actual)
    {
-      assertEquals(null, (Object[])expected, (Object[])actual);
+      assertEquals(null, expected, actual);
    }
 
    /** Test equality as defined by java.util.Array#equals(Object[], Object[]). */

Added: trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortlet.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortlet.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortlet.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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.portlet.state.consumer;
+
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.info.PortletInfo;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConsumerPortlet implements Portlet
+{
+
+   /** . */
+   private final PortletContext context;
+
+   /** . */
+   private final Portlet delegate;
+
+   public ConsumerPortlet(PortletContext context, Portlet delegate)
+   {
+      this.context = context;
+      this.delegate = delegate;
+   }
+
+   public PortletContext getContext()
+   {
+      return context;
+   }
+
+   public PortletInfo getInfo()
+   {
+      return delegate.getInfo();
+   }
+
+   public boolean isRemote()
+   {
+      return delegate.isRemote();
+   }
+}

Modified: trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/state/consumer/ConsumerPortletInvoker.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -127,7 +127,8 @@
    public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException
    {
       ConsumerContext cpc = getConsumerContext(portletContext);
-      return producer.getPortlet(cpc.portletContext);
+      Portlet delegate = producer.getPortlet(cpc.portletContext);
+      return new ConsumerPortlet(portletContext, delegate);
    }
 
    public PortletInvocationResponse invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException

Added: trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortlet.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortlet.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortlet.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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.portlet.state.producer;
+
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.info.PortletInfo;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ProducerPortlet implements Portlet
+{
+
+   /** . */
+   private final PortletContext context;
+
+   /** . */
+   private final Portlet delegate;
+
+   public ProducerPortlet(PortletContext context, Portlet delegate)
+   {
+      this.context = context;
+      this.delegate = delegate;
+   }
+
+   public PortletContext getContext()
+   {
+      return context;
+   }
+
+   public PortletInfo getInfo()
+   {
+      return delegate.getInfo();
+   }
+
+   public boolean isRemote()
+   {
+      return delegate.isRemote();
+   }
+}

Modified: trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -142,7 +142,8 @@
             try
             {
                PortletState portletState = stateConverter.unmarshall(state);
-               return portletInvoker.getPortlet(PortletContext.createPortletContext(portletState.getPortletId()));
+               Portlet delegate = portletInvoker.getPortlet(PortletContext.createPortletContext(portletState.getPortletId()));
+               return new ProducerPortlet(portletContext, delegate);
             }
             catch (StateConversionException e)
             {
@@ -161,7 +162,8 @@
             String stateId = portletId.substring(PRODUCER_CLONE_ID_PREFIX.length());
             PortletStateContext stateContext = persistenceManager.loadState(stateId);
             PortletState state = stateContext.getState();
-            return portletInvoker.getPortlet(PortletContext.createPortletContext(state.getPortletId()));
+            Portlet delegate = portletInvoker.getPortlet(PortletContext.createPortletContext(state.getPortletId()));
+            return new ProducerPortlet(portletContext, delegate);
          }
          catch (NoSuchStateException e)
          {

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -30,6 +30,7 @@
 import org.jboss.portal.portlet.NoSuchPortletException;
 import org.jboss.portal.portlet.Portlet;
 import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletContext;
 import org.jboss.portal.portlet.support.info.PortletInfoSupport;
 import org.jboss.portal.portlet.info.MetaInfo;
 import org.jboss.portal.portlet.invocation.ActionInvocation;
@@ -49,6 +50,7 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
+import java.util.Arrays;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -60,57 +62,57 @@
    /**
     *
     */
-   protected abstract Portlet getPortlet(Object portletRef) throws PortletInvokerException;
+   protected abstract Portlet getPortlet(PortletContext portletRef) throws PortletInvokerException;
 
    /**
     *
     */
-   protected abstract String getPortletId(Object portletRef) throws PortletInvokerException;
+   protected abstract String getPortletId(PortletContext portletRef) throws PortletInvokerException;
 
    /**
     *
     */
-   protected abstract Object createPOPRef(PortletSupport portletSupport) throws PortletInvokerException;
+   protected abstract PortletContext createPOPRef(PortletSupport portletSupport) throws PortletInvokerException;
 
    /**
     *
     */
-   protected abstract Object createNonExistingPOPRef() throws PortletInvokerException;
+   protected abstract PortletContext createNonExistingPOPRef() throws PortletInvokerException;
 
    /**
     *
     */
-   protected abstract Object createInvalidPOPRef() throws PortletInvokerException;
+   protected abstract PortletContext createInvalidPOPRef() throws PortletInvokerException;
 
    /**
     *
     */
-   protected abstract Object createLocalClone(Object portletRef) throws Exception;
+   protected abstract PortletContext createLocalClone(PortletContext portletRef) throws Exception;
 
    /**
     *
     */
-   protected abstract void destroyClone(Object portletRef) throws Exception;
+   protected abstract void destroyClone(PortletContext portletRef) throws Exception;
 
    /**
     *
     */
-   protected abstract Object createClone(Object portletRef) throws PortletInvokerException;
+   protected abstract PortletContext createClone(PortletContext portletRef) throws PortletInvokerException;
 
    /**
     *
     */
-   protected abstract Object setProperties(Object portletRef, PropertyChange[] changes) throws PortletInvokerException;
+   protected abstract PortletContext setProperties(PortletContext portletRef, PropertyChange[] changes) throws PortletInvokerException;
 
    /**
     *
     */
-   protected abstract PropertyMap getProperties(Object portletRef) throws PortletInvokerException;
+   protected abstract PropertyMap getProperties(PortletContext portletRef) throws PortletInvokerException;
 
    /**
     *
     */
-   protected abstract PropertyMap getProperties(Object portletRef, Set keys) throws PortletInvokerException;
+   protected abstract PropertyMap getProperties(PortletContext portletRef, Set keys) throws PortletInvokerException;
 
    /**
     *
@@ -130,22 +132,22 @@
    /**
     *
     */
-   protected abstract ActionInvocation createAction(Object portletRef, AccessMode accessMode);
+   protected abstract ActionInvocation createAction(PortletContext portletRef, AccessMode accessMode);
 
    /**
     *
     */
-   protected abstract Object getImplicitClonedRef(ActionInvocation action);
+   protected abstract PortletContext getImplicitClonedRef(ActionInvocation action);
 
    /**
     *
     */
-   protected abstract Object getModifiedPortletRef(ActionInvocation action);
+   protected abstract PortletContext getModifiedPortletRef(ActionInvocation action);
 
    /**
     *
     */
-   protected final Object createPOPRef(PortletInfoSupport portletInfo) throws PortletInvokerException
+   protected final PortletContext createPOPRef(PortletInfoSupport portletInfo) throws PortletInvokerException
    {
       PortletSupport portletSupport = new PortletSupport(portletInfo);
       return createPOPRef(portletSupport);
@@ -154,19 +156,19 @@
    /**
     *
     */
-   protected final Object createLocalCCPRef() throws Exception
+   protected final PortletContext createLocalCCPRef() throws Exception
    {
-      Object popCtx = createPOPRef();
+      PortletContext popCtx = createPOPRef();
       return createLocalClone(popCtx);
    }
 
    /**
     *
     */
-   protected final Object createNonExistingLocalCCPRef() throws Exception
+   protected final PortletContext createNonExistingLocalCCPRef() throws Exception
    {
-      Object popRef = createPOPRef();
-      Object ccpRef = createLocalClone(popRef);
+      PortletContext popRef = createPOPRef();
+      PortletContext ccpRef = createLocalClone(popRef);
       destroyClone(ccpRef);
       return ccpRef;
    }
@@ -174,7 +176,7 @@
    /**
     *
     */
-   protected final Object createPOPRef() throws PortletInvokerException
+   protected final PortletContext createPOPRef() throws PortletInvokerException
    {
       PortletInfoSupport info = new PortletInfoSupport();
       return createPOPRef(info);
@@ -195,7 +197,7 @@
 
    public void testCloneNonExistingPOP() throws Exception
    {
-      Object popCtx = createNonExistingPOPRef();
+      PortletContext popCtx = createNonExistingPOPRef();
       try
       {
          createClone(popCtx);
@@ -209,7 +211,7 @@
 
    public void testCloneNonExistingCCP() throws Exception
    {
-      Object ccpCtx = createNonExistingLocalCCPRef();
+      PortletContext ccpCtx = createNonExistingLocalCCPRef();
       try
       {
          createClone(ccpCtx);
@@ -237,7 +239,7 @@
 
    public void testCloneInvalidPOP() throws Exception
    {
-      Object popCtx = createInvalidPOPRef();
+      PortletContext popCtx = createInvalidPOPRef();
       try
       {
          createClone(popCtx);
@@ -255,8 +257,8 @@
       info.getMetaSupport().setDisplayName("MyPortlet");
       info.getPreferencesSupport().addPreference("abc", new StringValue("def"));
 
-      Object popCtx = createPOPRef(info);
-      Object ccp1Ctx = createClone(popCtx);
+      PortletContext popCtx = createPOPRef(info);
+      PortletContext ccp1Ctx = createClone(popCtx);
 
       // Check state
       PropertyMap expected = new SimplePropertyMap();
@@ -268,13 +270,14 @@
       Portlet ccp1 = getPortlet(ccp1Ctx);
       LocalizedString abc = ccp1.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
       assertEquals("MyPortlet", abc.getString(Locale.ENGLISH, true));
+      assertEquals(ccp1Ctx, ccp1.getContext());
 
       // Update state
       PropertyChange[] changes = new PropertyChange[]{PropertyChange.newUpdate("ghi", new StringValue("jkl"))};
       ccp1Ctx = setProperties(ccp1Ctx, changes);
 
       // Clone a CCP
-      Object ccp2Ctx = createClone(ccp1Ctx);
+      PortletContext ccp2Ctx = createClone(ccp1Ctx);
 
       // Check state
       expected = new SimplePropertyMap();
@@ -303,7 +306,7 @@
 
    public void testGetNonExistingPOP() throws Exception
    {
-      Object pop = createNonExistingPOPRef();
+      PortletContext pop = createNonExistingPOPRef();
       try
       {
          getPortlet(pop);
@@ -316,7 +319,7 @@
 
    public void testGetNonExistingCCP() throws Exception
    {
-      Object ccpCtx = createNonExistingLocalCCPRef();
+      PortletContext ccpCtx = createNonExistingLocalCCPRef();
       try
       {
          getPortlet(ccpCtx);
@@ -329,7 +332,7 @@
 
    public void testGetInvalidPOP() throws Exception
    {
-      Object popCtx = createInvalidPOPRef();
+      PortletContext popCtx = createInvalidPOPRef();
       try
       {
          getPortlet(popCtx);
@@ -367,7 +370,7 @@
 
    public void testDestroyPOP() throws Exception
    {
-      Object popCtx = createPOPRef();
+      PortletContext popCtx = createPOPRef();
       List failures = destroyClones(Collections.singletonList(popCtx));
       assertEquals(1, failures.size());
       DestroyCloneFailure failure = (DestroyCloneFailure)failures.get(0);
@@ -376,8 +379,8 @@
 
    public void testDestroyCCP() throws Exception
    {
-      Object popCtx = createPOPRef();
-      Object ccpCtx = createClone(popCtx);
+      PortletContext popCtx = createPOPRef();
+      PortletContext ccpCtx = createClone(popCtx);
       List failures = destroyClones(Collections.singletonList(ccpCtx));
       assertEquals(0, failures.size());
       assertNoExistingState();
@@ -394,7 +397,7 @@
 
    public void testDestroyNonExistingCCP() throws Exception
    {
-      Object ccpCtx = createNonExistingLocalCCPRef();
+      PortletContext ccpCtx = createNonExistingLocalCCPRef();
       List failures = destroyClones(Collections.singletonList(ccpCtx));
       assertEquals(1, failures.size());
       DestroyCloneFailure failure = (DestroyCloneFailure)failures.get(0);
@@ -423,7 +426,7 @@
 
    public void testGetNonExistingPOPProperties() throws Exception
    {
-      Object popCtx = createNonExistingPOPRef();
+      PortletContext popCtx = createNonExistingPOPRef();
       try
       {
          getProperties(popCtx);
@@ -444,7 +447,7 @@
 
    public void testGetInvalidPOPProperties() throws Exception
    {
-      Object popCtx = createInvalidPOPRef();
+      PortletContext popCtx = createInvalidPOPRef();
       try
       {
          getProperties(popCtx);
@@ -465,7 +468,7 @@
 
    public void testGetNonExistingCCPProperties() throws Exception
    {
-      Object ccpCtx = createNonExistingLocalCCPRef();
+      PortletContext ccpCtx = createNonExistingLocalCCPRef();
       try
       {
          getProperties(ccpCtx);
@@ -507,7 +510,7 @@
 
    public void testGetPOPWithNullKeys() throws Exception
    {
-      Object popCtx = createPOPRef();
+      PortletContext popCtx = createPOPRef();
       try
       {
          getProperties(popCtx, null);
@@ -520,7 +523,7 @@
 
    public void testGetCCPWithNullKeys() throws Exception
    {
-      Object ccpCtx = createLocalCCPRef();
+      PortletContext ccpCtx = createLocalCCPRef();
       try
       {
          getProperties(ccpCtx, null);
@@ -536,7 +539,7 @@
       PortletInfoSupport info = new PortletInfoSupport();
       info.getPreferencesSupport().addPreference("abc", new StringValue("def"));
       info.getPreferencesSupport().addPreference("ghi", new StringValue("jkl"), Boolean.TRUE);
-      Object popCtx = createPOPRef(info);
+      PortletContext popCtx = createPOPRef(info);
 
       //
       PropertyMap props = getProperties(popCtx);
@@ -559,10 +562,10 @@
       info.getPreferencesSupport().addPreference("ghi", new StringValue("jkl"));
       info.getPreferencesSupport().addPreference("mno", new StringValue("pqr"), Boolean.TRUE);
       info.getPreferencesSupport().addPreference("stu", new StringValue("vwx"), Boolean.TRUE);
-      Object popCtx = createPOPRef(info);
+      PortletContext popCtx = createPOPRef(info);
 
       //
-      Object ccpCtx = createClone(popCtx);
+      PortletContext ccpCtx = createClone(popCtx);
       ccpCtx = setProperties(ccpCtx, new PropertyChange[]{
          PropertyChange.newUpdate("abc", new StringValue("_def")),
          PropertyChange.newReset("gho"),
@@ -600,7 +603,7 @@
 
    public void testSetPropertiesWithNullProperties() throws Exception
    {
-      Object ccpCtx = createLocalCCPRef();
+      PortletContext ccpCtx = createLocalCCPRef();
       try
       {
          setProperties(ccpCtx, null);
@@ -613,7 +616,7 @@
 
    public void testSetPOPProperties() throws Exception
    {
-      Object popCtx = createPOPRef();
+      PortletContext popCtx = createPOPRef();
       try
       {
          setProperties(popCtx, new PropertyChange[0]);
@@ -626,7 +629,7 @@
 
    public void testSetNonExistingCCPProperties() throws Exception
    {
-      Object ccpCtx = createNonExistingLocalCCPRef();
+      PortletContext ccpCtx = createNonExistingLocalCCPRef();
       try
       {
          setProperties(ccpCtx, new PropertyChange[0]);
@@ -644,10 +647,10 @@
       info.getPreferencesSupport().addPreference("override_reset", new StringValue("override_reset_portlet_value"));
       info.getPreferencesSupport().addPreference("override_create", new StringValue("override_create_portlet_value"));
       info.getPreferencesSupport().addPreference("readonly_create", new StringValue("readonly_create_portlet_value"), Boolean.TRUE);
-      Object popCtx = createPOPRef(info);
+      PortletContext popCtx = createPOPRef(info);
 
       //
-      Object ccpCtx = createClone(popCtx);
+      PortletContext ccpCtx = createClone(popCtx);
       ccpCtx = setProperties(ccpCtx, new PropertyChange[]{
          PropertyChange.newUpdate("override_update", new StringValue("override_update_clone_value")),
          PropertyChange.newUpdate("override_reset", new StringValue("override_reset_clone_value")),
@@ -704,14 +707,14 @@
             return null;
          }
       };
-      Object popCtx = createPOPRef(portletSupport);
+      PortletContext popCtx = createPOPRef(portletSupport);
 
       //
       ActionInvocation invocation = createAction(popCtx, AccessMode.CLONE_BEFORE_WRITE);
       invoke(invocation);
 
       //
-      Object cloneRef = getImplicitClonedRef(invocation);
+      PortletContext cloneRef = getImplicitClonedRef(invocation);
       assertNotNull(cloneRef);
 
       //
@@ -744,7 +747,7 @@
             }
          }
       };
-      Object popCtx = createPOPRef(portletSupport);
+      PortletContext popCtx = createPOPRef(portletSupport);
 
       //
       ActionInvocation invocation = createAction(popCtx, AccessMode.READ_ONLY);
@@ -769,8 +772,8 @@
             return null;
          }
       };
-      Object popCtx = createPOPRef(portletSupport);
-      Object ccpCtx = createClone(popCtx);
+      PortletContext popCtx = createPOPRef(portletSupport);
+      PortletContext ccpCtx = createClone(popCtx);
 
       //
       ActionInvocation invocation = createAction(ccpCtx, AccessMode.READ_WRITE);
@@ -786,4 +789,32 @@
       expectedProps.setProperty("abc", new StringValue("_def"));
       ValueMapAssert.assertEquals(expectedProps, blah);
    }
+
+   private void assertEquals(PortletContext expected, PortletContext actual)
+   {
+      if (expected == null)
+      {
+         assertNull("Portlet context should be null", actual);
+      }
+      else
+      {
+         assertNotNull("Portlet context should not be null but rather equals to " + expected, actual);
+
+         // Test handle first
+         assertEquals(expected.getId(), actual.getId());
+
+         // Compare bytes
+         byte[] expectedState = expected.getState();
+         byte[] actualState = actual.getState();
+         if (expectedState == null)
+         {
+            assertNull("Actual state should be null", actualState);
+         }
+         else
+         {
+            assertNotNull("Actual state should be not null", actualState);
+            assertTrue(Arrays.equals(expectedState, actualState));
+         }
+      }
+   }
 }

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -106,19 +106,19 @@
       consumer.setProducer(producer);
    }
 
-   protected Portlet getPortlet(Object portletRef) throws PortletInvokerException
+   protected Portlet getPortlet(PortletContext portletRef) throws PortletInvokerException
    {
       return consumer.getPortlet((PortletContext)portletRef);
    }
 
-   protected Object createPOPRef(PortletSupport portletSupport) throws PortletInvokerException
+   protected PortletContext createPOPRef(PortletSupport portletSupport) throws PortletInvokerException
    {
       container.addPortlet("PortletId", portletSupport);
       Portlet portlet = getSinglePOP();
       return portlet.getContext();
    }
 
-   protected Object createNonExistingPOPRef() throws PortletInvokerException
+   protected PortletContext createNonExistingPOPRef() throws PortletInvokerException
    {
       container.addPortlet("NonExistingPortletId", new PortletInfoSupport());
       PortletContext popContext = getSinglePOP().getContext();
@@ -126,7 +126,7 @@
       return popContext;
    }
 
-   protected Object createInvalidPOPRef() throws PortletInvokerException
+   protected PortletContext createInvalidPOPRef() throws PortletInvokerException
    {
       container.addPortlet("InvalidPortletId", new PortletInfoSupport());
       PortletContext popContext = getSinglePOP().getContext();
@@ -134,7 +134,7 @@
       return popContext;
    }
 
-   protected Object createLocalClone(Object portletRef) throws Exception
+   protected PortletContext createLocalClone(PortletContext portletRef) throws Exception
    {
       stateManagementPolicy.setPersistLocally(true);
       PortletContext cloneRef = consumer.createClone((PortletContext)portletRef);
@@ -142,7 +142,7 @@
       return cloneRef;
    }
 
-   protected void destroyClone(Object portletRef) throws Exception
+   protected void destroyClone(PortletContext portletRef) throws Exception
    {
       assertEquals(Collections.EMPTY_LIST, consumer.destroyClones(Collections.singletonList(portletRef)));
    }
@@ -152,23 +152,23 @@
       // todo
    }
 
-   protected Object createClone(Object portletRef) throws PortletInvokerException
+   protected PortletContext createClone(PortletContext portletRef) throws PortletInvokerException
    {
       return consumer.createClone((PortletContext)portletRef);
    }
 
-   protected Object setProperties(Object portletRef, PropertyChange[] changes) throws PortletInvokerException
+   protected PortletContext setProperties(PortletContext portletRef, PropertyChange[] changes) throws PortletInvokerException
    {
       consumer.setProperties((PortletContext)portletRef, changes);
       return portletRef;
    }
 
-   protected PropertyMap getProperties(Object portletRef) throws PortletInvokerException
+   protected PropertyMap getProperties(PortletContext portletRef) throws PortletInvokerException
    {
       return consumer.getProperties((PortletContext)portletRef);
    }
 
-   protected PropertyMap getProperties(Object portletRef, Set keys) throws PortletInvokerException
+   protected PropertyMap getProperties(PortletContext portletRef, Set keys) throws PortletInvokerException
    {
       return consumer.getProperties((PortletContext)portletRef, keys);
    }
@@ -178,7 +178,7 @@
       return consumer.destroyClones(portletRefs);
    }
 
-   protected String getPortletId(Object portletRef) throws PortletInvokerException
+   protected String getPortletId(PortletContext portletRef) throws PortletInvokerException
    {
       return ((PortletContext)portletRef).getId();
    }
@@ -188,7 +188,7 @@
       consumer.invoke(invocation);
    }
 
-   protected ActionInvocation createAction(Object portletRef, AccessMode accessMode)
+   protected ActionInvocation createAction(PortletContext portletRef, AccessMode accessMode)
    {
       ActionContextImpl actionCtx = new ActionContextImpl();
       InstanceContextImpl instanceCtx = new InstanceContextImpl("blah", accessMode);
@@ -200,15 +200,15 @@
       return action;
    }
 
-   protected Object getImplicitClonedRef(ActionInvocation action)
+   protected PortletContext getImplicitClonedRef(ActionInvocation action)
    {
       InstanceContextImpl instanceCtx = (InstanceContextImpl)action.getInstanceContext();
       return instanceCtx.getClonedContext();
    }
 
-   protected Object getModifiedPortletRef(ActionInvocation action)
+   protected PortletContext getModifiedPortletRef(ActionInvocation action)
    {
-      return action.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+      return (PortletContext)action.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
    }
 
    private Portlet getSinglePOP() throws PortletInvokerException

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/state/LocalStoreProducerStatefulPortletInvokerTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/state/LocalStoreProducerStatefulPortletInvokerTestCase.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/state/LocalStoreProducerStatefulPortletInvokerTestCase.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -24,6 +24,7 @@
 
 import org.jboss.portal.portlet.invocation.ActionInvocation;
 import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.PortletContext;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -36,8 +37,8 @@
       super(true);
    }
 
-   protected Object getModifiedPortletRef(ActionInvocation action)
+   protected PortletContext getModifiedPortletRef(ActionInvocation action)
    {
-      return action.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+      return (PortletContext)action.getAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
    }
 }

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -97,14 +97,14 @@
       assertEquals(0, persistenceManager.getSize());
    }
 
-   protected Object createPOPRef(PortletSupport portletSupport) throws PortletInvokerException
+   protected PortletContext createPOPRef(PortletSupport portletSupport) throws PortletInvokerException
    {
       container.addPortlet("PortletId", portletSupport);
       Portlet portlet = getSinglePOP();
       return portlet.getContext();
    }
 
-   protected Object createNonExistingPOPRef()
+   protected PortletContext createNonExistingPOPRef()
    {
       container.addPortlet("NonExistingPortletId", new PortletInfoSupport());
       PortletContext popCtx = getSinglePOP().getContext();
@@ -112,7 +112,7 @@
       return popCtx;
    }
 
-   protected Object createInvalidPOPRef()
+   protected PortletContext createInvalidPOPRef()
    {
       container.addPortlet("InvalidPortletId", new PortletInfoSupport());
       PortletContext popCtx = getSinglePOP().getContext();
@@ -120,7 +120,7 @@
       return popCtx;
    }
 
-   protected Object createLocalClone(Object portletRef) throws Exception
+   protected PortletContext createLocalClone(PortletContext portletRef) throws Exception
    {
       stateManagementPolicy.setPersistLocally(true);
       PortletContext cloneContext = producer.createClone((PortletContext)portletRef);
@@ -128,27 +128,27 @@
       return cloneContext;
    }
 
-   protected void destroyClone(Object portletRef) throws Exception
+   protected void destroyClone(PortletContext portletRef) throws Exception
    {
       assertEquals(Collections.EMPTY_LIST, producer.destroyClones(Collections.singletonList(portletRef)));
    }
 
-   protected Object createClone(Object portletRef) throws PortletInvokerException
+   protected PortletContext createClone(PortletContext portletRef) throws PortletInvokerException
    {
       return producer.createClone((PortletContext)portletRef);
    }
 
-   protected Object setProperties(Object portletRef, PropertyChange[] changes) throws PortletInvokerException
+   protected PortletContext setProperties(PortletContext portletRef, PropertyChange[] changes) throws PortletInvokerException
    {
       return producer.setProperties((PortletContext)portletRef, changes);
    }
 
-   protected PropertyMap getProperties(Object portletRef) throws PortletInvokerException
+   protected PropertyMap getProperties(PortletContext portletRef) throws PortletInvokerException
    {
       return producer.getProperties((PortletContext)portletRef);
    }
 
-   protected PropertyMap getProperties(Object portletRef, Set keys) throws PortletInvokerException
+   protected PropertyMap getProperties(PortletContext portletRef, Set keys) throws PortletInvokerException
    {
       return producer.getProperties((PortletContext)portletRef, keys);
    }
@@ -158,7 +158,7 @@
       return producer.destroyClones(portletRefs);
    }
 
-   protected Portlet getPortlet(Object portletRef) throws PortletInvokerException
+   protected Portlet getPortlet(PortletContext portletRef) throws PortletInvokerException
    {
       if (portletRef == null)
       {
@@ -170,7 +170,7 @@
       }
    }
 
-   protected String getPortletId(Object portletRef) throws PortletInvokerException
+   protected String getPortletId(PortletContext portletRef) throws PortletInvokerException
    {
       return ((PortletContext)portletRef).getId();
    }
@@ -180,7 +180,7 @@
       producer.invoke(invocation);
    }
 
-   protected ActionInvocation createAction(Object portletRef, AccessMode accessMode)
+   protected ActionInvocation createAction(PortletContext portletRef, AccessMode accessMode)
    {
       ActionContextImpl actionCtx = new ActionContextImpl();
       InstanceContextImpl instanceCtx = new InstanceContextImpl("blah", accessMode);
@@ -192,7 +192,7 @@
       return action;
    }
 
-   protected Object getImplicitClonedRef(ActionInvocation action)
+   protected PortletContext getImplicitClonedRef(ActionInvocation action)
    {
       InstanceContextImpl instanceCtx = (InstanceContextImpl)action.getInstanceContext();
       return instanceCtx.getClonedContext();

Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/state/RemoteStoreProducerStatefulPortletInvokerTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/state/RemoteStoreProducerStatefulPortletInvokerTestCase.java	2007-01-11 15:40:53 UTC (rev 6002)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/state/RemoteStoreProducerStatefulPortletInvokerTestCase.java	2007-01-12 23:32:39 UTC (rev 6003)
@@ -24,6 +24,7 @@
 
 import org.jboss.portal.portlet.invocation.ActionInvocation;
 import org.jboss.portal.portlet.test.InstanceContextImpl;
+import org.jboss.portal.portlet.PortletContext;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -36,7 +37,7 @@
       super(false);
    }
 
-   protected Object getModifiedPortletRef(ActionInvocation action)
+   protected PortletContext getModifiedPortletRef(ActionInvocation action)
    {
       InstanceContextImpl instanceCtx = (InstanceContextImpl)action.getInstanceContext();
       return instanceCtx.getModifiedContext();




More information about the portal-commits mailing list