You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2006/12/21 22:08:41 UTC

svn commit: r489461 [5/5] - in /incubator/qpid/branches/new_persistence/java: broker/src/main/java/org/apache/qpid/server/exchange/ broker/src/main/java/org/apache/qpid/server/handler/ broker/src/main/java/org/apache/qpid/server/protocol/ broker/src/ma...

Modified: incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java Thu Dec 21 13:08:38 2006
@@ -24,14 +24,22 @@
 import junit.framework.TestCase;
 
 import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
 
 import org.apache.mina.common.ByteBuffer;
+import org.apache.log4j.Logger;
+import org.apache.qpid.AMQPInvalidClassException;
 
 public class PropertyFieldTableTest extends TestCase
 {
 
-    //Test byte modification
+    private static final Logger _logger = Logger.getLogger(PropertyFieldTableTest.class);
 
+    /**
+     * Test that modifying a byte[] after setting property doesn't change property
+     */
     public void testByteModification()
     {
         PropertyFieldTable table = new PropertyFieldTable();
@@ -46,197 +54,518 @@
         assertBytesNotEqual(bytes, table.getBytes("bytes"));
     }
 
-    //Test replacement
-
+    /**
+     * Test that setting a similar named value replaces any previous value set on that name
+     */
     public void testReplacement()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
+        //Set a boolean value
         table1.setBoolean("value", true);
+        //Check size of table is correct (<Value length> + <type> + <Boolean length>)
+        int size = EncodingUtils.encodedShortStringLength("value") + 1 + EncodingUtils.encodedBooleanLength();
+        Assert.assertEquals(size, table1.getEncodedSize());
+
+        // reset value to an integer
         table1.setInteger("value", Integer.MAX_VALUE);
+
+        // Check the size has changed accordingly   (<Value length> + <type> + <Integer length>)
+        size = EncodingUtils.encodedShortStringLength("value") + 1 + EncodingUtils.encodedIntegerLength();
+        Assert.assertEquals(size, table1.getEncodedSize());
+
+        //Check boolean value is null
         Assert.assertEquals(null, table1.getBoolean("value"));
+        // ... and integer value is good
         Assert.assertEquals((Integer) Integer.MAX_VALUE, table1.getInteger("value"));
     }
 
-    //Test Lookups
 
