[portal-commits] JBoss Portal SVN: r9218 - in branches/JBoss_Portal_Branch_2_6: core/src/main/org/jboss/portal/core/impl/portlet/state and 1 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Fri Nov 30 08:56:36 EST 2007


Author: julien at jboss.com
Date: 2007-11-30 08:56:36 -0500 (Fri, 30 Nov 2007)
New Revision: 9218

Modified:
   branches/JBoss_Portal_Branch_2_6/core/build.xml
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java
   branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/AbstractRegistrationPersistenceManagerTestCase.java
Log:
JBPORTAL-1826 : bug fix and test case for "Registration data is not properly persisted on updates"

Modified: branches/JBoss_Portal_Branch_2_6/core/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/build.xml	2007-11-30 13:47:54 UTC (rev 9217)
+++ branches/JBoss_Portal_Branch_2_6/core/build.xml	2007-11-30 13:56:36 UTC (rev 9218)
@@ -613,7 +613,7 @@
                <parameter name="CacheNaturalId" value="true"/>
                <parameter name="Config" value="persistent-jboss-beans.xml"/>
             </zest>
-         	
+
             <!--
             <zest todir="${test.reports}" name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
                   outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">

Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java	2007-11-30 13:47:54 UTC (rev 9217)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java	2007-11-30 13:56:36 UTC (rev 9218)
@@ -23,6 +23,7 @@
 package org.jboss.portal.core.impl.portlet.state;
 
 import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.util.MapAccessor;
 import org.jboss.portal.common.util.TypedMap;
 import org.jboss.portal.registration.Consumer;
 import org.jboss.portal.registration.Registration;
@@ -30,10 +31,10 @@
 
 import javax.xml.namespace.QName;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import java.util.HashMap;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -175,7 +176,7 @@
 
    public Map getProperties()
    {
-      return Collections.unmodifiableMap(persistentProperties);
+      return Collections.unmodifiableMap(properties);
    }
 
    public void setPropertyValueFor(QName propertyName, Object value)
@@ -289,13 +290,21 @@
       }
    };
 
+   private final MapAccessor accessor = new MapAccessor()
+   {
+      public Map getMap(boolean b)
+      {
+         return persistentProperties;
+      }
+   };
+
    /** Implement registration properties semantics, mostly validation and equality. */
    public class Properties extends TypedMap
    {
 
       public Properties()
       {
-         super(persistentProperties, KEY_CONVERTER, VALUE_CONVERTER);
+         super(accessor, KEY_CONVERTER, VALUE_CONVERTER);
       }
 
       public void setProperty(String propertyName, Object value)

Modified: branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/AbstractRegistrationPersistenceManagerTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/AbstractRegistrationPersistenceManagerTestCase.java	2007-11-30 13:47:54 UTC (rev 9217)
+++ branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/AbstractRegistrationPersistenceManagerTestCase.java	2007-11-30 13:56:36 UTC (rev 9218)
@@ -29,6 +29,7 @@
 import org.jboss.portal.registration.NoSuchRegistrationException;
 import org.jboss.portal.registration.Registration;
 import org.jboss.portal.registration.RegistrationPersistenceManager;
+import org.jboss.portal.common.util.MapBuilder;
 
 import javax.xml.namespace.QName;
 import java.util.ArrayList;
@@ -397,4 +398,40 @@
       assertEquals(null, getManager().getRegistration(regId));
       stopInteraction();
    }
+
+   public void testBulkUpdateRegistrationProperties() throws Exception
+   {
+      startInteraction();
+      ConsumerGroup group = getManager().createConsumerGroup("Foo");
+      Consumer consumer = getManager().createConsumer("Bar", "Bar");
+      group.addConsumer(consumer);
+      getManager().addRegistrationFor("Bar", registrationProperties);
+      stopInteraction();
+
+      //
+      startInteraction();
+      consumer = getManager().getConsumerById("Bar");
+      Registration reg = (Registration)consumer.getRegistrations().iterator().next();
+      registrationProperties.remove(new QName("prop1"));
+      reg.updateProperties(registrationProperties);
+      assertEquals(Collections.singletonMap(new QName("prop2"), "value2"), reg.getProperties());
+      stopInteraction();
+
+      //
+      startInteraction();
+      consumer = getManager().getConsumerById("Bar");
+      reg = (Registration)consumer.getRegistrations().iterator().next();
+      assertEquals(Collections.singletonMap(new QName("prop2"), "value2"), reg.getProperties());
+      registrationProperties.put(new QName("prop3"), "value3");
+      reg.updateProperties(registrationProperties);
+      assertEquals(MapBuilder.hashMap().put(new QName("prop2"), "value2").put(new QName("prop3"), "value3").get(), reg.getProperties());
+      stopInteraction();
+
+      //
+      startInteraction();
+      consumer = getManager().getConsumerById("Bar");
+      reg = (Registration)consumer.getRegistrations().iterator().next();
+      assertEquals(MapBuilder.hashMap().put(new QName("prop2"), "value2").put(new QName("prop3"), "value3").get(), reg.getProperties());
+      stopInteraction();
+   }
 }




More information about the portal-commits mailing list