Author: ritchiem
Date: Thu Dec  7 07:43:53 2006
New Revision: 483503

URL: http://svn.apache.org/viewvc?view=rev&rev=483503
Log:
QPID-9
BasicContentHeaderPropertiesTest.java & PropertyFieldTableTest.java updated to 
use EncodingUtils.java to calculate expected Sizes.
PropertyFieldTable.java - Updated to use wider range of encoded values, Rather 
than very wasteful XML encoding.
EncodingUtils.java - updated to centralise the new encodings.

added target to ignore on eclipse-plugin folder

Modified:
    
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
    
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
    
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
    
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
    incubator/qpid/trunk/qpid/java/management/eclipse-plugin/   (props changed)

Modified: 
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java?view=diff&rev=483503&r1=483502&r2=483503
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
 Thu Dec  7 07:43:53 2006
@@ -108,9 +108,7 @@
             {
                 encodedString[i] = (byte) cha[i];
             }
-            // TODO: check length fits in an unsigned byte
-            writeUnsignedByte(buffer, (short) encodedString.length);
-            buffer.put(encodedString);
+            writeBytes(buffer,encodedString);
         }
         else
         {
@@ -243,6 +241,7 @@
 
     /**
      * This is used for writing longstrs.
+     *
      * @param buffer
      * @param data
      */
@@ -363,97 +362,6 @@
         return buffer.getUnsignedInt();
     }
 
