Added tests for SimpleMessagingGateway.

This commit is contained in:
Mark Fisher
2008-07-03 17:47:07 +00:00
parent 7d8a6c0f84
commit 25bcd05293
5 changed files with 141 additions and 7 deletions

View File

@@ -29,6 +29,7 @@ import org.springframework.integration.endpoint.HandlerEndpoint;
import org.springframework.integration.handler.ReplyHandler;
import org.springframework.integration.handler.ReplyMessageCorrelator;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessagingException;
import org.springframework.integration.message.selector.MessageSelector;
import org.springframework.integration.scheduling.Subscription;
@@ -131,22 +132,24 @@ public class RequestReplyTemplate implements MessageBusAware {
public boolean send(Message<?> message) {
if (message == null) {
throw new MessagingException("Message must not be null.");
throw new MessageDeliveryException(message, "Message must not be null.");
}
if (this.requestChannel == null) {
throw new MessagingException("No request channel has been configured. Cannot send message.");
throw new MessageDeliveryException(message,
"No request channel has been configured. Cannot send message.");
}
boolean sent = (this.requestTimeout >= 0) ?
this.requestChannel.send(message, this.requestTimeout) : this.requestChannel.send(message);
if (!sent) {
throw new MessagingException("Failed to send request message.");
throw new MessageDeliveryException(message, "Failed to send request message.");
}
return true;
}
public Message<?> receive() {
if (this.replyChannel == null) {
throw new MessagingException("No reply channel has been configured. Cannot perform receive only operation.");
throw new MessagingException(
"No reply channel has been configured. Cannot perform receive only operation.");
}
return this.receiveResponse(this.replyChannel);
}
@@ -170,7 +173,8 @@ public class RequestReplyTemplate implements MessageBusAware {
*/
public Message<?> request(Message<?> message) {
if (this.requestChannel == null) {
throw new MessagingException("No request channel available. Cannot send request message.");
throw new MessageDeliveryException(message,
"No request channel available. Cannot send request message.");
}
if (this.replyChannel != null) {
return this.sendAndReceiveWithReplyMessageCorrelator(message);