Search in sources :

Example 16 with ClientMessageImpl

use of org.apache.activemq.artemis.core.client.impl.ClientMessageImpl in project activemq-artemis by apache.

the class MessageHeaderTest method testCopyOnForeignBytesMessage.

@Test
public void testCopyOnForeignBytesMessage() throws JMSException {
    ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000);
    ClientSession session = new FakeSession(clientMessage);
    BytesMessage foreignBytesMessage = new SimpleJMSBytesMessage();
    for (int i = 0; i < 20; i++) {
        foreignBytesMessage.writeByte((byte) i);
    }
    ActiveMQBytesMessage copy = new ActiveMQBytesMessage(foreignBytesMessage, session);
    foreignBytesMessage.reset();
    copy.reset();
    MessageHeaderTestBase.ensureEquivalent(foreignBytesMessage, copy);
}
Also used : ActiveMQBytesMessage(org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) BytesMessage(javax.jms.BytesMessage) ActiveMQBytesMessage(org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientMessageImpl(org.apache.activemq.artemis.core.client.impl.ClientMessageImpl) Test(org.junit.Test)

Example 17 with ClientMessageImpl

use of org.apache.activemq.artemis.core.client.impl.ClientMessageImpl in project activemq-artemis by apache.

the class ConversionTest method testCoreToJMSConversion.

@Test
public void testCoreToJMSConversion() {
    ICoreMessage clientMessage = new ClientMessageImpl();
    clientMessage.setDurable(true).setPriority((byte) 9).setExpiration(123456);
    Map<String, Object> messageMap = clientMessage.toMap();
    Map<String, Object> jmsMap = ActiveMQMessage.coreMaptoJMSMap(messageMap);
    Object priority = jmsMap.get("JMSPriority");
    assertTrue(priority instanceof Integer);
    assertEquals(9, priority);
}
Also used : ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ClientMessageImpl(org.apache.activemq.artemis.core.client.impl.ClientMessageImpl) Test(org.junit.Test)

Aggregations

ClientMessageImpl (org.apache.activemq.artemis.core.client.impl.ClientMessageImpl)17 Test (org.junit.Test)16 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)8 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)8 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 BytesMessage (javax.jms.BytesMessage)2 MapMessage (javax.jms.MapMessage)2 ObjectMessage (javax.jms.ObjectMessage)2 StreamMessage (javax.jms.StreamMessage)2 TextMessage (javax.jms.TextMessage)2 Message (org.apache.activemq.artemis.api.core.Message)2 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)2 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)2 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)2 SessionSendMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage)2 ActiveMQBytesMessage (org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage)2 ActiveMQMapMessage (org.apache.activemq.artemis.jms.client.ActiveMQMapMessage)2