-    public void testBooleanLookup()
+    /**
+     * Set a boolean and check that we can only get it back as a boolean and a string
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testBoolean()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
         table1.setBoolean("value", true);
+        Assert.assertTrue(table1.propertyExists("value"));
+
         //Test Getting right value back
         Assert.assertEquals((Boolean) true, table1.getBoolean("value"));
 
-        //Looking up an invalid value returns null
-        Assert.assertTrue(table1.getBoolean("Rubbish") == null);
+        //Check we don't get anything back for other gets
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(null, table1.getShort("value"));
+        Assert.assertEquals(null, table1.getCharacter("value"));
+        Assert.assertEquals(null, table1.getDouble("value"));
+        Assert.assertEquals(null, table1.getFloat("value"));
+        Assert.assertEquals(null, table1.getInteger("value"));
+        Assert.assertEquals(null, table1.getLong("value"));
+        Assert.assertEquals(null, table1.getBytes("value"));
 
-        //Try reading value as a string
+        //except value as a string
         Assert.assertEquals("true", table1.getString("value"));
+
+        //Try setting a null value and read it back
+        table1.put(PropertyFieldTable.Prefix.AMQP_BOOLEAN_PROPERTY_PREFIX, "value", null);
+
+        // Should be able to get the null back
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
+
+        // Table should now have zero size for encoding
+        checkEmpty(table1);
+
+        //Looking up an invalid value returns null
+        Assert.assertEquals(null, table1.getBoolean("Rubbish"));
     }
 
-    public void testByteLookup()
+    /**
+     * Set a byte and check that we can only get it back as a byte and a string
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testByte()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
-        table1.setByte("value", (byte) 1);
-        Assert.assertEquals((Byte) (byte) 1, table1.getByte("value"));
+        table1.setByte("value", Byte.MAX_VALUE);
+        Assert.assertTrue(table1.propertyExists("value"));
 
-        //Looking up an invalid value returns null
-        Assert.assertTrue(table1.getByte("Rubbish") == null);
+        //Tets lookups we shouldn't get anything back for other gets
+        //we should get right value back for this type ....
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        Assert.assertEquals(Byte.MAX_VALUE, (byte) table1.getByte("value"));
+        Assert.assertEquals(null, table1.getShort("value"));
+        Assert.assertEquals(null, table1.getCharacter("value"));
+        Assert.assertEquals(null, table1.getDouble("value"));
+        Assert.assertEquals(null, table1.getFloat("value"));
+        Assert.assertEquals(null, table1.getInteger("value"));
+        Assert.assertEquals(null, table1.getLong("value"));
+        Assert.assertEquals(null, table1.getBytes("value"));
+
+        //... and a the string value of it.
+        Assert.assertEquals("" + Byte.MAX_VALUE, table1.getString("value"));
+
+        //Try setting a null value and read it back
+        table1.put(PropertyFieldTable.Prefix.AMQP_BYTE_PROPERTY_PREFIX, "value", null);
+
+        // Should be able to get the null back
+        Assert.assertEquals(null, table1.getByte("value"));
+
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
+
+        // Table should now have zero size for encoding
+        checkEmpty(table1);
 
-        //Try reading value as a string
-        Assert.assertEquals("1", table1.getString("value"));
+        //Looking up an invalid value returns null
+        Assert.assertEquals(null, table1.getByte("Rubbish"));
     }
 
-    public void testShortLookup()
+    /**
+     * Set a short and check that we can only get it back as a short and a string
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testShort()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
         table1.setShort("value", Short.MAX_VALUE);
-        Assert.assertEquals((Short) Short.MAX_VALUE, table1.getShort("value"));
+        Assert.assertTrue(table1.propertyExists("value"));
 
-        //Looking up an invalid value returns null
-        Assert.assertTrue(table1.getShort("Rubbish") == null);
+        //Tets lookups we shouldn't get anything back for other gets
+        //we should get right value back for this type ....
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(Short.MAX_VALUE, (short) table1.getShort("value"));
+        Assert.assertEquals(null, table1.getCharacter("value"));
+        Assert.assertEquals(null, table1.getDouble("value"));
+        Assert.assertEquals(null, table1.getFloat("value"));
+        Assert.assertEquals(null, table1.getInteger("value"));
+        Assert.assertEquals(null, table1.getLong("value"));
+        Assert.assertEquals(null, table1.getBytes("value"));
 
-        //Try reading value as a string
+        //... and a the string value of it.
         Assert.assertEquals("" + Short.MAX_VALUE, table1.getString("value"));
+
+        //Try setting a null value and read it back
+        table1.put(PropertyFieldTable.Prefix.AMQP_SHORT_PROPERTY_PREFIX, "value", null);
+
+        // Should be able to get the null back
+        Assert.assertEquals(null, table1.getShort("value"));
+
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
+
+        // Table should now have zero size for encoding
+        checkEmpty(table1);
+
+        //Looking up an invalid value returns null
+        Assert.assertEquals(null, table1.getShort("Rubbish"));
     }
 
 
-    public void testCharLookup()
+    /**
+     * Set a char and check that we can only get it back as a char
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testChar()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
-        table1.setChar("value", 'b');
-        Assert.assertEquals((Character) 'b', table1.getCharacter("value"));
+        table1.setChar("value", 'c');
+        Assert.assertTrue(table1.propertyExists("value"));
 
-        //Looking up an invalid value returns null
-        Assert.assertTrue(table1.getCharacter("Rubbish") == null);
+        //Tets lookups we shouldn't get anything back for other gets
+        //we should get right value back for this type ....
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(null, table1.getShort("value"));
+        Assert.assertEquals('c', (char) table1.getCharacter("value"));
+        Assert.assertEquals(null, table1.getDouble("value"));
+        Assert.assertEquals(null, table1.getFloat("value"));
+        Assert.assertEquals(null, table1.getInteger("value"));
+        Assert.assertEquals(null, table1.getLong("value"));
+        Assert.assertEquals(null, table1.getBytes("value"));
 
-        //Try reading value as a string
-        Assert.assertEquals("b", table1.getString("value"));
+        //... and a the string value of it.
+        Assert.assertEquals("c", table1.getString("value"));
+
+        //Try setting a null value and read it back
+        table1.put(PropertyFieldTable.Prefix.AMQP_ASCII_CHARACTER_PROPERTY_PREFIX, "value", null);
+
+        try
+        {
+            table1.getString("value");
+            fail("Should throw NullPointerException");
+        }
+        catch (NullPointerException npe)
+        {
+            //Normal Path
+        }
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
+
+        // Table should now have zero size for encoding
+        checkEmpty(table1);
+
+        //Looking up an invalid value returns null
+        Assert.assertEquals(null, table1.getCharacter("Rubbish"));
     }
 
-    public void testDoubleLookup()
+
+    /**
+     * Set a double and check that we can only get it back as a double
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testDouble()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
         table1.setDouble("value", Double.MAX_VALUE);
-        Assert.assertEquals(Double.MAX_VALUE, table1.getDouble("value"));
+        Assert.assertTrue(table1.propertyExists("value"));
 
-        //Looking up an invalid value returns null
-        Assert.assertTrue(table1.getDouble("Rubbish") == null);
+        //Tets lookups we shouldn't get anything back for other gets
+        //we should get right value back for this type ....
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(null, table1.getShort("value"));
+        Assert.assertEquals(null, table1.getCharacter("value"));
+        Assert.assertEquals(Double.MAX_VALUE, (double) table1.getDouble("value"));
+        Assert.assertEquals(null, table1.getFloat("value"));
+        Assert.assertEquals(null, table1.getInteger("value"));
+        Assert.assertEquals(null, table1.getLong("value"));
+        Assert.assertEquals(null, table1.getBytes("value"));
 
-        //Try reading value as a string
+        //... and a the string value of it.
         Assert.assertEquals("" + Double.MAX_VALUE, table1.getString("value"));
 
+        //Try setting a null value and read it back
+        table1.put(PropertyFieldTable.Prefix.AMQP_DOUBLE_PROPERTY_PREFIX, "value", null);
+
+        Assert.assertEquals(null, table1.getDouble("value"));
+
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
+
+        // Table should now have zero size for encoding
+        checkEmpty(table1);
+
+        //Looking up an invalid value returns null
+        Assert.assertEquals(null, table1.getDouble("Rubbish"));
     }
 
-    public void testFloatLookup()
+
+    /**
+     * Set a float and check that we can only get it back as a float
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testFloat()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
         table1.setFloat("value", Float.MAX_VALUE);
-        Assert.assertEquals(Float.MAX_VALUE, table1.getFloat("value"));
+        Assert.assertTrue(table1.propertyExists("value"));
 
-        //Looking up an invalid value returns null
-        Assert.assertTrue(table1.getFloat("Rubbish") == null);
+        //Tets lookups we shouldn't get anything back for other gets
+        //we should get right value back for this type ....
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(null, table1.getShort("value"));
+        Assert.assertEquals(null, table1.getCharacter("value"));
+        Assert.assertEquals(null, table1.getDouble("value"));
+        Assert.assertEquals(Float.MAX_VALUE, (float) table1.getFloat("value"));
+        Assert.assertEquals(null, table1.getInteger("value"));
+        Assert.assertEquals(null, table1.getLong("value"));
+        Assert.assertEquals(null, table1.getBytes("value"));
 
-        //Try reading value as a string
+        //... and a the string value of it.
         Assert.assertEquals("" + Float.MAX_VALUE, table1.getString("value"));
 
+        //Try setting a null value and read it back
+        table1.put(PropertyFieldTable.Prefix.AMQP_FLOAT_PROPERTY_PREFIX, "value", null);
+
+        Assert.assertEquals(null, table1.getFloat("value"));
+
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
+
+        // Table should now have zero size for encoding
+        checkEmpty(table1);
+
+        //Looking up an invalid value returns null
+        Assert.assertEquals(null, table1.getFloat("Rubbish"));
     }
 
-    public void testIntLookup()
+
+    /**
+     * Set an int and check that we can only get it back as an int
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testInt()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
         table1.setInteger("value", Integer.MAX_VALUE);
-        Assert.assertEquals((Integer) Integer.MAX_VALUE, table1.getInteger("value"));
+        Assert.assertTrue(table1.propertyExists("value"));
 
-        //Looking up an invalid value returns null
-        Assert.assertTrue(table1.getInteger("Rubbish") == null);
+        //Tets lookups we shouldn't get anything back for other gets
+        //we should get right value back for this type ....
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(null, table1.getShort("value"));
+        Assert.assertEquals(null, table1.getCharacter("value"));
+        Assert.assertEquals(null, table1.getDouble("value"));
+        Assert.assertEquals(null, table1.getFloat("value"));
+        Assert.assertEquals(Integer.MAX_VALUE, (int) table1.getInteger("value"));
+        Assert.assertEquals(null, table1.getLong("value"));
+        Assert.assertEquals(null, table1.getBytes("value"));
 
-        //Try reading value as a string
+        //... and a the string value of it.
         Assert.assertEquals("" + Integer.MAX_VALUE, table1.getString("value"));
 
+        //Try setting a null value and read it back
+        table1.put(PropertyFieldTable.Prefix.AMQP_INT_PROPERTY_PREFIX, "value", null);
+
+        Assert.assertEquals(null, table1.getInteger("value"));
+
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
+
+        // Table should now have zero size for encoding
+        checkEmpty(table1);
+
+        //Looking up an invalid value returns null
+        Assert.assertEquals(null, table1.getInteger("Rubbish"));
     }
 
-    public void testLongLookup()
+
+    /**
+     * Set a long and check that we can only get it back as a long
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testLong()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
         table1.setLong("value", Long.MAX_VALUE);
-        Assert.assertEquals((Long) Long.MAX_VALUE, table1.getLong("value"));
+        Assert.assertTrue(table1.propertyExists("value"));
 
-        //Looking up an invalid value returns null
-        Assert.assertTrue(table1.getLong("Rubbish") == null);
+        //Tets lookups we shouldn't get anything back for other gets
+        //we should get right value back for this type ....
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(null, table1.getShort("value"));
+        Assert.assertEquals(null, table1.getCharacter("value"));
+        Assert.assertEquals(null, table1.getDouble("value"));
+        Assert.assertEquals(null, table1.getFloat("value"));
+        Assert.assertEquals(null, table1.getInteger("value"));
+        Assert.assertEquals(Long.MAX_VALUE, (long) table1.getLong("value"));
+        Assert.assertEquals(null, table1.getBytes("value"));
 
-        //Try reading value as a string
+        //... and a the string value of it.
         Assert.assertEquals("" + Long.MAX_VALUE, table1.getString("value"));
 
-    }
+        //Try setting a null value and read it back
+        table1.put(PropertyFieldTable.Prefix.AMQP_LONG_PROPERTY_PREFIX, "value", null);
 
-    public void testBytesLookup()
-    {
-        PropertyFieldTable table1 = new PropertyFieldTable();
-        byte[] bytes = {99, 98, 97, 96, 95};
-        table1.setBytes("bytes", bytes);
-        assertBytesEqual(bytes, table1.getBytes("bytes"));
+        Assert.assertEquals(null, table1.getLong("value"));
+
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
+
+        // Table should now have zero size for encoding
+        checkEmpty(table1);
 
         //Looking up an invalid value returns null
-        Assert.assertTrue(table1.getBytes("Rubbish") == null);
+        Assert.assertEquals(null, table1.getLong("Rubbish"));
     }
 
-    // Failed Lookups
 
-    public void testFailedBooleanLookup()
+    /**
+     * Set a double and check that we can only get it back as a double
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testBytes()
     {
-        PropertyFieldTable table1 = new PropertyFieldTable();
-        Assert.assertEquals(null, table1.getBoolean("int"));
-    }
+        byte[] bytes = {99, 98, 97, 96, 95};
 
-    public void testFailedByteLookup()
-    {
         PropertyFieldTable table1 = new PropertyFieldTable();
-        Assert.assertEquals(null, table1.getByte("int"));
-    }
+        table1.setBytes("value", bytes);
+        Assert.assertTrue(table1.propertyExists("value"));
 
-    public void testFailedBytesLookup()
-    {
-        PropertyFieldTable table1 = new PropertyFieldTable();
-        Assert.assertEquals(null, table1.getBytes("int"));
-    }
+        //Tets lookups we shouldn't get anything back for other gets
+        //we should get right value back for this type ....
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(null, table1.getShort("value"));
+        Assert.assertEquals(null, table1.getCharacter("value"));
+        Assert.assertEquals(null, table1.getDouble("value"));
+        Assert.assertEquals(null, table1.getFloat("value"));
+        Assert.assertEquals(null, table1.getInteger("value"));
+        Assert.assertEquals(null, table1.getLong("value"));
+        assertBytesEqual(bytes, table1.getBytes("value"));
+
+        //... and a the string value of it is null
+        Assert.assertEquals(null, table1.getString("value"));
+
+        //Try setting a null value and read it back
+        table1.put(PropertyFieldTable.Prefix.AMQP_BINARY_PROPERTY_PREFIX, "value", null);
+
+        Assert.assertEquals(null, table1.getBytes("value"));
+
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
 
-    public void testFailedCharLookup()
-    {
-        PropertyFieldTable table1 = new PropertyFieldTable();
-        Assert.assertEquals(null, table1.getCharacter("int"));
-    }
+        // Table should now have zero size for encoding
+        checkEmpty(table1);
 
-    public void testFailedDoubleLookup()
-    {
-        PropertyFieldTable table1 = new PropertyFieldTable();
-        Assert.assertEquals(null, table1.getDouble("int"));
+        //Looking up an invalid value returns null
+        Assert.assertEquals(null, table1.getBytes("Rubbish"));
     }
 
-    public void testFailedFloatLookup()
-    {
-        PropertyFieldTable table1 = new PropertyFieldTable();
-        Assert.assertEquals(null, table1.getFloat("int"));
+    /**
+     * Calls all methods that can be used to check the table is empty
+     * - getEncodedSize
+     * - isEmpty
+     * - size
+     *
+     * @param table to check is empty
+     */
+    private void checkEmpty(PropertyFieldTable table)
+    {
+        Assert.assertEquals(0, table.getEncodedSize());
+        Assert.assertTrue(table.isEmpty());
+        Assert.assertEquals(0, table.size());
+
+        Assert.assertEquals(0, table.keySet().size());
+        Assert.assertEquals(0, table.values().size());
+        Assert.assertEquals(0, table.entrySet().size());
     }
 
