[jboss-cvs] JBoss Messaging SVN: r4401 - trunk/tests/src/org/jboss/messaging/tests/unit/core/util.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 6 07:23:39 EDT 2008


Author: jmesnil
Date: 2008-06-06 07:23:39 -0400 (Fri, 06 Jun 2008)
New Revision: 4401

Modified:
   trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java
Log:
added unit tests

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java	2008-06-06 10:56:20 UTC (rev 4400)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java	2008-06-06 11:23:39 UTC (rev 4401)
@@ -7,9 +7,6 @@
 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;
@@ -33,23 +30,82 @@
 
    // Public --------------------------------------------------------
 
+   private TypedProperties props;
+   private SimpleString key;
+
    public void testCopyContructor() throws Exception
    {
-      TypedProperties props = new TypedProperties();
-      props.putStringProperty(new SimpleString(randomString()), new SimpleString(randomString()));
+      props.putStringProperty(key, 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));
-      }
+      
+      assertTrue(copy.containsProperty(key));
+      assertEquals(props.getProperty(key), copy.getProperty(key));
    }
    
+   public void testClear() throws Exception
+   {
+      props.putStringProperty(key, new SimpleString(randomString()));
+
+      assertTrue(props.containsProperty(key));
+      assertNotNull(props.getProperty(key));
+      
+      props.clear();
+
+      assertFalse(props.containsProperty(key));
+      assertNull(props.getProperty(key));      
+   }
+   
+   public void testKey() throws Exception
+   {
+      props.putBooleanProperty(key, true);
+      boolean bool = (Boolean) props.getProperty(key);
+      assertEquals(true, bool);
+
+      props.putCharProperty(key, 'a');
+      char c = (Character) props.getProperty(key);
+      assertEquals('a', c);
+   }
+   
+   public void testNullProperty() throws Exception
+   {
+      props.putStringProperty(key, null);
+      assertTrue(props.containsProperty(key));
+      assertNull(props.getProperty(key));            
+   }
+   
+   public void testBooleanProperty() throws Exception
+   {
+      props.putBooleanProperty(key, true);
+      boolean bool = (Boolean) props.getProperty(key);
+      assertEquals(true, bool);
+      
+      props.putBooleanProperty(key, false);
+      bool = (Boolean) props.getProperty(key);
+      assertEquals(false, bool);
+   }
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      props = new TypedProperties();
+      key = new SimpleString(randomString());
+   }
+   
+   @Override
+   protected void tearDown() throws Exception
+   {
+      key = null;
+      props = null;
+
+      super.tearDown();
+   }
+   
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------




More information about the jboss-cvs-commits mailing list