@Test public void testWriteObjectWithChar() throws Exception { doWriteObjectWithType(RandomUtil.randomChar(), new TypeReader() { @Override public Object readType(final ActiveMQStreamMessage message) throws Exception { return message.readChar(); } }); }
@Test public void testSetObjectFromChar() throws Exception { doTestSetObject(RandomUtil.randomChar()); }
chrs[i] = RandomUtil.randomChar();
@Test public void testGetStringFromChar() throws Exception { char value = RandomUtil.randomChar(); ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setChar(itemName, value); Assert.assertEquals(Character.toString(value), message.getString(itemName)); }
@Test public void testReadStringFromChar() throws Exception { char value = RandomUtil.randomChar(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeChar(value); message.reset(); Assert.assertEquals(Character.toString(value), message.readString()); }
@Test public void testGetBytesFromInvalidType() throws Exception { ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setChar(itemName, RandomUtil.randomChar()); try { message.getBytes(itemName); Assert.fail("MessageFormatException"); } catch (MessageFormatException e) { } }
@Test public void testGetCharFromChar() throws Exception { char value = RandomUtil.randomChar(); ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setChar(itemName, value); Assert.assertEquals(value, message.getChar(itemName)); }
@Test public void testGetFloatFromInvalidType() throws Exception { ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setChar(itemName, RandomUtil.randomChar()); try { message.getFloat(itemName); Assert.fail("MessageFormatException"); } catch (MessageFormatException e) { } }
@Test public void testGetDoubleFromInvalidType() throws Exception { ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setChar(itemName, RandomUtil.randomChar()); try { message.getDouble(itemName); Assert.fail("MessageFormatException"); } catch (MessageFormatException e) { } }
@Test public void testReadObjectFromChar() throws Exception { char value = RandomUtil.randomChar(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeChar(value); message.reset(); Assert.assertEquals(value, message.readObject()); }
@Test public void testReadCharFromChar() throws Exception { char value = RandomUtil.randomChar(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeChar(value); message.reset(); Assert.assertEquals(value, message.readChar()); }
@Test public void testCharProperty() throws Exception { Character val = RandomUtil.randomChar(); props.putCharProperty(key, val); Assert.assertEquals(val, props.getCharProperty(key)); Assert.assertEquals(new SimpleString(Character.toString(val)), props.getSimpleStringProperty(key)); try { props.putByteProperty(key, RandomUtil.randomByte()); props.getCharProperty(key); Assert.fail(); } catch (ActiveMQPropertyConversionException e) { } try { props.getCharProperty(unknownKey); Assert.fail(); } catch (NullPointerException e) { } }
@Test public void testEncodeDecode() throws Exception { props.putByteProperty(RandomUtil.randomSimpleString(), RandomUtil.randomByte()); props.putBytesProperty(RandomUtil.randomSimpleString(), RandomUtil.randomBytes()); props.putBytesProperty(RandomUtil.randomSimpleString(), null); props.putBooleanProperty(RandomUtil.randomSimpleString(), RandomUtil.randomBoolean()); props.putShortProperty(RandomUtil.randomSimpleString(), RandomUtil.randomShort()); props.putIntProperty(RandomUtil.randomSimpleString(), RandomUtil.randomInt()); props.putLongProperty(RandomUtil.randomSimpleString(), RandomUtil.randomLong()); props.putFloatProperty(RandomUtil.randomSimpleString(), RandomUtil.randomFloat()); props.putDoubleProperty(RandomUtil.randomSimpleString(), RandomUtil.randomDouble()); props.putCharProperty(RandomUtil.randomSimpleString(), RandomUtil.randomChar()); props.putSimpleStringProperty(RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString()); props.putSimpleStringProperty(RandomUtil.randomSimpleString(), null); SimpleString keyToRemove = RandomUtil.randomSimpleString(); props.putSimpleStringProperty(keyToRemove, RandomUtil.randomSimpleString()); ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(1024); props.encode(buffer.byteBuf()); Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex()); TypedProperties decodedProps = new TypedProperties(); decodedProps.decode(buffer.byteBuf()); TypedPropertiesTest.assertEqualsTypeProperties(props, decodedProps); buffer.clear(); // After removing a property, you should still be able to encode the Property props.removeProperty(keyToRemove); props.encode(buffer.byteBuf()); Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex()); }