You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/06/05 08:24:18 UTC

[1/5] camel git commit: Upgrade MyBatis to version 3.3.0

Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x bab41b7bf -> e3c695004
  refs/heads/master 88e99af67 -> c9e105bb0


Upgrade MyBatis to version 3.3.0


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8106485a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8106485a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8106485a

Branch: refs/heads/master
Commit: 8106485a8763f9aa404b30f0b8efbb862b935c35
Parents: 6da5a7f
Author: Askannon <as...@flexarc.com>
Authored: Fri Jun 5 01:42:13 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jun 5 08:23:47 2015 +0200

----------------------------------------------------------------------
 parent/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8106485a/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 5223c53..7c75066 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -365,7 +365,7 @@
     <mustache-guava-version>16.0</mustache-guava-version>
     <mustache-bundle-version>0.8.16_1</mustache-bundle-version>
     <mvel-version>2.2.4.Final</mvel-version>
-    <mybatis-version>3.2.8</mybatis-version>
+    <mybatis-version>3.3.0</mybatis-version>
     <neethi-bundle-version>3.0.1</neethi-bundle-version>
     <netty3-version>3.10.3.Final</netty3-version>
     <netty-version>4.0.28.Final</netty-version>


[2/5] camel git commit: If ExchangePattern is InOut retain headers for all statement types and not only for select queries. Also preserve the body if outputHeader is set.

Posted by da...@apache.org.
If ExchangePattern is InOut retain headers for all statement types and not only for select queries. Also preserve the body if outputHeader is set.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6da5a7f6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6da5a7f6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6da5a7f6

Branch: refs/heads/master
Commit: 6da5a7f6ff7046c77522ed09d18f8ce0b3a38a0e
Parents: 88e99af
Author: Askannon <as...@flexarc.com>
Authored: Fri Jun 5 01:15:29 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jun 5 08:23:47 2015 +0200

----------------------------------------------------------------------
 .../component/mybatis/MyBatisProducer.java      | 28 +++++----
 ...ectOneExchangeInOutWithOutputHeaderTest.java | 60 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6da5a7f6/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java b/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
index 6989a57..63a1e89 100644
--- a/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
+++ b/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
@@ -227,14 +227,17 @@ public class MyBatisProducer extends DefaultProducer {
 
     private void doProcessResult(Exchange exchange, Object result, SqlSession session) {
         final String outputHeader = getEndpoint().getOutputHeader();
-        if (endpoint.getStatementType() == StatementType.SelectList || endpoint.getStatementType() == StatementType.SelectOne) {
-            Message answer = exchange.getIn();
-            if (ExchangeHelper.isOutCapable(exchange)) {
-                answer = exchange.getOut();
-                // preserve headers
-                answer.getHeaders().putAll(exchange.getIn().getHeaders());
+        Message answer = exchange.getIn();
+        if (ExchangeHelper.isOutCapable(exchange)) {
+            answer = exchange.getOut();
+            // preserve headers
+            answer.getHeaders().putAll(exchange.getIn().getHeaders());
+            if (outputHeader != null) {
+            	//if we put the MyBatis result into a header we should preserve the body as well
+            	answer.setBody(exchange.getIn().getBody());
             }
-
+        }
+        if (endpoint.getStatementType() == StatementType.SelectList || endpoint.getStatementType() == StatementType.SelectOne) {
             // we should not set the body if its a stored procedure as the result is already in its OUT parameter
             MappedStatement ms = session.getConfiguration().getMappedStatement(statement);
             if (ms != null && ms.getStatementType() == org.apache.ibatis.mapping.StatementType.CALLABLE) {
@@ -265,16 +268,11 @@ public class MyBatisProducer extends DefaultProducer {
                 }
             }
 
-            answer.setHeader(MyBatisConstants.MYBATIS_STATEMENT_NAME, statement);
         } else {
-            Message msg = exchange.getIn();
-            if (outputHeader != null) {
-                msg.setHeader(outputHeader, result);
-            } else {
-                msg.setHeader(MyBatisConstants.MYBATIS_RESULT, result);
-            }
-            msg.setHeader(MyBatisConstants.MYBATIS_STATEMENT_NAME, statement);
+        	final String headerName = (outputHeader != null) ? outputHeader : MyBatisConstants.MYBATIS_RESULT;
+           	answer.setHeader(headerName, result);
         }
+        answer.setHeader(MyBatisConstants.MYBATIS_STATEMENT_NAME, statement);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/6da5a7f6/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
new file mode 100644
index 0000000..d646d43
--- /dev/null
+++ b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.component.mybatis;
+
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class MyBatisSelectOneExchangeInOutWithOutputHeaderTest extends MyBatisTestSupport {
+
+    private static final String TEST_CASE_HEADER_NAME = "testCaseHeader";
+    private static final int TEST_ACCOUNT_ID = 456;
+
+    @Test
+    public void testSelectOneWithOutputHeader() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).header(TEST_CASE_HEADER_NAME).isInstanceOf(Account.class);
+        mock.message(0).body().isEqualTo(TEST_ACCOUNT_ID);
+        mock.message(0).header(MyBatisConstants.MYBATIS_RESULT).isNull();
+
+        template.sendBody("direct:start", TEST_ACCOUNT_ID);
+
+        assertMockEndpointsSatisfied();
+
+        Account account = mock.getReceivedExchanges().get(0).getIn().getHeader(TEST_CASE_HEADER_NAME, Account.class);
+        assertEquals("Claus", account.getFirstName());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // START SNIPPET: e1
+                from("direct:start")
+                	.setExchangePattern(ExchangePattern.InOut)
+                    .to("mybatis:selectAccountById?statementType=SelectOne&outputHeader=" + TEST_CASE_HEADER_NAME)
+                    .to("mock:result");
+                // END SNIPPET: e1
+            }
+        };
+    }
+
+}


