Search in sources :

Example 31 with ActiveMQMapMessage

use of org.apache.activemq.artemis.jms.client.ActiveMQMapMessage in project activemq-artemis by apache.

the class ActiveMQMapMessageTest method testGetDoubleFromFloat.

@Test
public void testGetDoubleFromFloat() throws Exception {
    float value = RandomUtil.randomFloat();
    ActiveMQMapMessage message = new ActiveMQMapMessage();
    message.setFloat(itemName, value);
    Assert.assertEquals(Float.valueOf(value).doubleValue(), message.getDouble(itemName), 0.000001);
}
Also used : ActiveMQMapMessage(org.apache.activemq.artemis.jms.client.ActiveMQMapMessage) Test(org.junit.Test)

Example 32 with ActiveMQMapMessage

use of org.apache.activemq.artemis.jms.client.ActiveMQMapMessage in project activemq-artemis by apache.

the class ActiveMQMapMessageTest method testGetBooleanFromBoolean.

@Test
public void testGetBooleanFromBoolean() throws Exception {
    boolean value = true;
    ActiveMQMapMessage message = new ActiveMQMapMessage();
    message.setBoolean(itemName, value);
    Assert.assertEquals(value, message.getBoolean(itemName));
}
Also used : ActiveMQMapMessage(org.apache.activemq.artemis.jms.client.ActiveMQMapMessage) Test(org.junit.Test)

Example 33 with ActiveMQMapMessage

use of org.apache.activemq.artemis.jms.client.ActiveMQMapMessage in project activemq-artemis by apache.

the class ActiveMQMapMessageTest method testGetShortFromByte.

@Test
public void testGetShortFromByte() throws Exception {
    byte value = RandomUtil.randomByte();
    ActiveMQMapMessage message = new ActiveMQMapMessage();
    message.setByte(itemName, value);
    Assert.assertEquals(value, message.getShort(itemName));
}
Also used : ActiveMQMapMessage(org.apache.activemq.artemis.jms.client.ActiveMQMapMessage) Test(org.junit.Test)

Example 34 with ActiveMQMapMessage

use of org.apache.activemq.artemis.jms.client.ActiveMQMapMessage in project activemq-artemis by apache.

the class ActiveMQMapMessageTest method testGetShortFromString.

@Test
public void testGetShortFromString() throws Exception {
    short value = RandomUtil.randomShort();
    ActiveMQMapMessage message = new ActiveMQMapMessage();
    message.setString(itemName, Short.toString(value));
    Assert.assertEquals(value, message.getShort(itemName));
}
Also used : ActiveMQMapMessage(org.apache.activemq.artemis.jms.client.ActiveMQMapMessage) Test(org.junit.Test)

Example 35 with ActiveMQMapMessage

use of org.apache.activemq.artemis.jms.client.ActiveMQMapMessage in project activemq-artemis by apache.

the class ActiveMQMapMessageTest method testGetFloatFromInvalidType.

@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) {
    }
}
Also used : MessageFormatException(javax.jms.MessageFormatException) ActiveMQMapMessage(org.apache.activemq.artemis.jms.client.ActiveMQMapMessage) Test(org.junit.Test)

Aggregations

ActiveMQMapMessage (org.apache.activemq.artemis.jms.client.ActiveMQMapMessage)58 Test (org.junit.Test)57 MessageFormatException (javax.jms.MessageFormatException)9 MapMessage (javax.jms.MapMessage)1 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1 ClientMessageImpl (org.apache.activemq.artemis.core.client.impl.ClientMessageImpl)1