public void testProperties()
{
for (int j = 0; j < 10; j++)
{
Message msg = new ClientMessageImpl();
SimpleString prop1 = new SimpleString("prop1");
boolean val1 = RandomUtil.randomBoolean();
msg.putBooleanProperty(prop1, val1);
SimpleString prop2 = new SimpleString("prop2");
byte val2 = RandomUtil.randomByte();
msg.putByteProperty(prop2, val2);
SimpleString prop3 = new SimpleString("prop3");
byte[] val3 = RandomUtil.randomBytes();
msg.putBytesProperty(prop3, val3);
SimpleString prop4 = new SimpleString("prop4");
double val4 = RandomUtil.randomDouble();
msg.putDoubleProperty(prop4, val4);
SimpleString prop5 = new SimpleString("prop5");
float val5 = RandomUtil.randomFloat();
msg.putFloatProperty(prop5, val5);
SimpleString prop6 = new SimpleString("prop6");
int val6 = RandomUtil.randomInt();
msg.putIntProperty(prop6, val6);
SimpleString prop7 = new SimpleString("prop7");
long val7 = RandomUtil.randomLong();
msg.putLongProperty(prop7, val7);
SimpleString prop8 = new SimpleString("prop8");
short val8 = RandomUtil.randomShort();
msg.putShortProperty(prop8, val8);
SimpleString prop9 = new SimpleString("prop9");
SimpleString val9 = new SimpleString(RandomUtil.randomString());
msg.putStringProperty(prop9, val9);
Assert.assertEquals(9, msg.getPropertyNames().size());
Assert.assertTrue(msg.getPropertyNames().contains(prop1));
Assert.assertTrue(msg.getPropertyNames().contains(prop2));
Assert.assertTrue(msg.getPropertyNames().contains(prop3));
Assert.assertTrue(msg.getPropertyNames().contains(prop4));
Assert.assertTrue(msg.getPropertyNames().contains(prop5));
Assert.assertTrue(msg.getPropertyNames().contains(prop6));
Assert.assertTrue(msg.getPropertyNames().contains(prop7));
Assert.assertTrue(msg.getPropertyNames().contains(prop8));
Assert.assertTrue(msg.getPropertyNames().contains(prop9));
Assert.assertTrue(msg.containsProperty(prop1));
Assert.assertTrue(msg.containsProperty(prop2));
Assert.assertTrue(msg.containsProperty(prop3));
Assert.assertTrue(msg.containsProperty(prop4));
Assert.assertTrue(msg.containsProperty(prop5));
Assert.assertTrue(msg.containsProperty(prop6));
Assert.assertTrue(msg.containsProperty(prop7));
Assert.assertTrue(msg.containsProperty(prop8));
Assert.assertTrue(msg.containsProperty(prop9));
Assert.assertEquals(val1, msg.getObjectProperty(prop1));
Assert.assertEquals(val2, msg.getObjectProperty(prop2));
Assert.assertEquals(val3, msg.getObjectProperty(prop3));
Assert.assertEquals(val4, msg.getObjectProperty(prop4));
Assert.assertEquals(val5, msg.getObjectProperty(prop5));
Assert.assertEquals(val6, msg.getObjectProperty(prop6));
Assert.assertEquals(val7, msg.getObjectProperty(prop7));
Assert.assertEquals(val8, msg.getObjectProperty(prop8));
Assert.assertEquals(val9, msg.getObjectProperty(prop9));
SimpleString val10 = new SimpleString(RandomUtil.randomString());
// test overwrite
msg.putStringProperty(prop9, val10);
Assert.assertEquals(val10, msg.getObjectProperty(prop9));
int val11 = RandomUtil.randomInt();
msg.putIntProperty(prop9, val11);
Assert.assertEquals(val11, msg.getObjectProperty(prop9));
msg.removeProperty(prop1);
Assert.assertEquals(8, msg.getPropertyNames().size());
Assert.assertTrue(msg.getPropertyNames().contains(prop2));
Assert.assertTrue(msg.getPropertyNames().contains(prop3));
Assert.assertTrue(msg.getPropertyNames().contains(prop4));
Assert.assertTrue(msg.getPropertyNames().contains(prop5));
Assert.assertTrue(msg.getPropertyNames().contains(prop6));
Assert.assertTrue(msg.getPropertyNames().contains(prop7));
Assert.assertTrue(msg.getPropertyNames().contains(prop8));
Assert.assertTrue(msg.getPropertyNames().contains(prop9));
msg.removeProperty(prop2);
Assert.assertEquals(7, msg.getPropertyNames().size());
Assert.assertTrue(msg.getPropertyNames().contains(prop3));
Assert.assertTrue(msg.getPropertyNames().contains(prop4));
Assert.assertTrue(msg.getPropertyNames().contains(prop5));
Assert.assertTrue(msg.getPropertyNames().contains(prop6));
Assert.assertTrue(msg.getPropertyNames().contains(prop7));
Assert.assertTrue(msg.getPropertyNames().contains(prop8));
Assert.assertTrue(msg.getPropertyNames().contains(prop9));
msg.removeProperty(prop9);
Assert.assertEquals(6, msg.getPropertyNames().size());
Assert.assertTrue(msg.getPropertyNames().contains(prop3));
Assert.assertTrue(msg.getPropertyNames().contains(prop4));
Assert.assertTrue(msg.getPropertyNames().contains(prop5));
Assert.assertTrue(msg.getPropertyNames().contains(prop6));
Assert.assertTrue(msg.getPropertyNames().contains(prop7));
Assert.assertTrue(msg.getPropertyNames().contains(prop8));
msg.removeProperty(prop3);
msg.removeProperty(prop4);
msg.removeProperty(prop5);
msg.removeProperty(prop6);
msg.removeProperty(prop7);
msg.removeProperty(prop8);
Assert.assertEquals(0, msg.getPropertyNames().size());
}
}