Java Code Examples for org.apache.qpid.jms.message.JmsMessage#getFacade()
The following examples show how to use
org.apache.qpid.jms.message.JmsMessage#getFacade() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
/** * Test that an amqp-sequence body containing a binary value results in an ObjectMessage * 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 testCreateObjectMessageMessageFromAmqpSequence() throws Exception { Message message = Proton.message(); List<String> list = new ArrayList<String>(); message.setBody(new AmqpSequence(list)); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsObjectMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsObjectMessageFacade.class, facade.getClass()); AmqpObjectTypeDelegate delegate = ((AmqpJmsObjectMessageFacade) facade).getDelegate(); assertTrue("Unexpected delegate type: " + delegate, delegate instanceof AmqpTypedObjectDelegate); }
Example 2
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
/** * Test that an amqp-value body containing a list results in an ObjectMessage * 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 testCreateAmqpObjectMessageFromAmqpValueWithList() throws Exception { Message message = Proton.message(); List<String> list = new ArrayList<String>(); message.setBody(new AmqpValue(list)); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsObjectMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsObjectMessageFacade.class, facade.getClass()); AmqpObjectTypeDelegate delegate = ((AmqpJmsObjectMessageFacade) facade).getDelegate(); assertTrue("Unexpected delegate type: " + delegate, delegate instanceof AmqpTypedObjectDelegate); }
Example 3
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
/** * Test that a data body containing nothing, but with the content type set to * {@value AmqpMessageSupport#OCTET_STREAM_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 testCreateBytesMessageFromDataWithEmptyBinaryAndContentType() throws Exception { Message message = Proton.message(); Binary binary = new Binary(new byte[0]); message.setBody(new Data(binary)); message.setContentType(AmqpMessageSupport.OCTET_STREAM_CONTENT_TYPE.toString()); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsBytesMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsBytesMessageFacade.class, facade.getClass()); }
Example 4
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
/** * Test that an amqp-value body containing a map results in an ObjectMessage * 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 testCreateAmqpObjectMessageFromAmqpValueWithMap() throws Exception { Message message = Proton.message(); Map<String, String> map = new HashMap<String,String>(); message.setBody(new AmqpValue(map)); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsObjectMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsObjectMessageFacade.class, facade.getClass()); AmqpObjectTypeDelegate delegate = ((AmqpJmsObjectMessageFacade) facade).getDelegate(); assertTrue("Unexpected delegate type: " + delegate, delegate instanceof AmqpTypedObjectDelegate); }
Example 5
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
/** * Test that a message with the {@value AmqpMessageSupport#JMS_MSG_TYPE} * annotation set to {@value AmqpMessageSupport#JMS_STREAM_MESSAGE} is * treated as a {@link JmsStreamMessage} with {@link AmqpJmsStreamMessageFacade} * * @throws Exception if an error occurs during the test. */ @Test public void testCreateStreamMessageFromMessageTypeAnnotation() throws Exception { Message message = Proton.message(); Map<Symbol, Object> map = new HashMap<Symbol, Object>(); map.put(AmqpMessageSupport.JMS_MSG_TYPE, AmqpMessageSupport.JMS_STREAM_MESSAGE); MessageAnnotations messageAnnotations = new MessageAnnotations(map); message.setMessageAnnotations(messageAnnotations); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsStreamMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsStreamMessageFacade.class, facade.getClass()); }
Example 6
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
/** * Test that a message with the {@value AmqpMessageSupport#JMS_MSG_TYPE} * annotation set to {@value AmqpMessageSupport#JMS_BYTES_MESSAGE} is * treated as a {@link JmsBytesMessage} with {@link AmqpJmsBytesMessageFacade} * * @throws Exception if an error occurs during the test. */ @Test public void testCreateBytesMessageFromMessageTypeAnnotation() throws Exception { Message message = Proton.message(); Map<Symbol, Object> map = new HashMap<Symbol, Object>(); map.put(AmqpMessageSupport.JMS_MSG_TYPE, AmqpMessageSupport.JMS_BYTES_MESSAGE); MessageAnnotations messageAnnotations = new MessageAnnotations(map); message.setMessageAnnotations(messageAnnotations); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsBytesMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsBytesMessageFacade.class, facade.getClass()); }
Example 7
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
/** * Test that a message with the {@value AmqpMessageSupport#JMS_MSG_TYPE} * annotation set to {@value AmqpMessageSupport#JMS_MESSAGE} is * treated as a generic {@link JmsMessage} with {@link AmqpJmsMessageFacade} * * @throws Exception if an error occurs during the test. */ @Test public void testCreateGenericMessageFromMessageTypeAnnotation() throws Exception { Message message = Proton.message(); Map<Symbol, Object> map = new HashMap<Symbol, Object>(); map.put(AmqpMessageSupport.JMS_MSG_TYPE, AmqpMessageSupport.JMS_MESSAGE); MessageAnnotations messageAnnotations = new MessageAnnotations(map); message.setMessageAnnotations(messageAnnotations); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsMessageFacade.class, facade.getClass()); }
Example 8
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test public void testDeliveryCountSetFromMessageWithNonDefaultValue() throws Exception { MessageImpl message = (MessageImpl) Message.Factory.create(); message.setDeliveryCount(2); message.setBody(new AmqpValue("test")); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); assertTrue(jmsMessage.getJMSRedelivered()); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, jmsMessage.getFacade().getClass()); AmqpJmsTextMessageFacade facade = (AmqpJmsTextMessageFacade) jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals(2, facade.getRedeliveryCount()); assertEquals(2, facade.getAmqpHeader().getDeliveryCount()); assertEquals(UnsignedInteger.valueOf(2), facade.getHeader().getDeliveryCount()); }
Example 9
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test public void testMessagePrioritySetFromMessageWithNonDefaultValue() throws Exception { MessageImpl message = (MessageImpl) Message.Factory.create(); message.setPriority((short) 8); message.setBody(new AmqpValue("test")); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); assertEquals(8, jmsMessage.getJMSPriority()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, facade.getClass()); assertEquals(8, facade.getPriority()); }
Example 10
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test public void testPersistentSetFromMessageWithNonDefaultValue() throws Exception { MessageImpl message = (MessageImpl) Message.Factory.create(); message.setDurable(true); message.setBody(new AmqpValue("test")); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); assertEquals(DeliveryMode.PERSISTENT, jmsMessage.getJMSDeliveryMode()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, facade.getClass()); assertTrue(facade.isPersistent()); }
Example 11
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 6 votes |
private void doCreateTextMessageFromDataWithContentTypeTestImpl(String contentType, Charset expectedCharset) throws IOException { Message message = Proton.message(); Binary binary = new Binary(new byte[0]); message.setBody(new Data(binary)); message.setContentType(contentType); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, facade.getClass()); AmqpJmsTextMessageFacade textFacade = (AmqpJmsTextMessageFacade) facade; assertEquals("Unexpected character set", expectedCharset, textFacade.getCharset()); }
Example 12
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test public void testTimeToLiveSetFromMessageWithNonDefaultValue() throws Exception { MessageImpl message = (MessageImpl) Message.Factory.create(); message.setTtl(65535); message.setBody(new AmqpValue("test")); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, jmsMessage.getFacade().getClass()); AmqpJmsTextMessageFacade facade = (AmqpJmsTextMessageFacade) jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals(65535, facade.getAmqpHeader().getTimeToLive()); }
Example 13
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * 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)); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, facade.getClass()); }
Example 14
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
private void createObjectMessageFromMessageTypeAnnotationTestImpl(boolean setJavaSerializedContentType) throws Exception { Message message = Proton.message(); Map<Symbol, Object> map = new HashMap<Symbol, Object>(); map.put(AmqpMessageSupport.JMS_MSG_TYPE, AmqpMessageSupport.JMS_OBJECT_MESSAGE); MessageAnnotations messageAnnotations = new MessageAnnotations(map); message.setMessageAnnotations(messageAnnotations); if (setJavaSerializedContentType) { message.setContentType(AmqpMessageSupport.SERIALIZED_JAVA_OBJECT_CONTENT_TYPE.toString()); } JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsObjectMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsObjectMessageFacade.class, facade.getClass()); AmqpObjectTypeDelegate delegate = ((AmqpJmsObjectMessageFacade) facade).getDelegate(); if (setJavaSerializedContentType) { assertTrue("Unexpected delegate type: " + delegate, delegate instanceof AmqpSerializedObjectDelegate); } else { assertTrue("Unexpected delegate type: " + delegate, delegate instanceof AmqpTypedObjectDelegate); } }
Example 15
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test public void testFirstAcquirerSetFromMessageWithNonDefaultValue() throws Exception { MessageImpl message = (MessageImpl) Message.Factory.create(); message.setFirstAcquirer(true); message.setBody(new AmqpValue("test")); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, jmsMessage.getFacade().getClass()); AmqpJmsTextMessageFacade facade = (AmqpJmsTextMessageFacade) jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertTrue(facade.getAmqpHeader().isFirstAcquirer()); }
Example 16
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * 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 = Proton.message(); assertNull(message.getContentType()); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsBytesMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsBytesMessageFacade.class, facade.getClass()); }
Example 17
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * 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)); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsBytesMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsBytesMessageFacade.class, facade.getClass()); }
Example 18
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test public void testCreateTextMessageFromNoBodySectionAndContentType() throws Exception { Message message = Proton.message(); message.setContentType("text/plain"); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, facade.getClass()); }
Example 19
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * Test that a message with no body section, and with the content type set to * an unknown value results in a plain Message when not otherwise annotated to * indicate the type of JMS message it is. * * @throws Exception if an error occurs during the test. */ public void testCreateGenericMessageFromNoBodySectionAndUnknownContentType() throws Exception { Message message = Proton.message(); message.setContentType("unknown-content-type"); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsMessageFacade.class, facade.getClass()); }
Example 20
Source File: AmqpCodecTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * 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"); JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage(); assertNotNull("Message should not be null", jmsMessage); assertEquals("Unexpected message class type", JmsBytesMessage.class, jmsMessage.getClass()); JmsMessageFacade facade = jmsMessage.getFacade(); assertNotNull("Facade should not be null", facade); assertEquals("Unexpected facade class type", AmqpJmsBytesMessageFacade.class, facade.getClass()); }