@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2015 the original author or authors .
* Copyright 2002 - 2016 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -50,6 +50,8 @@ import static org.mockito.BDDMockito.*;
@@ -50,6 +50,8 @@ import static org.mockito.BDDMockito.*;
* /
public class MessagingMessageListenerAdapterTests {
private static final Destination sharedReplyDestination = mock ( Destination . class ) ;
private final DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory ( ) ;
private final SampleBean sample = new SampleBean ( ) ;
@ -151,7 +153,6 @@ public class MessagingMessageListenerAdapterTests {
@@ -151,7 +153,6 @@ public class MessagingMessageListenerAdapterTests {
@Test
public void replyPayloadToQueue ( ) throws JMSException {
Message < String > request = MessageBuilder . withPayload ( "Response" ) . build ( ) ;
Session session = mock ( Session . class ) ;
Queue replyDestination = mock ( Queue . class ) ;
given ( session . createQueue ( "queueOut" ) ) . willReturn ( replyDestination ) ;
@ -161,7 +162,7 @@ public class MessagingMessageListenerAdapterTests {
@@ -161,7 +162,7 @@ public class MessagingMessageListenerAdapterTests {
given ( session . createTextMessage ( "Response" ) ) . willReturn ( responseMessage ) ;
given ( session . createProducer ( replyDestination ) ) . willReturn ( messageProducer ) ;
MessagingMessageListenerAdapter listener = getPayloadInstance ( request , "replyPayloadToQueue" , Message . class ) ;
MessagingMessageListenerAdapter listener = getPayloadInstance ( "Response" , "replyPayloadToQueue" , Message . class ) ;
listener . onMessage ( mock ( javax . jms . Message . class ) , session ) ;
verify ( session ) . createQueue ( "queueOut" ) ;
@ -172,7 +173,6 @@ public class MessagingMessageListenerAdapterTests {
@@ -172,7 +173,6 @@ public class MessagingMessageListenerAdapterTests {
@Test
public void replyPayloadToTopic ( ) throws JMSException {
Message < String > request = MessageBuilder . withPayload ( "Response" ) . build ( ) ;
Session session = mock ( Session . class ) ;
Topic replyDestination = mock ( Topic . class ) ;
given ( session . createTopic ( "topicOut" ) ) . willReturn ( replyDestination ) ;
@ -182,7 +182,7 @@ public class MessagingMessageListenerAdapterTests {
@@ -182,7 +182,7 @@ public class MessagingMessageListenerAdapterTests {
given ( session . createTextMessage ( "Response" ) ) . willReturn ( responseMessage ) ;
given ( session . createProducer ( replyDestination ) ) . willReturn ( messageProducer ) ;
MessagingMessageListenerAdapter listener = getPayloadInstance ( request , "replyPayloadToTopic" , Message . class ) ;
MessagingMessageListenerAdapter listener = getPayloadInstance ( "Response" , "replyPayloadToTopic" , Message . class ) ;
listener . onMessage ( mock ( javax . jms . Message . class ) , session ) ;
verify ( session ) . createTopic ( "topicOut" ) ;
@ -193,17 +193,13 @@ public class MessagingMessageListenerAdapterTests {
@@ -193,17 +193,13 @@ public class MessagingMessageListenerAdapterTests {
@Test
public void replyPayloadToDestination ( ) throws JMSException {
Queue replyDestination = mock ( Queue . class ) ;
Message < String > request = MessageBuilder . withPayload ( "Response" )
. setHeader ( "destination" , replyDestination ) . build ( ) ;
Session session = mock ( Session . class ) ;
MessageProducer messageProducer = mock ( MessageProducer . class ) ;
TextMessage responseMessage = mock ( TextMessage . class ) ;
given ( session . createTextMessage ( "Response" ) ) . willReturn ( responseMessage ) ;
given ( session . createProducer ( replyDestination ) ) . willReturn ( messageProducer ) ;
given ( session . createProducer ( sha redR eplyDestination) ) . willReturn ( messageProducer ) ;
MessagingMessageListenerAdapter listener = getPayloadInstance ( request , "replyPayloadToDestination" , Message . class ) ;
MessagingMessageListenerAdapter listener = getPayloadInstance ( "Response" , "replyPayloadToDestination" , Message . class ) ;
listener . onMessage ( mock ( javax . jms . Message . class ) , session ) ;
verify ( session , times ( 0 ) ) . createQueue ( anyString ( ) ) ;
@ -215,7 +211,6 @@ public class MessagingMessageListenerAdapterTests {
@@ -215,7 +211,6 @@ public class MessagingMessageListenerAdapterTests {
@Test
public void replyPayloadNoDestination ( ) throws JMSException {
Queue replyDestination = mock ( Queue . class ) ;
Message < String > request = MessageBuilder . withPayload ( "Response" ) . build ( ) ;
Session session = mock ( Session . class ) ;
MessageProducer messageProducer = mock ( MessageProducer . class ) ;
@ -224,7 +219,7 @@ public class MessagingMessageListenerAdapterTests {
@@ -224,7 +219,7 @@ public class MessagingMessageListenerAdapterTests {
given ( session . createProducer ( replyDestination ) ) . willReturn ( messageProducer ) ;
MessagingMessageListenerAdapter listener =
getPayloadInstance ( request , "replyPayloadNoDestination" , Message . class ) ;
getPayloadInstance ( "Response" , "replyPayloadNoDestination" , Message . class ) ;
listener . setDefaultResponseDestination ( replyDestination ) ;
listener . onMessage ( mock ( javax . jms . Message . class ) , session ) ;
@ -243,7 +238,6 @@ public class MessagingMessageListenerAdapterTests {
@@ -243,7 +238,6 @@ public class MessagingMessageListenerAdapterTests {
private TextMessage testReplyWithJackson ( String methodName , String replyContent ) throws JMSException {
Queue replyDestination = mock ( Queue . class ) ;
Message < String > request = MessageBuilder . withPayload ( "Response" ) . build ( ) ;
Session session = mock ( Session . class ) ;
MessageProducer messageProducer = mock ( MessageProducer . class ) ;
@ -251,7 +245,7 @@ public class MessagingMessageListenerAdapterTests {
@@ -251,7 +245,7 @@ public class MessagingMessageListenerAdapterTests {
given ( session . createTextMessage ( replyContent ) ) . willReturn ( responseMessage ) ;
given ( session . createProducer ( replyDestination ) ) . willReturn ( messageProducer ) ;
MessagingMessageListenerAdapter listener = getPayloadInstance ( request , methodName , Message . class ) ;
MessagingMessageListenerAdapter listener = getPayloadInstance ( "Response" , methodName , Message . class ) ;
MappingJackson2MessageConverter messageConverter = new MappingJackson2MessageConverter ( ) ;
messageConverter . setTargetType ( MessageType . TEXT ) ;
listener . setMessageConverter ( messageConverter ) ;
@ -321,8 +315,7 @@ public class MessagingMessageListenerAdapterTests {
@@ -321,8 +315,7 @@ public class MessagingMessageListenerAdapterTests {
}
public JmsResponse < String > replyPayloadToDestination ( Message < String > input ) {
return JmsResponse . forDestination ( input . getPayload ( ) ,
input . getHeaders ( ) . get ( "destination" , Destination . class ) ) ;
return JmsResponse . forDestination ( input . getPayload ( ) , sharedReplyDestination ) ;
}
public JmsResponse < String > replyPayloadNoDestination ( Message < String > input ) {