Search in sources :

Example 6 with ClientMessageImpl

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

the class ManagementHelperTest method testMapWithArrayValues.

@Test
public void testMapWithArrayValues() throws Exception {
    String resource = RandomUtil.randomString();
    String operationName = RandomUtil.randomString();
    Map<String, Object> map = new HashMap<>();
    String key1 = RandomUtil.randomString();
    String[] val1 = new String[] { "a", "b", "c" };
    ManagementHelperTest.log.info("val1 type is " + Arrays.toString(val1));
    String key2 = RandomUtil.randomString();
    Long[] val2 = new Long[] { 1L, 2L, 3L, 4L, 5L };
    ManagementHelperTest.log.info("val2 type is " + Arrays.toString(val2));
    map.put(key1, val1);
    map.put(key2, val2);
    Object[] params = new Object[] { "hello", map };
    ClientMessageImpl msg = new ClientMessageImpl((byte) 0, false, 0, 0, (byte) 4, 1000);
    ManagementHelper.putOperationInvocation(msg, resource, operationName, params);
    Object[] parameters = ManagementHelper.retrieveOperationParameters(msg);
    Assert.assertEquals(params.length, parameters.length);
    Assert.assertEquals("hello", parameters[0]);
    Map map2 = (Map) parameters[1];
    Assert.assertEquals(2, map2.size());
    Object[] arr1 = (Object[]) map2.get(key1);
    Assert.assertEquals(val1.length, arr1.length);
    Assert.assertEquals(arr1[0], val1[0]);
    Assert.assertEquals(arr1[1], val1[1]);
    Assert.assertEquals(arr1[2], val1[2]);
    Object[] arr2 = (Object[]) map2.get(key2);
    Assert.assertEquals(val2.length, arr2.length);
    Assert.assertEquals(arr2[0], val2[0]);
    Assert.assertEquals(arr2[1], val2[1]);
    Assert.assertEquals(arr2[2], val2[2]);
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) ClientMessageImpl(org.apache.activemq.artemis.core.client.impl.ClientMessageImpl) Test(org.junit.Test)

Example 7 with ClientMessageImpl

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

the class MessageHeaderTest method testCopyOnForeignTextMessage.

@Test
public void testCopyOnForeignTextMessage() throws JMSException {
    ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000);
    ClientSession session = new FakeSession(clientMessage);
    TextMessage foreignTextMessage = new SimpleJMSTextMessage();
    ActiveMQTextMessage copy = new ActiveMQTextMessage(foreignTextMessage, session);
    MessageHeaderTestBase.ensureEquivalent(foreignTextMessage, copy);
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) TextMessage(javax.jms.TextMessage) ClientMessageImpl(org.apache.activemq.artemis.core.client.impl.ClientMessageImpl) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) Test(org.junit.Test)

Example 8 with ClientMessageImpl

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

the class MessageHeaderTest method testCopyOnJBossMessage.

@Test
public void testCopyOnJBossMessage() throws JMSException {
    ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000);
    ClientSession session = new FakeSession(clientMessage);
    ActiveMQMessage jbossMessage = ActiveMQMessage.createMessage(clientMessage, session);
    jbossMessage.clearProperties();
    MessageHeaderTestBase.configureMessage(jbossMessage);
    ActiveMQMessage copy = new ActiveMQMessage(jbossMessage, session);
    MessageHeaderTestBase.ensureEquivalent(jbossMessage, copy);
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientMessageImpl(org.apache.activemq.artemis.core.client.impl.ClientMessageImpl) ActiveMQMessage(org.apache.activemq.artemis.jms.client.ActiveMQMessage) Test(org.junit.Test)

Example 9 with ClientMessageImpl

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

the class MessageHeaderTest method testCopyOnForeignObjectMessage.

@Test
public void testCopyOnForeignObjectMessage() throws JMSException {
    ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000);
    ClientSession session = new FakeSession(clientMessage);
    ObjectMessage foreignObjectMessage = new SimpleJMSObjectMessage();
    ActiveMQObjectMessage copy = new ActiveMQObjectMessage(foreignObjectMessage, session, null);
    MessageHeaderTestBase.ensureEquivalent(foreignObjectMessage, copy);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) ActiveMQObjectMessage(org.apache.activemq.artemis.jms.client.ActiveMQObjectMessage) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ActiveMQObjectMessage(org.apache.activemq.artemis.jms.client.ActiveMQObjectMessage) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientMessageImpl(org.apache.activemq.artemis.core.client.impl.ClientMessageImpl) Test(org.junit.Test)

Example 10 with ClientMessageImpl

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

the class MessageHeaderTest method testCopyOnForeignStreamMessage.

@Test
public void testCopyOnForeignStreamMessage() throws JMSException {
    ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000);
    ClientSession session = new FakeSession(clientMessage);
    StreamMessage foreignStreamMessage = new SimpleJMSStreamMessage();
    foreignStreamMessage.writeByte((byte) 1);
    foreignStreamMessage.writeByte((byte) 2);
    foreignStreamMessage.writeByte((byte) 3);
    ActiveMQStreamMessage copy = new ActiveMQStreamMessage(foreignStreamMessage, session);
    MessageHeaderTestBase.ensureEquivalent(foreignStreamMessage, copy);
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) StreamMessage(javax.jms.StreamMessage) ActiveMQStreamMessage(org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage) ActiveMQStreamMessage(org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) 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