[3/5] camel git commit: Fixed CS

Posted by da...@apache.org.
Fixed CS


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c9e105bb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c9e105bb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c9e105bb

Branch: refs/heads/master
Commit: c9e105bb047a57d7995ebb0b8d6cca7bb0f0b775
Parents: 8106485
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Jun 5 08:28:12 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jun 5 08:28:12 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/mybatis/MyBatisProducer.java  | 11 ++++++-----
 ...yBatisSelectOneExchangeInOutWithOutputHeaderTest.java |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c9e105bb/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java b/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
index 63a1e89..9eb435c 100644
--- a/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
+++ b/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
@@ -228,13 +228,14 @@ public class MyBatisProducer extends DefaultProducer {
     private void doProcessResult(Exchange exchange, Object result, SqlSession session) {
         final String outputHeader = getEndpoint().getOutputHeader();
         Message answer = exchange.getIn();
+
         if (ExchangeHelper.isOutCapable(exchange)) {
             answer = exchange.getOut();
             // preserve headers
             answer.getHeaders().putAll(exchange.getIn().getHeaders());
             if (outputHeader != null) {
-            	//if we put the MyBatis result into a header we should preserve the body as well
-            	answer.setBody(exchange.getIn().getBody());
+                //if we put the MyBatis result into a header we should preserve the body as well
+                answer.setBody(exchange.getIn().getBody());
             }
         }
         if (endpoint.getStatementType() == StatementType.SelectList || endpoint.getStatementType() == StatementType.SelectOne) {
@@ -269,8 +270,8 @@ public class MyBatisProducer extends DefaultProducer {
             }
 
         } else {
-        	final String headerName = (outputHeader != null) ? outputHeader : MyBatisConstants.MYBATIS_RESULT;
-           	answer.setHeader(headerName, result);
+            final String headerName = (outputHeader != null) ? outputHeader : MyBatisConstants.MYBATIS_RESULT;
+            answer.setHeader(headerName, result);
         }
         answer.setHeader(MyBatisConstants.MYBATIS_STATEMENT_NAME, statement);
     }
@@ -288,5 +289,5 @@ public class MyBatisProducer extends DefaultProducer {
             return exchange.getIn().getBody();
         }
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/c9e105bb/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
index d646d43..fb6a521 100644
--- a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
+++ b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
@@ -49,7 +49,7 @@ public class MyBatisSelectOneExchangeInOutWithOutputHeaderTest extends MyBatisTe
             public void configure() throws Exception {
                 // START SNIPPET: e1
                 from("direct:start")
-                	.setExchangePattern(ExchangePattern.InOut)
+                    .setExchangePattern(ExchangePattern.InOut)
                     .to("mybatis:selectAccountById?statementType=SelectOne&outputHeader=" + TEST_CASE_HEADER_NAME)
                     .to("mock:result");
                 // END SNIPPET: e1


[5/5] camel git commit: Fixed CS

Posted by da...@apache.org.
Fixed CS


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e3c69500
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e3c69500
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e3c69500

Branch: refs/heads/camel-2.15.x
Commit: e3c695004e59ad6466912f8a294a8025c9bc0744
Parents: cb203e5
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Jun 5 08:28:12 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jun 5 08:29:20 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/mybatis/MyBatisProducer.java  | 11 ++++++-----
 ...yBatisSelectOneExchangeInOutWithOutputHeaderTest.java |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e3c69500/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java b/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
index 63a1e89..9eb435c 100644
--- a/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
+++ b/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
@@ -228,13 +228,14 @@ public class MyBatisProducer extends DefaultProducer {
     private void doProcessResult(Exchange exchange, Object result, SqlSession session) {
         final String outputHeader = getEndpoint().getOutputHeader();
         Message answer = exchange.getIn();
+
         if (ExchangeHelper.isOutCapable(exchange)) {
             answer = exchange.getOut();
             // preserve headers
             answer.getHeaders().putAll(exchange.getIn().getHeaders());
             if (outputHeader != null) {
-            	//if we put the MyBatis result into a header we should preserve the body as well
-            	answer.setBody(exchange.getIn().getBody());
+                //if we put the MyBatis result into a header we should preserve the body as well
+                answer.setBody(exchange.getIn().getBody());
             }
         }
         if (endpoint.getStatementType() == StatementType.SelectList || endpoint.getStatementType() == StatementType.SelectOne) {
@@ -269,8 +270,8 @@ public class MyBatisProducer extends DefaultProducer {
             }
 
         } else {
-        	final String headerName = (outputHeader != null) ? outputHeader : MyBatisConstants.MYBATIS_RESULT;
-           	answer.setHeader(headerName, result);
+            final String headerName = (outputHeader != null) ? outputHeader : MyBatisConstants.MYBATIS_RESULT;
+            answer.setHeader(headerName, result);
         }
         answer.setHeader(MyBatisConstants.MYBATIS_STATEMENT_NAME, statement);
     }
@@ -288,5 +289,5 @@ public class MyBatisProducer extends DefaultProducer {
             return exchange.getIn().getBody();
         }
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e3c69500/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
index d646d43..fb6a521 100644
--- a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
+++ b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
@@ -49,7 +49,7 @@ public class MyBatisSelectOneExchangeInOutWithOutputHeaderTest extends MyBatisTe
             public void configure() throws Exception {
                 // START SNIPPET: e1
                 from("direct:start")
-                	.setExchangePattern(ExchangePattern.InOut)
+                    .setExchangePattern(ExchangePattern.InOut)
                     .to("mybatis:selectAccountById?statementType=SelectOne&outputHeader=" + TEST_CASE_HEADER_NAME)
                     .to("mock:result");
                 // END SNIPPET: e1


[4/5] camel git commit: If ExchangePattern is InOut retain headers for all statement types and not only for select queries. Also preserve the body if outputHeader is set.

Posted by da...@apache.org.
If ExchangePattern is InOut retain headers for all statement types and not only for select queries. Also preserve the body if outputHeader is set.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cb203e5e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cb203e5e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cb203e5e

Branch: refs/heads/camel-2.15.x
Commit: cb203e5edce7eac0dbce3bccaf0445a4575becaf
Parents: bab41b7
Author: Askannon <as...@flexarc.com>
Authored: Fri Jun 5 01:15:29 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jun 5 08:29:14 2015 +0200

----------------------------------------------------------------------
 .../component/mybatis/MyBatisProducer.java      | 28 +++++----
 ...ectOneExchangeInOutWithOutputHeaderTest.java | 60 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cb203e5e/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java b/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
index 6989a57..63a1e89 100644
--- a/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
+++ b/components/camel-mybatis/src/main/java/org/apache/camel/component/mybatis/MyBatisProducer.java
@@ -227,14 +227,17 @@ public class MyBatisProducer extends DefaultProducer {
 
     private void doProcessResult(Exchange exchange, Object result, SqlSession session) {
         final String outputHeader = getEndpoint().getOutputHeader();
-        if (endpoint.getStatementType() == StatementType.SelectList || endpoint.getStatementType() == StatementType.SelectOne) {
-            Message answer = exchange.getIn();
-            if (ExchangeHelper.isOutCapable(exchange)) {
-                answer = exchange.getOut();
-                // preserve headers
-                answer.getHeaders().putAll(exchange.getIn().getHeaders());
+        Message answer = exchange.getIn();
+        if (ExchangeHelper.isOutCapable(exchange)) {
+            answer = exchange.getOut();
+            // preserve headers
+            answer.getHeaders().putAll(exchange.getIn().getHeaders());
+            if (outputHeader != null) {
+            	//if we put the MyBatis result into a header we should preserve the body as well
+            	answer.setBody(exchange.getIn().getBody());
             }
-
+        }
+        if (endpoint.getStatementType() == StatementType.SelectList || endpoint.getStatementType() == StatementType.SelectOne) {
             // we should not set the body if its a stored procedure as the result is already in its OUT parameter
             MappedStatement ms = session.getConfiguration().getMappedStatement(statement);
             if (ms != null && ms.getStatementType() == org.apache.ibatis.mapping.StatementType.CALLABLE) {
@@ -265,16 +268,11 @@ public class MyBatisProducer extends DefaultProducer {
                 }
             }
 
-            answer.setHeader(MyBatisConstants.MYBATIS_STATEMENT_NAME, statement);
         } else {
-            Message msg = exchange.getIn();
-            if (outputHeader != null) {
-                msg.setHeader(outputHeader, result);
-            } else {
-                msg.setHeader(MyBatisConstants.MYBATIS_RESULT, result);
-            }
-            msg.setHeader(MyBatisConstants.MYBATIS_STATEMENT_NAME, statement);
+        	final String headerName = (outputHeader != null) ? outputHeader : MyBatisConstants.MYBATIS_RESULT;
+           	answer.setHeader(headerName, result);
         }
+        answer.setHeader(MyBatisConstants.MYBATIS_STATEMENT_NAME, statement);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/cb203e5e/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
new file mode 100644
index 0000000..d646d43
--- /dev/null
+++ b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneExchangeInOutWithOutputHeaderTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.component.mybatis;
+
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class MyBatisSelectOneExchangeInOutWithOutputHeaderTest extends MyBatisTestSupport {
+
+    private static final String TEST_CASE_HEADER_NAME = "testCaseHeader";
+    private static final int TEST_ACCOUNT_ID = 456;
+
+    @Test
+    public void testSelectOneWithOutputHeader() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).header(TEST_CASE_HEADER_NAME).isInstanceOf(Account.class);
+        mock.message(0).body().isEqualTo(TEST_ACCOUNT_ID);
+        mock.message(0).header(MyBatisConstants.MYBATIS_RESULT).isNull();
+
+        template.sendBody("direct:start", TEST_ACCOUNT_ID);
+
+        assertMockEndpointsSatisfied();
+
+        Account account = mock.getReceivedExchanges().get(0).getIn().getHeader(TEST_CASE_HEADER_NAME, Account.class);
+        assertEquals("Claus", account.getFirstName());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // START SNIPPET: e1
+                from("direct:start")
+                	.setExchangePattern(ExchangePattern.InOut)
+                    .to("mybatis:selectAccountById?statementType=SelectOne&outputHeader=" + TEST_CASE_HEADER_NAME)
+                    .to("mock:result");
+                // END SNIPPET: e1
+            }
+        };
+    }
+
+}