[jboss-cvs] JBoss Messaging SVN: r4269 - in trunk: tests/src/org/jboss/messaging/tests/unit/core/util and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 21 09:59:19 EDT 2008


Author: jmesnil
Date: 2008-05-21 09:59:19 -0400 (Wed, 21 May 2008)
New Revision: 4269

Added:
   trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java
Modified:
   trunk/src/main/org/jboss/messaging/util/TypedProperties.java
Log:
fixed copy constructor (size attribute was not correctly set)

Modified: trunk/src/main/org/jboss/messaging/util/TypedProperties.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/TypedProperties.java	2008-05-21 13:59:09 UTC (rev 4268)
+++ trunk/src/main/org/jboss/messaging/util/TypedProperties.java	2008-05-21 13:59:19 UTC (rev 4269)
@@ -73,6 +73,7 @@
 	public TypedProperties(final TypedProperties other)
 	{	   
 		this.properties = other.properties == null ? null : new HashMap<SimpleString, PropertyValue>(other.properties);
+		this.size = other.size;
 	}
 	
 	public void putBooleanProperty(final SimpleString key, final boolean value)

Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java	2008-05-21 13:59:19 UTC (rev 4269)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.tests.unit.core.util;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.util.SimpleString;
+import org.jboss.messaging.util.TypedProperties;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class TypedPropertiesTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testCopyContructor() throws Exception
+   {
+      TypedProperties props = new TypedProperties();
+      props.putStringProperty(new SimpleString(randomString()), new SimpleString(randomString()));
+      
+      TypedProperties copy = new TypedProperties(props);
+      
+      assertEquals(props.encodeSize(), copy.encodeSize());
+      assertEquals(props.getPropertyNames(), copy.getPropertyNames());
+      Iterator<SimpleString> iter = props.getPropertyNames().iterator();
+      while (iter.hasNext())
+      {
+         SimpleString name = (SimpleString) iter.next();
+         assertEquals(props.getProperty(name), copy.getProperty(name));
+      }
+   }
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}




More information about the jboss-cvs-commits mailing list