summaryrefslogtreecommitdiff
path: root/java/common
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2011-11-09 08:59:26 +0000
committerKeith Wall <kwall@apache.org>2011-11-09 08:59:26 +0000
commit03485e0e416d74c74c305bfbcb0864628c8075fe (patch)
tree2a8face28024b691002a2bc13b3ce9d6490fc3cb /java/common
parentcc6176cfb9c22ae2cdf56b03d33aca8975b7cd71 (diff)
downloadqpid-python-03485e0e416d74c74c305bfbcb0864628c8075fe.tar.gz
QPID-3519: refactor consumer argument handling
Applied patch from Oleksandr Rudyy<orudyy@gmail.com> and myself. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1199664 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/FieldTable.java9
-rw-r--r--java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java54
2 files changed, 49 insertions, 14 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
index 721c821bab..4a126b8504 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
@@ -832,9 +832,12 @@ public class FieldTable
public void addAll(FieldTable fieldTable)
{
initMapIfNecessary();
- _encodedForm = null;
- _properties.putAll(fieldTable._properties);
- recalculateEncodedSize();
+ if (fieldTable._properties != null)
+ {
+ _encodedForm = null;
+ _properties.putAll(fieldTable._properties);
+ recalculateEncodedSize();
+ }
}
public static Map<String, Object> convertToMap(final FieldTable fieldTable)
diff --git a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
index bb4c9c3884..bd189feb1c 100644
--- a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
+++ b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
@@ -20,17 +20,19 @@
*/
package org.apache.qpid.framing;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
import junit.framework.Assert;
import junit.framework.TestCase;
-import org.apache.qpid.AMQInvalidArgumentException;
import org.apache.qpid.AMQPInvalidClassException;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.*;
-
public class PropertyFieldTableTest extends TestCase
{
private static final Logger _logger = LoggerFactory.getLogger(PropertyFieldTableTest.class);
@@ -106,7 +108,7 @@ public class PropertyFieldTableTest extends TestCase
table1.setByte("value", Byte.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
- // Tets lookups we shouldn't get anything back for other gets
+ // Tests 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"));
@@ -139,7 +141,7 @@ public class PropertyFieldTableTest extends TestCase
table1.setShort("value", Short.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
- // Tets lookups we shouldn't get anything back for other gets
+ // Tests 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"));
@@ -172,7 +174,7 @@ public class PropertyFieldTableTest extends TestCase
table1.setChar("value", 'c');
Assert.assertTrue(table1.propertyExists("value"));
- // Tets lookups we shouldn't get anything back for other gets
+ // Tests 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"));
@@ -206,7 +208,7 @@ public class PropertyFieldTableTest extends TestCase
table1.setDouble("value", Double.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
- // Tets lookups we shouldn't get anything back for other gets
+ // Tests 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"));
@@ -241,7 +243,7 @@ public class PropertyFieldTableTest extends TestCase
table1.setFloat("value", Float.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
- // Tets lookups we shouldn't get anything back for other gets
+ // Tests 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"));
@@ -404,7 +406,7 @@ public class PropertyFieldTableTest extends TestCase
table1.setString("value", "Hello");
Assert.assertTrue(table1.propertyExists("value"));
- // Tets lookups we shouldn't get anything back for other gets
+ // Test 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"));
@@ -569,7 +571,7 @@ public class PropertyFieldTableTest extends TestCase
Assert.assertEquals("Hello", table.getObject("object-string"));
}
- public void testwriteBuffer() throws IOException
+ public void testWriteBuffer() throws IOException
{
byte[] bytes = { 99, 98, 97, 96, 95 };
@@ -950,6 +952,36 @@ public class PropertyFieldTableTest extends TestCase
}
+ public void testAddAll()
+ {
+ final FieldTable table1 = new FieldTable();
+ table1.setInteger("int1", 1);
+ table1.setInteger("int2", 2);
+ assertEquals("Unexpected number of entries in table1", 2, table1.size());
+
+ final FieldTable table2 = new FieldTable();
+ table2.setInteger("int3", 3);
+ table2.setInteger("int4", 4);
+ assertEquals("Unexpected number of entries in table2", 2, table2.size());
+
+ table1.addAll(table2);
+ assertEquals("Unexpected number of entries in table1 after addAll", 4, table1.size());
+ assertEquals(Integer.valueOf(3), table1.getInteger("int3"));
+ }
+
+ public void testAddAllWithEmptyFieldTable()
+ {
+ final FieldTable table1 = new FieldTable();
+ table1.setInteger("int1", 1);
+ table1.setInteger("int2", 2);
+ assertEquals("Unexpected number of entries in table1", 2, table1.size());
+
+ final FieldTable emptyFieldTable = new FieldTable();
+
+ table1.addAll(emptyFieldTable);
+ assertEquals("Unexpected number of entries in table1 after addAll", 2, table1.size());
+ }
+
private void assertBytesEqual(byte[] expected, byte[] actual)
{
Assert.assertEquals(expected.length, actual.length);