Search in sources :

Example 11 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testReadLongFromInt.

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

Example 12 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testReadObjectFromString.

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

Example 13 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testReadCharFromNull.

@Test
public void testReadCharFromNull() throws Exception {
    ActiveMQStreamMessage message = new ActiveMQStreamMessage();
    message.writeString(null);
    message.reset();
    try {
        message.readChar();
        fail();
    } catch (NullPointerException e) {
    }
}
Also used : ActiveMQStreamMessage(org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage) Test(org.junit.Test)

Example 14 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testReadDoubleFromString.

@Test
public void testReadDoubleFromString() throws Exception {
    double value = RandomUtil.randomDouble();
    ActiveMQStreamMessage message = new ActiveMQStreamMessage();
    message.writeString(Double.toString(value));
    message.reset();
    Assert.assertEquals(value, message.readDouble(), 0.000001);
}
Also used : ActiveMQStreamMessage(org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage) Test(org.junit.Test)

Example 15 with ActiveMQStreamMessage

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

the class ActiveMQStreamMessageTest method testWriteObjectWithInvalidType.

@Test
public void testWriteObjectWithInvalidType() throws Exception {
    ActiveMQStreamMessage message = new ActiveMQStreamMessage();
    try {
        message.writeObject(new ArrayList<String>());
        Assert.fail("MessageFormatException");
    } catch (MessageFormatException e) {
    }
}
Also used : MessageFormatException(javax.jms.MessageFormatException) 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