-    public void testFailedIntLookup()
-    {
-        PropertyFieldTable table1 = new PropertyFieldTable();
-        Assert.assertEquals(null, table1.getInteger("int"));
-    }
 
-    public void testFailedLongLookup()
+    /**
+     * Set a String and check that we can only get it back as a String
+     * Check that attempting to lookup a non existent value returns null
+     */
+    public void testString()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
-        Assert.assertEquals(null, table1.getLong("int"));
-    }
+        table1.setString("value", "Hello");
+        Assert.assertTrue(table1.propertyExists("value"));
 
-    public void testFailedShortLookup()
-    {
-        PropertyFieldTable table1 = new PropertyFieldTable();
-        Assert.assertEquals(null, table1.getShort("int"));
+        //Tets lookups we shouldn't get anything back for other gets
+        //we should get right value back for this type ....
+        Assert.assertEquals(null, table1.getBoolean("value"));
+        Assert.assertEquals(null, table1.getByte("value"));
+        Assert.assertEquals(null, table1.getShort("value"));
+        Assert.assertEquals(null, table1.getCharacter("value"));
+        Assert.assertEquals(null, table1.getDouble("value"));
+        Assert.assertEquals(null, table1.getFloat("value"));
+        Assert.assertEquals(null, table1.getInteger("value"));
+        Assert.assertEquals(null, table1.getLong("value"));
+        Assert.assertEquals(null, table1.getBytes("value"));
+        Assert.assertEquals("Hello", table1.getString("value"));
+
+        //Try setting a null value and read it back
+        table1.setString("value", null);
+
+        Assert.assertEquals(null, table1.getString("value"));
+
+        //but still contains the value
+        Assert.assertTrue(table1.containsKey("value"));
+
+        table1.remove("value");
+        //but after a remove it doesn't
+        Assert.assertFalse(table1.containsKey("value"));
+
+        checkEmpty(table1);
+
+        //Looking up an invalid value returns null
+        Assert.assertEquals(null, table1.getString("Rubbish"));
+
+        //Additional Test that haven't been covered for string
+        table1.setObject("value", "Hello");
+        //Check that it was set correctly
+        Assert.assertEquals("Hello", table1.getString("value"));
     }
 
