diff --git a/org.springframework.integration.security/ivy.xml b/org.springframework.integration.security/ivy.xml
index c75f711826..e08e1ec777 100644
--- a/org.springframework.integration.security/ivy.xml
+++ b/org.springframework.integration.security/ivy.xml
@@ -20,13 +20,13 @@
-
+
+
-
diff --git a/org.springframework.integration/.classpath b/org.springframework.integration/.classpath
index c6af3a7de4..a3ab111073 100644
--- a/org.springframework.integration/.classpath
+++ b/org.springframework.integration/.classpath
@@ -6,6 +6,7 @@
+
diff --git a/org.springframework.integration/ivy.xml b/org.springframework.integration/ivy.xml
index 7297302778..b7331f1795 100644
--- a/org.springframework.integration/ivy.xml
+++ b/org.springframework.integration/ivy.xml
@@ -21,6 +21,7 @@
+
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/gateway/RequestReplyTemplate.java b/org.springframework.integration/src/main/java/org/springframework/integration/gateway/RequestReplyTemplate.java
index 0a7efa58a9..ae2095e70c 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/gateway/RequestReplyTemplate.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/gateway/RequestReplyTemplate.java
@@ -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);
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/gateway/SimpleMessagingGatewayTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/gateway/SimpleMessagingGatewayTests.java
new file mode 100644
index 0000000000..1d4b78bae3
--- /dev/null
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/gateway/SimpleMessagingGatewayTests.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2002-2008 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.gateway;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import org.easymock.IAnswer;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.springframework.integration.channel.MessageChannel;
+import org.springframework.integration.message.Message;
+import org.springframework.integration.message.MessageDeliveryException;
+import org.springframework.integration.message.MessageMapper;
+
+/**
+ * @author Iwein Fuld
+ */
+public class SimpleMessagingGatewayTests {
+
+ private SimpleMessagingGateway simpleMessagingGateway;
+
+ private MessageChannel requestChannel;
+
+ private Object[] allmocks;
+
+ private Message messageMock;
+
+ private MessageChannel replyChannel;
+
+ private MessageMapper messageMapperMock;
+
+
+ @Before
+ public void initializeSample() {
+ this.requestChannel = createMock(MessageChannel.class);
+ this.replyChannel = createMock(MessageChannel.class);
+ this.messageMock = createMock(Message.class);
+ this.messageMapperMock = createMock(MessageMapper.class);
+
+ this.simpleMessagingGateway = new SimpleMessagingGateway(requestChannel);
+ this.simpleMessagingGateway.setReplyChannel(replyChannel);
+ this.simpleMessagingGateway.setMessageMapper(messageMapperMock);
+ this.allmocks = new Object[] { requestChannel, replyChannel, messageMock, messageMapperMock };
+ }
+
+
+ /* send tests */
+
+ @Test
+ public void sendMessage() {
+ expect(requestChannel.send(messageMock)).andReturn(true);
+ replay(allmocks);
+ this.simpleMessagingGateway.send(messageMock);
+ verify(allmocks);
+ }
+
+ @Test(expected=MessageDeliveryException.class)
+ public void sendMessage_failure() {
+ expect(requestChannel.send(messageMock)).andReturn(false);
+ replay(allmocks);
+ this.simpleMessagingGateway.send(messageMock);
+ verify(allmocks);
+ }
+
+ @Test
+ public void sendObject() {
+ expect(requestChannel.send(isA(Message.class))).andAnswer(new IAnswer() {
+ public Boolean answer() throws Throwable {
+ assertEquals("test", ((Message) getCurrentArguments()[0]).getPayload());
+ return true;
+ }
+ });
+ replay(allmocks);
+ this.simpleMessagingGateway.send("test");
+ verify(allmocks);
+ }
+
+ @Test(expected=MessageDeliveryException.class)
+ public void sendObject_failure() {
+ expect(requestChannel.send(isA(Message.class))).andAnswer(new IAnswer() {
+ public Boolean answer() throws Throwable {
+ assertEquals("test", ((Message) getCurrentArguments()[0]).getPayload());
+ return false;
+ }
+ });
+ replay(allmocks);
+ this.simpleMessagingGateway.send("test");
+ verify(allmocks);
+ }
+
+ //TODO null cases for send
+
+ /* receive tests */
+
+ @Test
+ public void receiveMessage() {
+ expect(replyChannel.receive()).andReturn(messageMock);
+ expect(messageMapperMock.mapMessage(messageMock)).andReturn(messageMock);
+ replay(allmocks);
+ assertEquals(this.simpleMessagingGateway.receive(), messageMock);
+ verify(allmocks);
+ }
+
+ @Test
+ public void receiveMessage_null() {
+ expect(replyChannel.receive()).andReturn(null);
+ replay(allmocks);
+ assertEquals(this.simpleMessagingGateway.receive(), null);
+ verify(allmocks);
+ }
+
+}