1111import java .util .HashSet ;
1212import java .util .Map ;
1313import java .util .Set ;
14+ import java .util .UUID ;
1415
1516import javax .jms .BytesMessage ;
1617import javax .jms .DeliveryMode ;
@@ -53,7 +54,7 @@ public void testSendToAmqpAndReceiveTextMessage() throws Exception {
5354
5455 queueConn .start ();
5556 QueueSession queueSession = queueConn .createQueueSession (false , Session .DUPS_OK_ACKNOWLEDGE );
56- Queue queue = ( Queue ) new RMQDestination (QUEUE_NAME , "" , QUEUE_NAME , null ); // write-only AMQP-mapped queue
57+ Queue queue = new RMQDestination (QUEUE_NAME , "" , QUEUE_NAME , null ); // write-only AMQP-mapped queue
5758
5859 QueueSender queueSender = queueSession .createSender (queue );
5960 queueSender .setDeliveryMode (DeliveryMode .NON_PERSISTENT );
@@ -97,7 +98,7 @@ public void testSendToAmqpAndReceiveBytesMessage() throws Exception {
9798
9899 queueConn .start ();
99100 QueueSession queueSession = queueConn .createQueueSession (false , Session .DUPS_OK_ACKNOWLEDGE );
100- Queue queue = ( Queue ) new RMQDestination (QUEUE_NAME , "" , QUEUE_NAME , null ); // write-only AMQP-mapped queue
101+ Queue queue = new RMQDestination (QUEUE_NAME , "" , QUEUE_NAME , null ); // write-only AMQP-mapped queue
101102
102103 QueueSender queueSender = queueSession .createSender (queue );
103104 queueSender .setDeliveryMode (DeliveryMode .NON_PERSISTENT );
@@ -154,7 +155,7 @@ public void testSendFromAmqpAndReceiveBytesMessage() throws Exception {
154155
155156 queueConn .start ();
156157 QueueSession queueSession = queueConn .createQueueSession (false , Session .DUPS_OK_ACKNOWLEDGE );
157- Queue queue = ( Queue ) new RMQDestination (QUEUE_NAME_NON_EXCLUSIVE , null , null , QUEUE_NAME_NON_EXCLUSIVE ); // read-only AMQP-mapped queue
158+ Queue queue = new RMQDestination (QUEUE_NAME_NON_EXCLUSIVE , null , null , QUEUE_NAME_NON_EXCLUSIVE ); // read-only AMQP-mapped queue
158159
159160 QueueReceiver queueReceiver = queueSession .createReceiver (queue );
160161 BytesMessage message = (BytesMessage ) queueReceiver .receive (TEST_RECEIVE_TIMEOUT );
@@ -209,7 +210,7 @@ public void testSendFromAmqpAndReceiveTextMessage() throws Exception {
209210
210211 queueConn .start ();
211212 QueueSession queueSession = queueConn .createQueueSession (false , Session .DUPS_OK_ACKNOWLEDGE );
212- Queue queue = ( Queue ) new RMQDestination (QUEUE_NAME_NON_EXCLUSIVE , null , null , QUEUE_NAME_NON_EXCLUSIVE ); // read-only AMQP-mapped queue
213+ Queue queue = new RMQDestination (QUEUE_NAME_NON_EXCLUSIVE , null , null , QUEUE_NAME_NON_EXCLUSIVE ); // read-only AMQP-mapped queue
213214
214215 QueueReceiver queueReceiver = queueSession .createReceiver (queue );
215216 TextMessage message = (TextMessage ) queueReceiver .receive (TEST_RECEIVE_TIMEOUT );
@@ -235,4 +236,40 @@ public void testSendFromAmqpAndReceiveTextMessage() throws Exception {
235236 assertEquals ("Numeric property not transferred" , "42" , message .getStringProperty ("DummyProp" ));
236237 }
237238
239+ @ Test
240+ public void testSendFromJmsAndReceiveJmsTextMessage () throws Exception {
241+ String queueName = UUID .randomUUID ().toString ();
242+ channel .queueDeclare (queueName ,
243+ false , // durable
244+ false , // non-exclusive
245+ true , // autoDelete
246+ null // options
247+ );
248+
249+ queueConn .start ();
250+ QueueSession queueSession = queueConn .createQueueSession (false , Session .DUPS_OK_ACKNOWLEDGE );
251+ Queue queue = new RMQDestination (queueName , "" , queueName , null ); // write-only AMQP-mapped queue
252+
253+ QueueSender queueSender = queueSession .createSender (queue );
254+ queueSender .setDeliveryMode (DeliveryMode .NON_PERSISTENT );
255+
256+ TextMessage message = queueSession .createTextMessage (MESSAGE );
257+ message .setStringProperty ("JMSType" , "TextMessage" );
258+ message .setStringProperty (USER_STRING_PROPERTY_NAME , STRING_PROP_VALUE );
259+
260+ queueSender .send (message );
261+ queueSession .close ();
262+
263+ queueSession = queueConn .createQueueSession (false , Session .DUPS_OK_ACKNOWLEDGE );
264+ queue = new RMQDestination (queueName , null , null , queueName ); // read-only AMQP-mapped queue
265+ QueueReceiver queueReceiver = queueSession .createReceiver (queue );
266+ message = (TextMessage ) queueReceiver .receive (TEST_RECEIVE_TIMEOUT );
267+
268+ channel .queueDelete (queueName );
269+
270+ assertNotNull ("No message received" , message );
271+ assertEquals ("Payload doesn't match" , MESSAGE , message .getText ());
272+ assertEquals ("String property not transferred" , STRING_PROP_VALUE , message .getStringProperty (USER_STRING_PROPERTY_NAME ));
273+ }
274+
238275}
0 commit comments