-    public void testXML()
+
+    /**
+     * Test that the generated XML can be used to create a field table with the same values.
+     */
+    public void testValidXML()
     {
         PropertyFieldTable table1 = new PropertyFieldTable();
         table1.setBoolean("bool", true);
@@ -249,6 +578,8 @@
         table1.setInteger("int", Integer.MAX_VALUE);
         table1.setLong("long", Long.MAX_VALUE);
         table1.setShort("short", Short.MAX_VALUE);
+        table1.setString("string", "Hello");
+        table1.setString("null-string", null);
 
         table1.setObject("object-bool", true);
         table1.setObject("object-byte", Byte.MAX_VALUE);
@@ -259,14 +590,48 @@
         table1.setObject("object-int", Integer.MAX_VALUE);
         table1.setObject("object-long", Long.MAX_VALUE);
         table1.setObject("object-short", Short.MAX_VALUE);
+        table1.setObject("object-string", "Hello");
+
+        Assert.assertEquals(21, table1.size());
 
         String table1XML = table1.toString();
 
         PropertyFieldTable table2 = new PropertyFieldTable(table1XML);
 
         Assert.assertEquals(table1XML, table2.toString());
+
+        //Check that when bytes is written out as a string with no new line between items that it is read in ok.
+
+    }
+
+    /**
+     * Test that invalid input throws the correct Exception
+     */
+    public void testInvalidXML()
+    {
+        try
+        {
+            _logger.warn("Testing Invalid XML expecting IllegalArgumentException");
+            new PropertyFieldTable("Rubbish");
+            fail("IllegalArgumentException expected");
+        }
+        catch (IllegalArgumentException iae)
+        {
+            //normal path
+        }
+        try
+        {
+            _logger.warn("Testing Invalid XML expecting IllegalArgumentException");
+            new PropertyFieldTable("");
+            fail("IllegalArgumentException expected");
+        }
+        catch (IllegalArgumentException iae)
+        {
+            //normal path
+        }
     }
 
+
     public void testKeyEnumeration()
     {
         PropertyFieldTable table = new PropertyFieldTable();
@@ -298,6 +663,8 @@
         table.setInteger("int", Integer.MAX_VALUE);
         table.setLong("long", Long.MAX_VALUE);
         table.setShort("short", Short.MAX_VALUE);
+        table.setString("string", "Hello");
+        table.setString("null-string", null);
 
         table.setObject("object-bool", true);
         table.setObject("object-byte", Byte.MAX_VALUE);
@@ -308,6 +675,7 @@
         table.setObject("object-int", Integer.MAX_VALUE);
         table.setObject("object-long", Long.MAX_VALUE);
         table.setObject("object-short", Short.MAX_VALUE);
+        table.setObject("object-string", "Hello");
 
 
         Assert.assertEquals((Boolean) true, table.getBoolean("bool"));
@@ -319,6 +687,8 @@
         Assert.assertEquals((Integer) Integer.MAX_VALUE, table.getInteger("int"));
         Assert.assertEquals((Long) Long.MAX_VALUE, table.getLong("long"));
         Assert.assertEquals((Short) Short.MAX_VALUE, table.getShort("short"));
+        Assert.assertEquals("Hello", table.getString("string"));
+        Assert.assertEquals(null, table.getString("null-string"));
 
         Assert.assertEquals(true, table.getObject("object-bool"));
         Assert.assertEquals(Byte.MAX_VALUE, table.getObject("object-byte"));
@@ -329,6 +699,7 @@
         Assert.assertEquals(Integer.MAX_VALUE, table.getObject("object-int"));
         Assert.assertEquals(Long.MAX_VALUE, table.getObject("object-long"));
         Assert.assertEquals(Short.MAX_VALUE, table.getObject("object-short"));
+        Assert.assertEquals("Hello", table.getObject("object-string"));
     }
 
 
@@ -347,6 +718,8 @@
         table.setInteger("int", Integer.MAX_VALUE);
         table.setLong("long", Long.MAX_VALUE);
         table.setShort("short", Short.MAX_VALUE);
+        table.setString("string", "hello");
+        table.setString("null-string", null);
 
 
         final ByteBuffer buffer = ByteBuffer.allocate((int) table.getEncodedSize()); // FIXME XXX: Is cast a problem?
@@ -370,6 +743,9 @@
             Assert.assertEquals((Integer) Integer.MAX_VALUE, table2.getInteger("int"));
             Assert.assertEquals((Long) Long.MAX_VALUE, table2.getLong("long"));
             Assert.assertEquals((Short) Short.MAX_VALUE, table2.getShort("short"));
