You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/12/11 14:30:15 UTC
[3/3] camel git commit: CAMEL-8145 Merged the patch into camel-mina2
CAMEL-8145 Merged the patch into camel-mina2
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/81e4db37
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/81e4db37
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/81e4db37
Branch: refs/heads/master
Commit: 81e4db372ab6d4b2ba02bec178568343d0670d79
Parents: d0d469b
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Dec 11 20:29:59 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Dec 11 21:29:46 2014 +0800
----------------------------------------------------------------------
.../apache/camel/component/mina2/Mina2Consumer.java | 8 ++++++--
.../Mina2TcpWithInOutUsingPlainSocketTest.java | 16 ++++++++++++++--
2 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/81e4db37/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
index 29ce424..df85635 100644
--- a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
+++ b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
@@ -346,8 +346,12 @@ public class Mina2Consumer extends DefaultConsumer {
//
boolean disconnect = getEndpoint().getConfiguration().isDisconnect();
Object response = null;
- response = Mina2PayloadHelper.getOut(getEndpoint(), exchange);
-
+ if (exchange.hasOut()) {
+ response = Mina2PayloadHelper.getOut(getEndpoint(), exchange);
+ } else {
+ response = Mina2PayloadHelper.getIn(getEndpoint(), exchange);
+ }
+
boolean failed = exchange.isFailed();
if (failed && !getEndpoint().getConfiguration().isTransferExchange()) {
if (exchange.getException() != null) {
http://git-wip-us.apache.org/repos/asf/camel/blob/81e4db37/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java
index 7aa7e3c..3ae322c 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpWithInOutUsingPlainSocketTest.java
@@ -75,12 +75,22 @@ public class Mina2TcpWithInOutUsingPlainSocketTest extends BaseMina2Test {
assertTrue("out should not be the same as in when the exchange has failed", !"force-exception".equals(out));
assertEquals("should get the exception here", out, "java.lang.IllegalArgumentException: Forced exception");
}
+
+ @Test
+ public void testExchangeWithInOnly() throws IOException {
+ String out = sendAndReceive("force-set-in-body");
+ assertEquals("Get a wrong response message", "Update the in message!", out);
+ }
private String sendAndReceive(String input) throws IOException {
+ return sendAndReceive(input, getPort());
+ }
+
+ private String sendAndReceive(String input, int port) throws IOException {
byte buf[] = new byte[128];
Socket soc = new Socket();
- soc.connect(new InetSocketAddress("localhost", getPort()));
+ soc.connect(new InetSocketAddress("localhost", port));
// Send message using plain Socket to test if this works
OutputStream os = null;
@@ -132,9 +142,11 @@ public class Mina2TcpWithInOutUsingPlainSocketTest extends BaseMina2Test {
// clear out before throwing exception
e.getOut().setBody(null);
throw new IllegalArgumentException("Forced exception");
+ } else if ("force-set-in-body".equals(in)) {
+ e.getIn().setBody("Update the in message!");
} else {
e.getOut().setBody("Hello " + in);
- }
+ }
}
});
}