Search in sources :

Example 36 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testString.

@Test
public void testString() throws Exception {
    String value = RandomUtil.randomString();
    ActiveMQStreamMessage message = new ActiveMQStreamMessage();
    message.writeString(value);
    message.reset();
    try {
        message.readByte();
        fail("must throw a NumberFormatException");
    } catch (NumberFormatException e) {
    }
    // we can read the String without resetting the message
    Assert.assertEquals(value, message.readString());
}
Also used : ActiveMQStreamMessage(org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage) Test(org.junit.Test)

Example 37 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testReadFloatFromFloat.

@Test
public void testReadFloatFromFloat() throws Exception {
    float value = RandomUtil.randomFloat();
    ActiveMQStreamMessage message = new ActiveMQStreamMessage();
    message.writeFloat(value);
    message.reset();
    Assert.assertEquals(value, message.readFloat(), 0.000001);
}
Also used : ActiveMQStreamMessage(org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage) Test(org.junit.Test)

Example 38 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testReadObjectFromChar.

@Test
public void testReadObjectFromChar() throws Exception {
    char value = RandomUtil.randomChar();
    ActiveMQStreamMessage message = new ActiveMQStreamMessage();
    message.writeChar(value);
    message.reset();
    Assert.assertEquals(value, message.readObject());
}
Also used : ActiveMQStreamMessage(org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage) Test(org.junit.Test)

Example 39 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testReadStringFromInt.

@Test
public void testReadStringFromInt() throws Exception {
    int value = RandomUtil.randomInt();
    ActiveMQStreamMessage message = new ActiveMQStreamMessage();
    message.writeInt(value);
    message.reset();
    Assert.assertEquals(Integer.toString(value), message.readString());
}
Also used : ActiveMQStreamMessage(org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage) Test(org.junit.Test)

Example 40 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testReadObjectFromBoolean.

@Test
public void testReadObjectFromBoolean() throws Exception {
    boolean value = RandomUtil.randomBoolean();
    ActiveMQStreamMessage message = new ActiveMQStreamMessage();
    message.writeBoolean(value);
    message.reset();
    Assert.assertEquals(value, message.readObject());
}
Also used : ActiveMQStreamMessage(org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage) Test(org.junit.Test)

Aggregations

ActiveMQStreamMessage (org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage)53 Test (org.junit.Test)50 MessageFormatException (javax.jms.MessageFormatException)2 MessageEOFException (javax.jms.MessageEOFException)1 StreamMessage (javax.jms.StreamMessage)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