+            Assert.assertEquals("hello", table2.getString("string"));
+            Assert.assertEquals(null, table2.getString("null-string"));
+
         }
         catch (AMQFrameDecodingException e)
         {
@@ -380,7 +756,7 @@
 
     public void testEncodingSize()
     {
-        FieldTable result = FieldTableFactory.newFieldTable();
+        PropertyFieldTable result = new PropertyFieldTable();
         int size = 0;
 
         result.setBoolean("boolean", true);
@@ -468,62 +844,295 @@
 
     }
 
-    public void testEncodingSize1()
+//    public void testEncodingSize1()
+//    {
+//                PropertyFieldTable table = new PropertyFieldTable();
+//        int size = 0;
+//        result.put("one", 1L);
+//        size = EncodingUtils.encodedShortStringLength("one");
+//        size += 1 + EncodingUtils.encodedLongLength();
+//        assertEquals(size, result.getEncodedSize());
+//
+//        result.put("two", 2L);
+//        size += EncodingUtils.encodedShortStringLength("two");
+//        size += 1 + EncodingUtils.encodedLongLength();
+//        assertEquals(size, result.getEncodedSize());
+//
+//        result.put("three", 3L);
+//        size += EncodingUtils.encodedShortStringLength("three");
+//        size += 1 + EncodingUtils.encodedLongLength();
+//        assertEquals(size, result.getEncodedSize());
+//
+//        result.put("four", 4L);
+//        size += EncodingUtils.encodedShortStringLength("four");
+//        size += 1 + EncodingUtils.encodedLongLength();
+//        assertEquals(size, result.getEncodedSize());
+//
+//        result.put("five", 5L);
+//        size += EncodingUtils.encodedShortStringLength("five");
+//        size += 1 + EncodingUtils.encodedLongLength();
+//        assertEquals(size, result.getEncodedSize());
+//
+//        //fixme should perhaps be expanded to incorporate all types.
+//
+//        final ByteBuffer buffer = ByteBuffer.allocate((int) result.getEncodedSize()); // FIXME XXX: Is cast a problem?
+//
+//        result.writeToBuffer(buffer);
+//
+//        buffer.flip();
+//
+//        long length = buffer.getUnsignedInt();
+//
+//        try
+//        {
+//            PropertyFieldTable table2 = new PropertyFieldTable(buffer, length);
+//
+//            Assert.assertEquals((Long) 1L, table2.getLong("one"));
+//            Assert.assertEquals((Long) 2L, table2.getLong("two"));
+//            Assert.assertEquals((Long) 3L, table2.getLong("three"));
+//            Assert.assertEquals((Long) 4L, table2.getLong("four"));
+//            Assert.assertEquals((Long) 5L, table2.getLong("five"));
+//        }
+//        catch (AMQFrameDecodingException e)
+//        {
+//            e.printStackTrace();
+//            fail("PFT should be instantiated from bytes." + e.getCause());
+//        }
+//
+//    }
+
+
+    /**
+     * Additional test for setObject
+     */
+    public void testSetObject()
     {
-        FieldTable result = FieldTableFactory.newFieldTable();
-        int size = 0;
-        result.put("one", 1L);
-        size = EncodingUtils.encodedShortStringLength("one");
-        size += 1 + EncodingUtils.encodedLongLength();
-        assertEquals(size, result.getEncodedSize());
-
-        result.put("two", 2L);
-        size += EncodingUtils.encodedShortStringLength("two");
-        size += 1 + EncodingUtils.encodedLongLength();
-        assertEquals(size, result.getEncodedSize());
-
-        result.put("three", 3L);
-        size += EncodingUtils.encodedShortStringLength("three");
-        size += 1 + EncodingUtils.encodedLongLength();
-        assertEquals(size, result.getEncodedSize());
-
-        result.put("four", 4L);
-        size += EncodingUtils.encodedShortStringLength("four");
-        size += 1 + EncodingUtils.encodedLongLength();
-        assertEquals(size, result.getEncodedSize());
-
-        result.put("five", 5L);
-        size += EncodingUtils.encodedShortStringLength("five");
-        size += 1 + EncodingUtils.encodedLongLength();
-        assertEquals(size, result.getEncodedSize());
+        PropertyFieldTable table = new PropertyFieldTable();
 
-        //fixme should perhaps be expanded to incorporate all types.
+        //Try setting a non primative object
 
-        final ByteBuffer buffer = ByteBuffer.allocate((int) result.getEncodedSize()); // FIXME XXX: Is cast a problem?
+        try
+        {
+            table.setObject("value", this);
+            fail("Only primative values allowed in setObject");
+        }
+        catch (AMQPInvalidClassException iae)
+        {
+            //normal path
+        }
+        // so size should be zero
+        Assert.assertEquals(0, table.getEncodedSize());
+    }
 
-        result.writeToBuffer(buffer);
+    /**
+     * Additional test checkPropertyName doesn't accept Null
+     */
+    public void testCheckPropertyNameasNull()
+    {
+        PropertyFieldTable table = new PropertyFieldTable();
 
-        buffer.flip();
+        try
+        {
+            table.setObject(null, "String");
+            fail("Null property name is not allowed");
+        }
+        catch (IllegalArgumentException iae)
+        {
+            //normal path
+        }
+        // so size should be zero
+        Assert.assertEquals(0, table.getEncodedSize());
+    }
 
-        long length = buffer.getUnsignedInt();
+
+    /**
+     * Additional test checkPropertyName doesn't accept an empty String
+     */
+    public void testCheckPropertyNameasEmptyString()
+    {
+        PropertyFieldTable table = new PropertyFieldTable();
 
         try
         {
-            PropertyFieldTable table2 = new PropertyFieldTable(buffer, length);
+            table.setObject("", "String");
+            fail("empty property name is not allowed");
+        }
+        catch (IllegalArgumentException iae)
+        {
+            //normal path
+        }
+        // so size should be zero
+        Assert.assertEquals(0, table.getEncodedSize());
+    }
+
+
+    /**
+     * Additional test checkPropertyName doesn't accept an empty String
+     */
+    public void testCheckPropertyNamehasMaxLength()
+    {
+        PropertyFieldTable table = new PropertyFieldTable();
 
-            Assert.assertEquals((Long) 1L, table2.getLong("one"));
-            Assert.assertEquals((Long) 2L, table2.getLong("two"));
-            Assert.assertEquals((Long) 3L, table2.getLong("three"));
-            Assert.assertEquals((Long) 4L, table2.getLong("four"));
-            Assert.assertEquals((Long) 5L, table2.getLong("five"));
+        StringBuffer longPropertyName = new StringBuffer(129);
+
+        for (int i = 0; i < 129; i++)
+        {
+            longPropertyName.append("x");
         }
-        catch (AMQFrameDecodingException e)
+
+        try
         {
-            e.printStackTrace();
-            fail("PFT should be instantiated from bytes." + e.getCause());
+            table.setObject(longPropertyName.toString(), "String");
+            fail("property name must be < 128 characters");
+        }
+        catch (IllegalArgumentException iae)
+        {
+            //normal path
         }
+        // so size should be zero
+        Assert.assertEquals(0, table.getEncodedSize());
+    }
+
 
+    /**
+     * Additional test checkPropertyName starts with a letter
+     */
+    public void testCheckPropertyNameStartCharacterIsLetter()
+    {
+        PropertyFieldTable table = new PropertyFieldTable();
+
+        //Try a name that starts with a number
+        try
+        {
+            table.setObject("1", "String");
+            fail("property name must start with a letter");
+        }
+        catch (IllegalArgumentException iae)
+        {
+            //normal path
+        }
+        // so size should be zero
+        Assert.assertEquals(0, table.getEncodedSize());
+    }
+
+
+    /**
+     * Additional test checkPropertyName starts with a hash or a dollar
+     */
+    public void testCheckPropertyNameStartCharacterIsHashorDollar()
+    {
+        PropertyFieldTable table = new PropertyFieldTable();
+
+        //Try a name that starts with a number
+        try
+        {
+            table.setObject("#", "String");
+            table.setObject("$", "String");
+        }
+        catch (IllegalArgumentException iae)
+        {
+            fail("property name are allowed to start with # and $s");
+        }
     }
+
+
+    /**
+     * Additional test to test the contents of the table
+     */
+    public void testContents()
+    {
+        PropertyFieldTable table = new PropertyFieldTable();
+
+        table.put("StringProperty", "String");
+
+        Assert.assertTrue(table.containsValue("String"));
+
+        Assert.assertEquals("String", table.get("StringProperty"));
+
+        //Test Clear
+
+        table.clear();
+
+        checkEmpty(table);
+    }
+
+    /**
+     * Test the contents of the sets
+     */
+    public void testSets()
+    {
+
+        PropertyFieldTable table = new PropertyFieldTable();
+
+        table.put("n1", "1");
+        table.put("n2", "2");
+        table.put("n3", "3");
+
+        Iterator iterator = table.keySet().iterator();
+        Assert.assertEquals("n1", iterator.next());
+        Assert.assertEquals("n2", iterator.next());
+        Assert.assertEquals("n3", iterator.next());
+        Assert.assertFalse(iterator.hasNext());
+
+
+        iterator = table.values().iterator();
+        Assert.assertEquals("1", iterator.next());
+        Assert.assertEquals("2", iterator.next());
+        Assert.assertEquals("3", iterator.next());
+        Assert.assertFalse(iterator.hasNext());
+
+
+        iterator = table.entrySet().iterator();
+        Map.Entry entry = (Map.Entry) iterator.next();
+        Assert.assertEquals("n1", entry.getKey());
+        Assert.assertEquals("1", entry.getValue());
+        entry = (Map.Entry) iterator.next();
+        Assert.assertEquals("n2", entry.getKey());
+        Assert.assertEquals("2", entry.getValue());
+        entry = (Map.Entry) iterator.next();
+        Assert.assertEquals("n3", entry.getKey());
+        Assert.assertEquals("3", entry.getValue());
+        Assert.assertFalse(iterator.hasNext());
+
+
+    }
+
+
+    /**
+     * Test that all the values are preserved after a putAll
+     */
+    public void testPutAll()
+    {
+        Map map = new HashMap();
+
+        map.put("char", 'c');
+        map.put("double", Double.MAX_VALUE);
+        map.put("float", Float.MAX_VALUE);
+        map.put("int", Integer.MAX_VALUE);
+        map.put("long", Long.MAX_VALUE);
+        map.put("short", Short.MAX_VALUE);
+
+        PropertyFieldTable table = new PropertyFieldTable();
+
+        table.putAll(map);
+
+        Assert.assertEquals(6, table.size());
+
+        Assert.assertTrue(table.containsKey("char"));
+        Assert.assertEquals('c', (char) table.getCharacter("char"));
+        Assert.assertTrue(table.containsKey("double"));
+        Assert.assertEquals(Double.MAX_VALUE, table.getDouble("double"));
+        Assert.assertTrue(table.containsKey("float"));
+        Assert.assertEquals(Float.MAX_VALUE, table.getFloat("float"));
+        Assert.assertTrue(table.containsKey("int"));
+        Assert.assertEquals(Integer.MAX_VALUE, (int) table.getInteger("int"));
+        Assert.assertTrue(table.containsKey("long"));
+        Assert.assertEquals(Long.MAX_VALUE, (long) table.getLong("long"));
+        Assert.assertTrue(table.containsKey("short"));
+        Assert.assertEquals(Short.MAX_VALUE, (short) table.getShort("short"));
+        Assert.assertEquals(Short.MAX_VALUE, (short) table.getShort("short"));
+    }
+
 
     private void assertBytesEqual(byte[] expected, byte[] actual)
     {

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java Thu Dec 21 13:08:38 2006
@@ -26,6 +26,7 @@
 
 /**
  * The activator class controls the plug-in life cycle
+ * @author Bhupendra Bhardwaj
  */
 public class Activator extends AbstractUIPlugin
 {
@@ -44,7 +45,6 @@
 	}
 
 	/*
-	 * (non-Javadoc)
 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
 	 */
 	public void start(BundleContext context) throws Exception
@@ -53,7 +53,6 @@
 	}
 
 	/*
-	 * (non-Javadoc)
 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
 	 */
 	public void stop(BundleContext context) throws Exception
@@ -67,18 +66,19 @@
 	 *
 	 * @return the shared instance
 	 */
-	public static Activator getDefault() {
+	public static Activator getDefault()
+    {
 		return plugin;
 	}
 
 	/**
-	 * Returns an image descriptor for the image file at the given
-	 * plug-in relative path
+	 * Returns an image descriptor for the image file at the given plug-in relative path
 	 *
 	 * @param path the path
 	 * @return the image descriptor
 	 */
-	public static ImageDescriptor getImageDescriptor(String path) {
+	public static ImageDescriptor getImageDescriptor(String path)
+    {
 		return imageDescriptorFromPlugin(PLUGIN_ID, path);
 	}
 }

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java Thu Dec 21 13:08:38 2006
@@ -34,8 +34,8 @@
     static Shell shell = null;
 
     /*
-     * (non-Javadoc)
-     * 
+     * The call to createAndRunWorkbench will not return until the workbench is closed.
+     * The SWT event loop and other low-level logistics are handled inside this method.
      * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object)
      */
     public Object run(Object args) throws Exception

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java Thu Dec 21 13:08:38 2006
@@ -33,6 +33,10 @@
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.PlatformUI;
 
+/**
+ * Main Application Registry, which contains shared resources and map to all connected servers.
+ * @author Bhupendra Bhardwaj
+ */
 public abstract class ApplicationRegistry
 {
     private static ImageRegistry imageRegistry = new ImageRegistry();

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java Thu Dec 21 13:08:38 2006
@@ -28,6 +28,10 @@
 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
 
+/**
+ * 
+ * @author Bhupendra Bhardwaj
+ */
 public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor
 {
     public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer)
@@ -49,7 +53,7 @@
         configurer.setShowCoolBar(true);
         configurer.setShowStatusLine(false);
         
-        configurer.setTitle("Qpid Management Console");
+        configurer.setTitle(Constants.APPLICATION_NAME);
     }  
     
     public void postWindowCreate()

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java Thu Dec 21 13:08:38 2006
@@ -20,6 +20,11 @@
  */
 package org.apache.qpid.management.ui;
 
+/**
+ * Contains constants for the application
+ * @author Bhupendra Bhardwaj
+ *
+ */
 public class Constants
 {
     public final static String APPLICATION_NAME = "Qpid Management Console";

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java Thu Dec 21 13:08:38 2006
@@ -22,6 +22,11 @@
 
 import java.util.HashMap;
 
+/**
+ * Class representing a managed bean on the managed server
+ * @author Bhupendra Bhardwaj
+ *
+ */
 public abstract class ManagedBean extends ManagedObject
 {
     private String _uniqueName = "";

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java Thu Dec 21 13:08:38 2006
@@ -20,6 +20,10 @@
  */
 package org.apache.qpid.management.ui;
 
+/**
+ * Abstract class representing a managed object
+ * @author Bhupendra Bhardwaj
+ */
 public abstract class ManagedObject
 {
     private String _name;

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java Thu Dec 21 13:08:38 2006
@@ -20,6 +20,10 @@
  */
 package org.apache.qpid.management.ui;
 
+/**
+ * Class representing a server being managed eg. MBeanServer
+ * @author Bhupendra Bhardwaj
+ */
 public class ManagedServer extends ManagedObject
 {
     private String host;

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java Thu Dec 21 13:08:38 2006
@@ -25,6 +25,10 @@
 import org.eclipse.ui.IPageLayout;
 import org.eclipse.ui.IPerspectiveFactory;
 
+/**
+ * 
+ * @author Bhupendra Bhardwaj
+ */
 public class Perspective implements IPerspectiveFactory
 {
 	public void createInitialLayout(IPageLayout layout)
@@ -32,20 +36,9 @@
 		String editorArea = layout.getEditorArea();
 		layout.setEditorAreaVisible(false);
         
-		// standalone view meaning it can't be docked or stacked with other views,
-        // and it doesn't have a title bar.
-        
-		layout.addStandaloneView(NavigationView.ID,
-                                 true,
-                                 IPageLayout.LEFT,
-                                 0.25f,
-                                 editorArea);
-        
-        layout.addStandaloneView(MBeanView.ID,
-                true,
-                IPageLayout.RIGHT,
-                0.75f,
-                editorArea);
+		// standalone view meaning it can't be docked or stacked with other views, and it doesn't have a title bar.        
+		layout.addStandaloneView(NavigationView.ID, true, IPageLayout.LEFT, 0.25f, editorArea);
+        layout.addStandaloneView(MBeanView.ID, true, IPageLayout.RIGHT, 0.75f, editorArea);
 		
 		layout.getViewLayout(NavigationView.ID).setCloseable(false);
         layout.getViewLayout(MBeanView.ID).setCloseable(false);       

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java Thu Dec 21 13:08:38 2006
@@ -41,6 +41,7 @@
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.ManagedBean;
 import org.apache.qpid.management.ui.ManagedServer;
+import org.apache.qpid.management.ui.exceptions.ManagementConsoleException;
 import org.apache.qpid.management.ui.model.AttributeData;
 import org.apache.qpid.management.ui.model.ManagedAttributeModel;
 import org.apache.qpid.management.ui.model.NotificationInfoModel;
@@ -49,31 +50,47 @@
 import org.apache.qpid.management.ui.model.ParameterData;
 import org.apache.qpid.management.ui.views.ViewUtility;
 
-
+/**
+ * Utility class for all mbeanserver related operations. Keeps all JMX code out from view and model classes
+ * @author Bhupendra Bhardwaj
+ */
 public class MBeanUtility
 {
-
-    public static MBeanInfo getMBeanInfo(ManagedBean mbean)
-        throws IOException, JMException
+    /**
+     * Retrieves the MBeanInfo from MBeanServer and stores in the application registry
+     * @param mbean  managed bean
+     * @return MBeanInfo
+     * @throws Exception, if server connection is null or if server throws Exception
+     */
+    public static MBeanInfo getMBeanInfo(ManagedBean mbean) throws Exception
     {
         ManagedServer server = mbean.getServer();
         JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server);
 
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
         if (mbsc == null)
-            System.out.println("MBeanServerConnection does not exist in the Application registry.");
+        {
+            throw new ManagementConsoleException("Server connection is broken");
+        }
         
         JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         MBeanInfo mbeanInfo = mbsc.getMBeanInfo(jmxbean.getObjectName());
         serverRegistry.putMBeanInfo(mbean, mbeanInfo);
         
+        // populate the server registry with attribute and operation info
         getAttributes(mbean);
         getOperations(mbean);
         
         return mbeanInfo;
     }
     
-    
+    /**
+     * executes the MBean operation
+     * @param mbean
+     * @param opData
+     * @return MBean operation return value
+     * @throws Exception if server connection is broken or if operation execution fails on the mbean server
+     */
     public static Object execute(ManagedBean mbean, OperationData opData) throws Exception
     {
         String opName = opData.getName();
@@ -89,7 +106,6 @@
             {
                 signature[i] = params.get(i).getType();
                 values[i] = params.get(i).getValue();
-                System.out.println(params.get(i).getName() +  " : " + params.get(i).getValue());
             }
         }
         
@@ -99,48 +115,27 @@
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
         if (mbsc == null)
         {
-            System.out.println("MBeanServerConnection doesn't exist in the Application registry.");
+            throw new ManagementConsoleException("Server connection is broken");
             // TODO
-            // throw exception to check if the server is added 
-            // Or try and get the connection again if it was disconnected
-            return null;
+            // try and get the connection again if it was disconnected
         }
         JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         return mbsc.invoke(jmxbean.getObjectName(), opName, values, signature);
-        
-        /*
-        try
-        {
-            
-        }
-        catch(MBeanException ex)
-        {
-            ex.printStackTrace();
-            
-        } 
-        catch(OperationsException ex)
-        {
-            ex.printStackTrace();
-            
-        }
-        catch(JMException ex)
-        {
-            ex.printStackTrace();
-            ViewUtility.popupError(new Exception(ex), "Operation failed");
-        }
-        catch(IOException ex)
-        {
-            ex.printStackTrace();
-            ViewUtility.popupError(new Exception(ex), "Operation failed");
-        }
-        */
     }
     
+    /**
+     * @see MBeanUtility#handleException(ManagedBean, Exception)
+     */
     public static void handleException(Exception ex)
     {
         handleException(null, ex);
     }
     
+    /**
+     * handels the exception received. Shows the exception to the user in best suitable way
+     * @param mbean managed bean
+     * @param ex   Exception
+     */
     public static void handleException(ManagedBean mbean, Exception ex)
     {
         if (mbean == null)
@@ -161,17 +156,35 @@
         }
         else if (ex instanceof MBeanException)
         {
-            ViewUtility.popupInfoMessage(mbean.getName(), ex.getMessage());
+            String cause = ((MBeanException)ex).getTargetException().getMessage();
+            if (cause == null)
+                cause = ex.getMessage();
+            ViewUtility.popupInfoMessage(mbean.getName(), cause);
         }
-        else
+        else if (ex instanceof JMException)
+        {
+            ViewUtility.popupErrorMessage(mbean.getName(), ex.getMessage());
+        }
+        else if (ex instanceof ManagementConsoleException)
+        {
+            ViewUtility.popupErrorMessage(mbean.getName(), ex.getMessage());
+        }
+        else 
         {
             ViewUtility.popupError(mbean.getName(), "Error occured", ex);
         }
-        ex.printStackTrace();
+        //ex.printStackTrace();
     }
     
+    /**
+     * Registers the notification listener with the MBeanServer
+     * @param mbean   managed bean
+     * @param name    notification name
+     * @param type    notification type
+     * @throws Exception  if server connection is broken or if listener could not be created 
+     */
     public static void createNotificationlistener(ManagedBean mbean, String name, String type)
-        throws IOException, Exception
+        throws Exception
     {
         JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
@@ -180,23 +193,15 @@
         
         if (mbsc == null)
         {
-            throw new Exception("MBeanServer connection is broken");
+            throw new ManagementConsoleException("Server connection is broken");
         }
         mbsc.addNotificationListener(jmxbean.getObjectName(), serverRegistry.getNotificationListener(), null, null);
-        System.out.println("Listener created : " + jmxbean.getObjectName());
     }
     
     public static void removeNotificationListener(ManagedBean mbean, String name, String type) throws Exception
     {
-        //JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
         serverRegistry.removeNotificationListener(mbean, name, type);
-        //MBeanServerConnection mbsc = serverRegistry.getServerConnection();
-        
-        //if (mbsc != null)
-        //{
-          //  mbsc.removeNotificationListener(jmxbean.getObjectName(), serverRegistry.getNotificationListener());
-        //}
     }
     
     public static int refreshAttribute(ManagedBean mbean, String attribute) throws Exception
@@ -205,7 +210,9 @@
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
         
         if (mbsc == null)
-            throw new Exception("Server connection is not available for " + mbean.getUniqueName());
+        {
+            throw new ManagementConsoleException("Server connection is broken");
+        }
         
         Object value = mbsc.getAttribute(((JMXManagedObject)mbean).getObjectName(), attribute);
         
@@ -214,7 +221,13 @@
         return Integer.parseInt(String.valueOf(value));
     }
     
-    public static ManagedAttributeModel getAttributes(ManagedBean mbean)
+    /**
+     * Retrieves the attribute values from MBeanSever and stores in the server registry.
+     * @param mbean
+     * @return the attribute model
+     * @throws Exception if attributes can not be retrieved from MBeanServer
+     */
+    public static ManagedAttributeModel getAttributes(ManagedBean mbean) throws Exception
     {
         ObjectName objName = ((JMXManagedObject)mbean).getObjectName();
         String[] attributes = null;
@@ -243,29 +256,28 @@
             attributes = attributeModel.getAttributeNames().toArray(new String[0]);
         }
         
-        try
+        if (attributes.length != 0)
         {
-            if (attributes.length != 0)
+            list = mbsc.getAttributes(objName, attributes);
+            for (Iterator itr = list.iterator(); itr.hasNext();)
             {
-                list = mbsc.getAttributes(objName, attributes);
-                for (Iterator itr = list.iterator(); itr.hasNext();)
-                {
-                    Attribute attrib = (Attribute)itr.next();
-                    attributeModel.setAttributeValue(attrib.getName(), attrib.getValue());
-                }
+                Attribute attrib = (Attribute)itr.next();
+                attributeModel.setAttributeValue(attrib.getName(), attrib.getValue());
             }
-        }
-        catch (Exception ex)
-        {
-            ex.printStackTrace();
         }               
         
-        serverRegistry.setAttributeModel(mbean, attributeModel);
-        
+        serverRegistry.setAttributeModel(mbean, attributeModel);       
         return attributeModel;
     }
     
-    public static void updateAttribute(ManagedBean mbean, AttributeData attribute, String value)
+    /**
+     * Updates the attribute value of an MBean
+     * @param mbean
+     * @param attribute
+     * @param value
+     * @throws Exception if MBeanServer throws exception in updating the attribute value
+     */
+    public static void updateAttribute(ManagedBean mbean, AttributeData attribute, String value) throws Exception
     {
         JMXManagedObject jmxbean = (JMXManagedObject)mbean;
         JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
@@ -273,11 +285,7 @@
         MBeanServerConnection mbsc = serverRegistry.getServerConnection();
         
         Object newValue = value;
-        if (attribute.getDataType().equals(String.class.getName()))
-        {
-            
-        }
-        else if (attribute.getDataType().equals(Long.class.getName()))
+        if (attribute.getDataType().equals(Long.class.getName()))
         {
             newValue = new Long(Long.parseLong(value));
         }
@@ -286,24 +294,20 @@
             newValue = new Integer(Integer.parseInt(value));
         }
         
-        try
-        {
-            mbsc.setAttribute(jmxbean.getObjectName(), new Attribute(attribute.getName(), newValue));
-            
-            // Update the value in the registry, to avoid refreshing from mbsc
-            ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean);
-            attributeModel.setAttributeValue(attribute.getName(), newValue);
-        }
-        catch(Exception ex)
-        {
-            ex.printStackTrace();
-        }
+        mbsc.setAttribute(jmxbean.getObjectName(), new Attribute(attribute.getName(), newValue));           
+        // Update the value in the registry, to avoid refreshing from mbsc
+        ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean);
+        attributeModel.setAttributeValue(attribute.getName(), newValue);
     }
     
