Search in sources :

Example 16 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage in project activemq-artemis by apache.

the class JMSMappingInboundTransformerTest method testCreateBytesMessageFromNoBodySectionAndNoContentType.

/**
 * Test that a message with no body section, and no content-type results in a BytesMessage
 * when not otherwise annotated to indicate the type of JMS message it is.
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
@Test
public void testCreateBytesMessageFromNoBodySectionAndNoContentType() throws Exception {
    Message message = Message.Factory.create();
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSBytesMessage.class, jmsMessage.getClass());
}
Also used : ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) TextMessage(javax.jms.TextMessage) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 17 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage in project activemq-artemis by apache.

the class JMSMappingInboundTransformerTest method testCreateAmqpBytesMessageFromAmqpValueWithBinary.

/**
 * Test that an amqp-value body containing a binary value results in BytesMessage when not
 * otherwise annotated to indicate the type of JMS message it is.
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
@Test
public void testCreateAmqpBytesMessageFromAmqpValueWithBinary() throws Exception {
    Message message = Proton.message();
    Binary binary = new Binary(new byte[0]);
    message.setBody(new AmqpValue(binary));
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSBytesMessage.class, jmsMessage.getClass());
}
Also used : ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) TextMessage(javax.jms.TextMessage) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) Binary(org.apache.qpid.proton.amqp.Binary) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) Test(org.junit.Test)

Example 18 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage in project activemq-artemis by apache.

the class JMSMappingInboundTransformerTest method testCreateBytesMessageFromDataWithEmptyBinaryAndNoContentType.

/**
 * Test that a receiving a data body containing nothing and no content type being set results
 * in a BytesMessage when not otherwise annotated to indicate the type of JMS message it is.
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
@Test
public void testCreateBytesMessageFromDataWithEmptyBinaryAndNoContentType() throws Exception {
    Message message = Proton.message();
    Binary binary = new Binary(new byte[0]);
    message.setBody(new Data(binary));
    assertNull(message.getContentType());
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSBytesMessage.class, jmsMessage.getClass());
}
Also used : ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) TextMessage(javax.jms.TextMessage) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) Data(org.apache.qpid.proton.amqp.messaging.Data) Binary(org.apache.qpid.proton.amqp.Binary) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 19 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage in project activemq-artemis by apache.

the class JMSMappingInboundTransformerTest method testCreateBytesMessageFromDataWithUnknownContentType.

/**
 * Test that a message with an empty data body section, and with the content type set to an
 * unknown value results in a BytesMessage when not otherwise annotated to indicate the type
 * of JMS message it is.
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
public void testCreateBytesMessageFromDataWithUnknownContentType() throws Exception {
    Message message = Proton.message();
    Binary binary = new Binary(new byte[0]);
    message.setBody(new Data(binary));
    message.setContentType("unknown-content-type");
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSBytesMessage.class, jmsMessage.getClass());
}
Also used : ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) TextMessage(javax.jms.TextMessage) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) Data(org.apache.qpid.proton.amqp.messaging.Data) Binary(org.apache.qpid.proton.amqp.Binary) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage)

Example 20 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage in project activemq-artemis by apache.

the class JMSMappingInboundTransformerTest method testCreateTextMessageFromAmqpValueWithNull.

/**
 * Test that an amqp-value body containing a null results in an TextMessage when not
 * otherwise annotated to indicate the type of JMS message it is.
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
@Test
public void testCreateTextMessageFromAmqpValueWithNull() throws Exception {
    Message message = Proton.message();
    message.setBody(new AmqpValue(null));
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSTextMessage.class, jmsMessage.getClass());
}
Also used : ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) TextMessage(javax.jms.TextMessage) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) Test(org.junit.Test)

Aggregations

AMQPMessage (org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage)57 Test (org.junit.Test)49 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)35 Message (org.apache.qpid.proton.message.Message)26 MessageImpl (org.apache.qpid.proton.message.impl.MessageImpl)21 ServerJMSBytesMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage)20 ServerJMSMapMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage)20 ServerJMSMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage)20 ServerJMSStreamMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage)20 ServerJMSTextMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage)20 TextMessage (javax.jms.TextMessage)19 ServerJMSObjectMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage)19 AmqpValue (org.apache.qpid.proton.amqp.messaging.AmqpValue)19 Header (org.apache.qpid.proton.amqp.messaging.Header)11 ApplicationProperties (org.apache.qpid.proton.amqp.messaging.ApplicationProperties)10 HashMap (java.util.HashMap)9 Binary (org.apache.qpid.proton.amqp.Binary)9 Data (org.apache.qpid.proton.amqp.messaging.Data)6 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)5 ByteBuf (io.netty.buffer.ByteBuf)4