-    // Will barf with a NPE on a null input. Not sure whether it should return 
null or
-    // an empty field-table (which would be slower - perhaps unnecessarily).
-    //
-    // Some sample input and the result output:
-    //
-    // Input: "a=1" "a=2 c=3" "a=3 c=4 d" "a='four' b='five'" "a=bad"
-    //
-    //    Parsing <a=1>...
-    //    {a=1}
-    //    Parsing <a=2 c=3>...
-    //    {a=2, c=3}
-    //    Parsing <a=3 c=4 d>...
-    //    {a=3, c=4, d=null}
-    //    Parsing <a='four' b='five'>...
-    //    {a=four, b=five}
-    //    Parsing <a=bad>...
-    //    java.lang.IllegalArgumentException: a: Invalid integer in <bad> from 
<a=bad>.
-    //
-    public static FieldTable createFieldTableFromMessageSelector(String 
selector)
-    {
-        boolean debug = _logger.isDebugEnabled();
-
-        // TODO: Doesn't support embedded quotes properly.
-        String[] expressions = selector.split(" +");
-
-        FieldTable result = FieldTableFactory.newFieldTable();
-
-        for (int i = 0; i < expressions.length; i++)
-        {
-            String expr = expressions[i];
-
-            if (debug)
-            {
-                _logger.debug("Expression = <" + expr + ">");
-            }
-
-            int equals = expr.indexOf('=');
-
-            if (equals < 0)
-            {
-                // Existence check
-                result.put("S" + expr.trim(), null);
-            }
-            else
-            {
-                String key = expr.substring(0, equals).trim();
-                String value = expr.substring(equals + 1).trim();
-
-                if (debug)
-                {
-                    _logger.debug("Key = <" + key + ">, Value = <" + value + 
">");
-                }
-
-                if (value.charAt(0) == '\'')
-                {
-                    if (value.charAt(value.length() - 1) != '\'')
-                    {
-                        throw new IllegalArgumentException(key + ": Missing 
quote in <" + value + "> from <" + selector + ">.");
-                    }
-                    else
-                    {
-                        value = value.substring(1, value.length() - 1);
-
-                        result.put("S" + key, value);
-                    }
-                }
-                else
-                {
-                    try
-                    {
-                        int intValue = Integer.parseInt(value);
-
-                        result.put("i" + key, value);
-                    }
-                    catch (NumberFormatException e)
-                    {
-                        throw new IllegalArgumentException(key + ": Invalid 
integer in <" + value + "> from <" + selector + ">.");
-
-                    }
-                }
-            }
-        }
-
-        if (debug)
-        {
-            _logger.debug("Field-table created from <" + selector + "> is <" + 
result + ">");
-        }
-
-        return (result);
-
-    }
 
     static byte[] hexToByteArray(String id)
     {
@@ -526,24 +434,155 @@
         return (new String(convertToHexCharArray(from)));
     }
 
-    public static void main(String[] args)
+    private static char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', 
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+    //**** new methods
+
+    // BOOLEAN_PROPERTY_PREFIX
+
+    public static void writeBoolean(ByteBuffer buffer, Boolean aBoolean)
     {
-        for (int i = 0; i < args.length; i++)
-        {
-            String selector = args[i];
+        buffer.put((byte) (aBoolean ? 1 : 0));
+    }
+
+    public static Boolean readBoolean(ByteBuffer buffer)
+    {
+        byte packedValue = buffer.get();
+        return (packedValue == 1);
+    }
 
-            System.err.println("Parsing <" + selector + ">...");
+    public static int encodedBooleanLength()
+    {
+        return 1;
+    }
 
-            try
-            {
-                
System.err.println(createFieldTableFromMessageSelector(selector));
-            }
-            catch (IllegalArgumentException e)
-            {
-                System.err.println(e);
-            }
+    // BYTE_PROPERTY_PREFIX
+    public static void writeByte(ByteBuffer buffer, Byte aByte)
+    {
+        buffer.put(aByte);
+    }
+
+    public static Byte readByte(ByteBuffer buffer)
+    {
+        return buffer.get();
+    }
+
+    public static int encodedByteLength()
+    {
+        return 1;
+    }
+
+
+    // SHORT_PROPERTY_PREFIX
+    public static void writeShort(ByteBuffer buffer, Short aShort)
+    {
+        buffer.putShort(aShort);
+    }
+
+    public static Short readShort(ByteBuffer buffer)
+    {
+        return buffer.getShort();
+    }
+
+    public static int encodedShortLength()
+    {
+        return 2;
+    }
+
+    // INTEGER_PROPERTY_PREFIX
+    public static void writeInteger(ByteBuffer buffer, Integer aInteger)
+    {
+        buffer.putInt(aInteger);
+    }
+
+    public static Integer readInteger(ByteBuffer buffer)
+    {
+        return buffer.getInt();
+    }
+
+    public static int encodedIntegerLength()
+    {
+        return 4;
+    }
+
+    // LONG_PROPERTY_PREFIX
+    public static void writeLong(ByteBuffer buffer, Long aLong)
+    {
+        buffer.putLong(aLong);
+    }
+
+    public static Long readLong(ByteBuffer buffer)
+    {
+        return buffer.getLong();
+    }
+
+    public static int encodedLongLength()
+    {
+        return 8;
+    }
+
+    // Float_PROPERTY_PREFIX
+    public static void writeFloat(ByteBuffer buffer, Float aFloat)
+    {
+        buffer.putFloat(aFloat);
+    }
+
+    public static Float readFloat(ByteBuffer buffer)
+    {
+        return buffer.getFloat();
+    }
+
+    public static int encodedFloatLength()
+    {
+        return 4;
+    }
+
+
+    // Double_PROPERTY_PREFIX
+    public static void writeDouble(ByteBuffer buffer, Double aDouble)
+    {
+        buffer.putDouble(aDouble);
+    }
+
+    public static Double readDouble(ByteBuffer buffer)
+    {
+        return buffer.getDouble();
+    }
+
+    public static int encodedDoubleLength()
+    {
+        return 8;
+    }
+
+
+    public static byte[] readBytes(ByteBuffer buffer)
+    {
+        short length = buffer.getUnsigned();
+        if (length == 0)
+        {
+            return null;
+        }
+        else
+        {
+            byte[] dataBytes = new byte[length];
+            buffer.get(dataBytes, 0, length);
+
+            return dataBytes;
         }
     }
 
-    private static char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', 
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+    public static void writeBytes(ByteBuffer buffer, byte[] data)
+    {
+        if (data != null)
+        {
+            // TODO: check length fits in an unsigned byte            
+            writeUnsignedByte(buffer, (short) data.length);
+            buffer.put(data);
+        }
+        else
+        {
+            // really writing out unsigned byte
+            buffer.put((byte) 0);
+        }
+    }
 }

Modified: 
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java?view=diff&rev=483503&r1=483502&r2=483503
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
 Thu Dec  7 07:43:53 2006
@@ -42,17 +42,21 @@
     public static final char AMQP_UNSIGNEDINT_PROPERTY_PREFIX = 'I';
     public static final char AMQP_TIMESTAMP_PROPERTY_PREFIX = 'T';
     public static final char AMQP_STRING_PROPERTY_PREFIX = 'S';
+    public static final char AMQP_ASCII_STRING_PROPERTY_PREFIX = 'c';
+    public static final char AMQP_WIDE_STRING_PROPERTY_PREFIX = 'C';
+    public static final char AMQP_BINARY_PROPERTY_PREFIX = 'x';
 
-    public static final char BOOLEAN_PROPERTY_PREFIX = 'B';
+    public static final char BOOLEAN_PROPERTY_PREFIX = 't';
     public static final char BYTE_PROPERTY_PREFIX = 'b';
     public static final char SHORT_PROPERTY_PREFIX = 's';
     public static final char INT_PROPERTY_PREFIX = 'i';
     public static final char LONG_PROPERTY_PREFIX = 'l';
     public static final char FLOAT_PROPERTY_PREFIX = 'f';
     public static final char DOUBLE_PROPERTY_PREFIX = 'd';
+
     public static final char STRING_PROPERTY_PREFIX = 
AMQP_STRING_PROPERTY_PREFIX;
-    public static final char CHAR_PROPERTY_PREFIX = 'c';
-    public static final char BYTES_PROPERTY_PREFIX = 'y';
+    public static final char CHAR_PROPERTY_PREFIX = 
AMQP_ASCII_STRING_PROPERTY_PREFIX;
+    public static final char BYTES_PROPERTY_PREFIX = 
AMQP_BINARY_PROPERTY_PREFIX;
 
     //Our custom prefix for encoding across the wire
     private static final char XML_PROPERTY_PREFIX = 'X';
@@ -121,7 +125,7 @@
         {
             return null;
         }
-        
+
         if (type.equals("" + prefix))
         {
             return _properties.get(propertyName);
@@ -963,22 +967,59 @@
             switch (propertyPrefix)
             {
 
+                case BOOLEAN_PROPERTY_PREFIX:
+                    buffer.put((byte) BOOLEAN_PROPERTY_PREFIX);
+                    EncodingUtils.writeBoolean(buffer, (Boolean) value);
+                    break;
+                case BYTE_PROPERTY_PREFIX:
+                    buffer.put((byte) BYTE_PROPERTY_PREFIX);
+                    EncodingUtils.writeByte(buffer, (Byte) value);
+                    break;
+                case SHORT_PROPERTY_PREFIX:
+                    buffer.put((byte) SHORT_PROPERTY_PREFIX);
+                    EncodingUtils.writeShort(buffer, (Short) value);
+                    break;
+                case INT_PROPERTY_PREFIX:
+                    buffer.put((byte) INT_PROPERTY_PREFIX);
+                    EncodingUtils.writeInteger(buffer, (Integer) value);
+                    break;
+                case AMQP_UNSIGNEDINT_PROPERTY_PREFIX: // Currently we don't 
create these
+                    buffer.put((byte) AMQP_UNSIGNEDINT_PROPERTY_PREFIX);
+                    EncodingUtils.writeUnsignedInteger(buffer, (Long) value);
+                    break;
+                case LONG_PROPERTY_PREFIX:
+                    buffer.put((byte) LONG_PROPERTY_PREFIX);
+                    EncodingUtils.writeLong(buffer, (Long) value);
+                    break;
+                case FLOAT_PROPERTY_PREFIX:
+                    buffer.put((byte) FLOAT_PROPERTY_PREFIX);
+                    EncodingUtils.writeFloat(buffer, (Float) value);
+                    break;
+                case DOUBLE_PROPERTY_PREFIX:
+                    buffer.put((byte) DOUBLE_PROPERTY_PREFIX);
+                    EncodingUtils.writeDouble(buffer, (Double) value);
+                    break;
+
+                case AMQP_WIDE_STRING_PROPERTY_PREFIX:
+                    //case AMQP_STRING_PROPERTY_PREFIX:
                 case STRING_PROPERTY_PREFIX:
                     // TODO: look at using proper charset encoder
                     buffer.put((byte) STRING_PROPERTY_PREFIX);
                     EncodingUtils.writeLongStringBytes(buffer, (String) value);
                     break;
 
-                case AMQP_UNSIGNEDINT_PROPERTY_PREFIX:
-                case LONG_PROPERTY_PREFIX:
-                case INT_PROPERTY_PREFIX:
-                case BOOLEAN_PROPERTY_PREFIX:
-                case BYTE_PROPERTY_PREFIX:
-                case SHORT_PROPERTY_PREFIX:
-                case FLOAT_PROPERTY_PREFIX:
-                case DOUBLE_PROPERTY_PREFIX:
+                    //case AMQP_ASCII_STRING_PROPERTY_PREFIX:
                 case CHAR_PROPERTY_PREFIX:
+                    // TODO: look at using proper charset encoder
+                    buffer.put((byte) CHAR_PROPERTY_PREFIX);
+                    EncodingUtils.writeShortStringBytes(buffer, "" + 
(Character) value);
+                    break;
+
                 case BYTES_PROPERTY_PREFIX:
+                    buffer.put((byte) BYTES_PROPERTY_PREFIX);
+                    EncodingUtils.writeBytes(buffer, (byte[]) value);
+                    break;
+
                 case XML_PROPERTY_PREFIX:
                     // Encode as XML
                     buffer.put((byte) XML_PROPERTY_PREFIX);
@@ -986,7 +1027,6 @@
                     break;
                 default:
                 {
-
                     // Should never get here
                     throw new IllegalArgumentException("Key '" + propertyName 
+ "': Unsupported type in field table, type: " + ((value == null) ? 
"null-object" : value.getClass()));
                 }
@@ -1011,18 +1051,42 @@
 
             switch (type)
             {
-                case STRING_PROPERTY_PREFIX:
-                    value = EncodingUtils.readLongString(buffer);
-                    break;
-                case LONG_PROPERTY_PREFIX:
-                case INT_PROPERTY_PREFIX:
                 case BOOLEAN_PROPERTY_PREFIX:
+                    value = EncodingUtils.readBoolean(buffer);
+                    break;
                 case BYTE_PROPERTY_PREFIX:
+                    value = EncodingUtils.readByte(buffer);
+                    break;
                 case SHORT_PROPERTY_PREFIX:
+                    value = EncodingUtils.readShort(buffer);
+                    break;
+                case INT_PROPERTY_PREFIX:
+                    value = EncodingUtils.readInteger(buffer);
+                    break;
+                case AMQP_UNSIGNEDINT_PROPERTY_PREFIX:// This will only fit in 
a long
+                case LONG_PROPERTY_PREFIX:
+                    value = EncodingUtils.readLong(buffer);
+                    break;
                 case FLOAT_PROPERTY_PREFIX:
+                    value = EncodingUtils.readFloat(buffer);
+                    break;
                 case DOUBLE_PROPERTY_PREFIX:
+                    value = EncodingUtils.readDouble(buffer);
+                    break;
+
+                    // TODO: use proper charset decoder
+                case AMQP_WIDE_STRING_PROPERTY_PREFIX:
+                    //case AMQP_STRING_PROPERTY_PREFIX:
+                case STRING_PROPERTY_PREFIX:
+                    value = EncodingUtils.readLongString(buffer);
+                    break;
+                    //case AMQP_ASCII_STRING_PROPERTY_PREFIX:
                 case CHAR_PROPERTY_PREFIX:
+                    value = EncodingUtils.readShortString(buffer).charAt(0);
+                    break;
                 case BYTES_PROPERTY_PREFIX:
+                    value = EncodingUtils.readBytes(buffer);
+                    break;
                 case XML_PROPERTY_PREFIX:
                     processXMLLine(EncodingUtils.readLongString(buffer));
                     break;
@@ -1066,19 +1130,39 @@
 
         switch (propertyPrefix)
         {
-            // the extra byte if for the type indicator that is written out
-            case STRING_PROPERTY_PREFIX:
-                encodingSize = 1 + 
EncodingUtils.encodedLongStringLength((String) value);
-                break;
-            case LONG_PROPERTY_PREFIX:
-            case INT_PROPERTY_PREFIX:
             case BOOLEAN_PROPERTY_PREFIX:
+                encodingSize = 1 + EncodingUtils.encodedBooleanLength();
+                break;
             case BYTE_PROPERTY_PREFIX:
+                encodingSize = 1 + EncodingUtils.encodedByteLength();
+                break;
             case SHORT_PROPERTY_PREFIX:
+                encodingSize = 1 + EncodingUtils.encodedShortLength();
+                break;
+            case INT_PROPERTY_PREFIX:
+                encodingSize = 1 + EncodingUtils.encodedIntegerLength();
+                break;
+            case LONG_PROPERTY_PREFIX:
+                encodingSize = 1 + EncodingUtils.encodedLongLength();
+                break;
             case FLOAT_PROPERTY_PREFIX:
+                encodingSize = 1 + EncodingUtils.encodedFloatLength();
+                break;
             case DOUBLE_PROPERTY_PREFIX:
+                encodingSize = 1 + EncodingUtils.encodedDoubleLength();
+                break;
+            case AMQP_WIDE_STRING_PROPERTY_PREFIX:
+                //case AMQP_STRING_PROPERTY_PREFIX:
+            case STRING_PROPERTY_PREFIX:
+                encodingSize = 1 + 
EncodingUtils.encodedLongStringLength((String) value);
+                break;
+                //case AMQP_ASCII_STRING_PROPERTY_PREFIX:
             case CHAR_PROPERTY_PREFIX:
+                encodingSize = 1 + EncodingUtils.encodedShortStringLength("" + 
(Character) value);
+                break;
             case BYTES_PROPERTY_PREFIX:
+                encodingSize = 1 + ((byte[]) value).length;
+                break;
             case XML_PROPERTY_PREFIX:
                 encodingSize = 1 + 
EncodingUtils.encodedLongStringLength(valueAsXML(name, value));
                 break;

Modified: 
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java?view=diff&rev=483503&r1=483502&r2=483503
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
 Thu Dec  7 07:43:53 2006
@@ -27,7 +27,8 @@
 import junit.framework.TestCase;
 
 
-public class BasicContentHeaderPropertiesTest extends TestCase {
+public class BasicContentHeaderPropertiesTest extends TestCase
+{
 
     BasicContentHeaderProperties _testProperties;
     PropertyFieldTable _testTable;
@@ -37,123 +38,155 @@
     /**
      * Currently only test setting/getting String, int and boolean props
      */
-    public BasicContentHeaderPropertiesTest() {
-         _testProperties = new BasicContentHeaderProperties();
+    public BasicContentHeaderPropertiesTest()
+    {
+        _testProperties = new BasicContentHeaderProperties();
     }
 
     public void setUp()
     {
         HashMap _testMap = new HashMap(10);
-        _testMap.put("TestString",_testString);
-        _testMap.put("Testint",_testint);
+        _testMap.put("TestString", _testString);
+        _testMap.put("Testint", _testint);
         _testTable = new PropertyFieldTable();
         _testTable.putAll(_testMap);
         _testProperties = new BasicContentHeaderProperties();
         _testProperties.setHeaders(_testTable);
     }
 
-    public void testGetPropertyListSize() {
+    public void testGetPropertyListSize()
+    {
         //needs a better test but at least we're exercising the code !
+         // FT size is encoded in an int
+        int expectedSize = EncodingUtils.encodedIntegerLength();
+
+        expectedSize += EncodingUtils.encodedShortStringLength("TestInt");
+        // 1 is for the Encoding Letter. here an 'i'
+        expectedSize += 1 + EncodingUtils.encodedIntegerLength();
+
+        expectedSize += EncodingUtils.encodedShortStringLength("TestString");
+        // 1 is for the Encoding Letter. here an 'S'
+        expectedSize += 1 + EncodingUtils.encodedLongStringLength(_testString);
+
+
         int size = _testProperties.getPropertyListSize();
-        assertEquals(83,size);
+
+        assertEquals(expectedSize, size);
     }
 
-    public void testGetSetPropertyFlags() {
+    public void testGetSetPropertyFlags()
+    {
         _testProperties.setPropertyFlags(99);
-        assertEquals(99,_testProperties.getPropertyFlags());
+        assertEquals(99, _testProperties.getPropertyFlags());
     }
 
-    public void testWritePropertyListPayload() {
+    public void testWritePropertyListPayload()
+    {
         ByteBuffer buf = ByteBuffer.allocate(300);
         _testProperties.writePropertyListPayload(buf);
     }
 
-    public void testPopulatePropertiesFromBuffer() throws Exception {
+    public void testPopulatePropertiesFromBuffer() throws Exception
+    {
         ByteBuffer buf = ByteBuffer.allocate(300);
-        _testProperties.populatePropertiesFromBuffer(buf,99,99);
+        _testProperties.populatePropertiesFromBuffer(buf, 99, 99);
     }
 
-    public void testSetGetContentType() {
+    public void testSetGetContentType()
+    {
         String contentType = "contentType";
         _testProperties.setContentType(contentType);
-        assertEquals(contentType,_testProperties.getContentType());
+        assertEquals(contentType, _testProperties.getContentType());
     }
 
-    public void testSetGetEncoding() {
+    public void testSetGetEncoding()
+    {
         String encoding = "encoding";
         _testProperties.setEncoding(encoding);
-        assertEquals(encoding,_testProperties.getEncoding());
+        assertEquals(encoding, _testProperties.getEncoding());
     }
 
-    public void testSetGetHeaders() {
+    public void testSetGetHeaders()
+    {
         _testProperties.setHeaders(_testTable);
-        assertEquals(_testTable,_testProperties.getHeaders());
+        assertEquals(_testTable, _testProperties.getHeaders());
     }
 
-    public void testSetGetDeliveryMode() {
+    public void testSetGetDeliveryMode()
+    {
         byte deliveryMode = 1;
         _testProperties.setDeliveryMode(deliveryMode);
-        assertEquals(deliveryMode,_testProperties.getDeliveryMode());
+        assertEquals(deliveryMode, _testProperties.getDeliveryMode());
     }
 
-    public void testSetGetPriority() {
+    public void testSetGetPriority()
+    {
         byte priority = 1;
         _testProperties.setPriority(priority);
-        assertEquals(priority,_testProperties.getPriority());
+        assertEquals(priority, _testProperties.getPriority());
     }
 
-    public void testSetGetCorrelationId() {
+    public void testSetGetCorrelationId()
+    {
         String correlationId = "correlationId";
         _testProperties.setCorrelationId(correlationId);
-        assertEquals(correlationId,_testProperties.getCorrelationId());
+        assertEquals(correlationId, _testProperties.getCorrelationId());
     }
 
-    public void testSetGetReplyTo() {
+    public void testSetGetReplyTo()
+    {
         String replyTo = "replyTo";
         _testProperties.setReplyTo(replyTo);
-        assertEquals(replyTo,_testProperties.getReplyTo());
+        assertEquals(replyTo, _testProperties.getReplyTo());
     }
 
-    public void testSetGetExpiration() {
+    public void testSetGetExpiration()
+    {
         long expiration = 999999999;
         _testProperties.setExpiration(expiration);
-        assertEquals(expiration,_testProperties.getExpiration());
+        assertEquals(expiration, _testProperties.getExpiration());
     }
 
-    public void testSetGetMessageId() {
+    public void testSetGetMessageId()
+    {
         String messageId = "messageId";
         _testProperties.setMessageId(messageId);
-        assertEquals(messageId,_testProperties.getMessageId());
+        assertEquals(messageId, _testProperties.getMessageId());
     }
 
-    public void testSetGetTimestamp() {
+    public void testSetGetTimestamp()
+    {
         long timestamp = 999999999;
         _testProperties.setTimestamp(timestamp);
-        assertEquals(timestamp,_testProperties.getTimestamp());
+        assertEquals(timestamp, _testProperties.getTimestamp());
     }
 
-    public void testSetGetType() {
+    public void testSetGetType()
+    {
         String type = "type";
         _testProperties.setType(type);
-        assertEquals(type,_testProperties.getType());
+        assertEquals(type, _testProperties.getType());
     }
 
-    public void testSetGetUserId() {
+    public void testSetGetUserId()
+    {
         String userId = "userId";
         _testProperties.setUserId(userId);
-        assertEquals(userId,_testProperties.getUserId());
+        assertEquals(userId, _testProperties.getUserId());
     }
 
-    public void testSetGetAppId() {
+    public void testSetGetAppId()
+    {
         String appId = "appId";
         _testProperties.setAppId(appId);
-        assertEquals(appId,_testProperties.getAppId());
+        assertEquals(appId, _testProperties.getAppId());
     }
 
-    public void testSetGetClusterId() {
+    public void testSetGetClusterId()
+    {
         String clusterId = "clusterId";
         _testProperties.setClusterId(clusterId);
-        assertEquals(clusterId,_testProperties.getClusterId());
+        assertEquals(clusterId, _testProperties.getClusterId());
     }
 
 }

Modified: 
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java?view=diff&rev=483503&r1=483502&r2=483503
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
 Thu Dec  7 07:43:53 2006
@@ -329,35 +329,28 @@
         FieldTable result = FieldTableFactory.newFieldTable();
         int size = 0;
         result.put("one", 1L);
-        // size is 1(size) + bytes for short string
-        size = 1 + 3; // 1 + key length
-        // or size is 1(the type) + number of bytes (4bytes worth) + bytes
-        size += 1 + 4;                 // 1 + 4 + value length
-        size += "<long name='one'>1</long>".length(); // this is the xml 
encoding for a long.
+        size = EncodingUtils.encodedShortStringLength("one");
+        size += 1 + EncodingUtils.encodedLongLength();
         assertEquals(size, result.getEncodedSize());
 
         result.put("two", 2L);
-        size += 1 + 3; // 1 + key length
-        size += 1 + 4;                 // 1 + 4 + value length
-        size += "<long name='two'>2</long>".length(); // this is the xml 
encoding for a long.
+        size += EncodingUtils.encodedShortStringLength("two");
+        size += 1 + EncodingUtils.encodedLongLength();
         assertEquals(size, result.getEncodedSize());
 
         result.put("three", 3L);
-        size += 1 + 5; // 1 + key length
-        size += 1 + 4;                 // 1 + 4 + value length
-        size += "<long name='three'>3</long>".length(); // this is the xml 
encoding for a long.
+        size += EncodingUtils.encodedShortStringLength("three");
+        size += 1 + EncodingUtils.encodedLongLength();
         assertEquals(size, result.getEncodedSize());
 
         result.put("four", 4L);
-        size += 1 + 4; // 1 + key length
-        size += 1 + 4;                 // 1 + 4 + value length
-        size += "<long name='four'>4</long>".length(); // this is the xml 
encoding for a long.
+        size += EncodingUtils.encodedShortStringLength("four");
+        size += 1 + EncodingUtils.encodedLongLength();
         assertEquals(size, result.getEncodedSize());
 
         result.put("five", 5L);
-        size += 1 + 4; // 1 + key length
-        size += 1 + 4;                 // 1 + 4 + value length
-        size += "<long name='five'>5</long>".length(); // this is the xml 
encoding for a long.
+        size += EncodingUtils.encodedShortStringLength("five");
+        size += 1 + EncodingUtils.encodedLongLength();
         assertEquals(size, result.getEncodedSize());
 
         //fixme should perhaps be expanded to incorporate all types.

Propchange: incubator/qpid/trunk/qpid/java/management/eclipse-plugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Dec  7 07:43:53 2006
@@ -0,0 +1 @@
+target


Reply via email to