+    /**
+     * populates the operation data model in server registry for given mbean
+     * @param mbean
+     * @return operation data model
+     */
     public static OperationDataModel getOperations(ManagedBean mbean)
     {
         JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
-
         OperationDataModel dataModel = serverRegistry.getOperationModel(mbean);
         if (dataModel == null)
         {
@@ -322,6 +326,11 @@
         return dataModel;
     }
     
+    /**
+     * populates the notification in the server registry for given mbean
+     * @param mbean
+     * @return notification info model
+     */
     public static NotificationInfoModel[] getNotificationInfo(ManagedBean mbean)
     {
         

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java Thu Dec 21 13:08:38 2006
@@ -277,8 +277,16 @@
             {
                 public void widgetSelected(SelectionEvent e)
                 {
-                    // refresh the attributes list                
-                    refresh(_mbean);
+                    try
+                    {
+                        // refresh the attributes list                
+                        refresh(_mbean);
+                    }
+                    catch (Exception ex)
+                    {
+                        MBeanUtility.handleException(_mbean, ex);
+                    }
+                    
                 }
             });
     }
@@ -582,12 +590,19 @@
             {
                 public void widgetSelected(SelectionEvent event)
                 {
-                    Button button = (Button)event.widget;
-                    Text text = (Text)button.getData();
-                    AttributeData data = (AttributeData)button.getParent().getData();
-                    MBeanUtility.updateAttribute(_mbean, data, text.getText());
-                    button.getShell().close();
-                    refresh();
+                    try
+                    {
+                        Button button = (Button)event.widget;
+                        Text text = (Text)button.getData();
+                        AttributeData data = (AttributeData)button.getParent().getData();
+                        MBeanUtility.updateAttribute(_mbean, data, text.getText());
+                        button.getShell().close();
+                        refresh();
+                    }
+                    catch (Exception ex)
+                    {
+                        MBeanUtility.handleException(_mbean, ex);
+                    }
                 }
             });
         
@@ -612,7 +627,15 @@
             _tableViewer.setInput(null);
             return;
         }
-        ManagedAttributeModel attributesList = MBeanUtility.getAttributes(mbean);
+        ManagedAttributeModel attributesList = null;
+        try
+        {
+            attributesList = MBeanUtility.getAttributes(mbean);
+        }
+        catch(Exception ex)
+        {
+            MBeanUtility.handleException(_mbean, ex);
+        }
         _tableViewer.setInput(attributesList);
         _table.setItemCount(attributesList.getCount());
        

Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java?view=diff&rev=489461&r1=489460&r2=489461
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java Thu Dec 21 13:08:38 2006
@@ -595,15 +595,6 @@
         else
         {
             ViewUtility.disposeChildren(_resultsComposite);
-            /*
-            if (_resultsComposite == null || _resultsComposite.isDisposed())
-            {
-                _resultsComposite = _toolkit.createComposite(_form.getBody(), SWT.NONE);
-                GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
-                layoutData.verticalIndent = 20;
-                _resultsComposite.setLayoutData(layoutData);
-                _resultsComposite.setLayout(new GridLayout());
-            }*/
             populateResults(result, _resultsComposite);
             _resultsComposite.layout();
             _form.layout();