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/03/31 08:21:35 UTC
[1/8] git commit: [CAMEL-7313] Adding support to retrieve generated
keys for camel-sql
Repository: camel
Updated Branches:
refs/heads/camel-2.12.x 18ac8cd60 -> 88b77a363
refs/heads/camel-2.13.x 39744db54 -> f0fbc8430
[CAMEL-7313] Adding support to retrieve generated keys for camel-sql
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6919c57c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6919c57c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6919c57c
Branch: refs/heads/camel-2.13.x
Commit: 6919c57c7cdfeb8def9b429a64668183544b7d31
Parents: 39744db
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Mar 28 21:44:35 2014 +0100
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Mar 31 14:16:43 2014 +0800
----------------------------------------------------------------------
components/camel-sql/pom.xml | 5 +
.../camel/component/sql/SqlConstants.java | 25 ++
.../apache/camel/component/sql/SqlProducer.java | 48 +++-
.../component/sql/SqlGeneratedKeysTest.java | 261 +++++++++++++++++++
.../sql/createAndPopulateDatabase3.sql | 27 ++
parent/pom.xml | 7 +
6 files changed, 371 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6919c57c/components/camel-sql/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-sql/pom.xml b/components/camel-sql/pom.xml
index 3d12c4c..8b48e23 100644
--- a/components/camel-sql/pom.xml
+++ b/components/camel-sql/pom.xml
@@ -81,6 +81,11 @@
<artifactId>derby</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/camel/blob/6919c57c/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
index aef93a2..e2fef78 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
@@ -27,6 +27,31 @@ public final class SqlConstants {
public static final String SQL_ROW_COUNT = "CamelSqlRowCount";
+ /**
+ * Boolean input header.
+ * Set its value to true to retrieve generated keys, default is false
+ */
+ public static final String SQL_RETRIEVE_GENERATED_KEYS = "CamelSqlRetrieveGeneratedKeys";
+
+ /**
+ * <tt>String[]</tt> or <tt>int[]</tt> input header - optional
+ * Set it to specify the expected generated columns, see:
+ *
+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#execute(java.lang.String, int[])">
+ * java.sql.Statement.execute(java.lang.String, int[])</a>
+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#execute(java.lang.String, java.lang.String[])">
+ * java.sql.Statement.execute(java.lang.String, java.lang.String[])</a>
+ */
+ public static final String SQL_GENERATED_COLUMNS = "CamelGeneratedColumns";
+
+ /**
+ * <tt>org.springframework.jdbc.support.KeyHolder</tt> output header containing the generated keys retrieved
+ *
+ * @see <a href="http://docs.spring.io/spring/docs/3.2.x/javadoc-api/org/springframework/jdbc/support/KeyHolder.html">
+ * org.springframework.jdbc.support.KeyHolder</a>
+ */
+ public static final String SQL_GENERATED_KEY_HOLDER = "CamelSqlGeneratedKeyHolder";
+
private SqlConstants() {
// Utility class
}
http://git-wip-us.apache.org/repos/asf/camel/blob/6919c57c/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
index 870e7b4..2df7941 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
@@ -16,9 +16,11 @@
*/
package org.apache.camel.component.sql;
+import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -27,6 +29,9 @@ import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultProducer;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCallback;
+import org.springframework.jdbc.core.PreparedStatementCreator;
+import org.springframework.jdbc.support.GeneratedKeyHolder;
+import org.springframework.jdbc.support.KeyHolder;
public class SqlProducer extends DefaultProducer {
private String query;
@@ -57,7 +62,33 @@ public class SqlProducer extends DefaultProducer {
final String sql = queryHeader != null ? queryHeader : query;
final String preparedQuery = sqlPrepareStatementStrategy.prepareQuery(sql, getEndpoint().isAllowNamedParameters());
- jdbcTemplate.execute(preparedQuery, new PreparedStatementCallback<Map<?, ?>>() {
+ // CAMEL-7313 - check whether to return generated keys
+ final Boolean shouldRetrieveGeneratedKeys =
+ exchange.getIn().getHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, false, Boolean.class);
+
+ PreparedStatementCreator statementCreator = new PreparedStatementCreator() {
+ @Override
+ public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
+ if (!shouldRetrieveGeneratedKeys) {
+ return con.prepareStatement(preparedQuery);
+ } else {
+ Object expectedGeneratedColumns = exchange.getIn().getHeader(SqlConstants.SQL_GENERATED_COLUMNS);
+ if (expectedGeneratedColumns == null) {
+ return con.prepareStatement(preparedQuery, Statement.RETURN_GENERATED_KEYS);
+ } else if (expectedGeneratedColumns instanceof String[]) {
+ return con.prepareStatement(preparedQuery, (String[]) expectedGeneratedColumns);
+ } else if (expectedGeneratedColumns instanceof int[]) {
+ return con.prepareStatement(preparedQuery, (int[]) expectedGeneratedColumns);
+ } else {
+ throw new IllegalArgumentException(
+ "Header specifying expected returning columns isn't an instance of String[] or int[] but "
+ + expectedGeneratedColumns.getClass());
+ }
+ }
+ }
+ };
+
+ jdbcTemplate.execute(statementCreator, new PreparedStatementCallback<Map<?, ?>>() {
public Map<?, ?> doInPreparedStatement(PreparedStatement ps) throws SQLException {
int expected = parametersCount > 0 ? parametersCount : ps.getParameterMetaData().getParameterCount();
@@ -78,6 +109,8 @@ public class SqlProducer extends DefaultProducer {
}
}
+ boolean isResultSet = false;
+
// execute the prepared statement and populate the outgoing message
if (batch) {
int[] updateCounts = ps.executeBatch();
@@ -87,7 +120,7 @@ public class SqlProducer extends DefaultProducer {
}
exchange.getIn().setHeader(SqlConstants.SQL_UPDATE_COUNT, total);
} else {
- boolean isResultSet = ps.execute();
+ isResultSet = ps.execute();
if (isResultSet) {
// preserve headers first, so we can override the SQL_ROW_COUNT header
exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
@@ -123,6 +156,17 @@ public class SqlProducer extends DefaultProducer {
}
}
+ if (shouldRetrieveGeneratedKeys) {
+ if (isResultSet) {
+ // we won't return generated keys for SELECT statements
+ exchange.getOut().setHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, new GeneratedKeyHolder());
+ } else {
+ List<Map<String, Object>> generatedKeys = getEndpoint().queryForList(ps.getGeneratedKeys());
+ KeyHolder holder = new GeneratedKeyHolder(generatedKeys);
+ exchange.getOut().setHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, holder);
+ }
+ }
+
// data is set on exchange so return null
return null;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/6919c57c/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
new file mode 100644
index 0000000..ce3326e
--- /dev/null
+++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
@@ -0,0 +1,261 @@
+/**
+ * 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.sql;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import org.springframework.jdbc.support.KeyHolder;
+
+
+public class SqlGeneratedKeysTest extends CamelTestSupport {
+
+ private EmbeddedDatabase db;
+
+ @Before
+ public void setUp() throws Exception {
+ // Only HSQLDB seem to handle:
+ // - more than one generated column in row
+ // - return all keys generated in batch insert
+ db = new EmbeddedDatabaseBuilder()
+ .setType(EmbeddedDatabaseType.HSQL).addScript("sql/createAndPopulateDatabase3.sql").build();
+
+ super.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ db.shutdown();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ getContext().getComponent("sql", SqlComponent.class).setDataSource(db);
+ from("direct:insert").to("sql:insert into projects (project, license, description) values (#, #, #)").to("mock:result");
+ from("direct:batch").to("sql:insert into projects (project, license, description) values (#, #, #)?batch=true").to("mock:result");
+ from("direct:select").to("sql:select * from projects order by id asc").to("mock:result");
+ from("direct:insert2").to("sql:insert into developers (name, position) values (#, #)").to("mock:result");
+ }
+ };
+ }
+
+ @Test
+ public void testRetrieveGeneratedKey() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert");
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(new Object[] {"project x", "ASF", "new project"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getOut());
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+ assertEquals(1, generatedKeys.getKeyList().get(0).size());
+
+ Map<String, Object> row = generatedKeys.getKeys();
+ assertEquals("auto increment value should be 3", Integer.valueOf(3), row.get("ID"));
+
+ assertEquals("generated keys row count should be one", 1, generatedKeys.getKeyList().size());
+ }
+
+ @Test
+ public void testRetrieveGeneratedKeys() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert2");
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(new Object[] {"Star Swirl", "Wizard"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+ exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_COLUMNS, new String[]{"ID1", "ID2"});
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getOut());
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+ assertEquals(2, generatedKeys.getKeyList().get(0).size());
+
+ Map<String, Object> row = generatedKeys.getKeys();
+ assertEquals("auto increment value of ID1 should be 5", Integer.valueOf(5), row.get("ID1"));
+ assertEquals("auto increment value of ID2 should be 6", Integer.valueOf(6), row.get("ID2"));
+
+ assertEquals("generated keys row count should be one", 1, generatedKeys.getKeyList().size());
+ }
+
+ @Test
+ public void testRetrieveGeneratedKeysForBatch() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:batch");
+
+ Exchange exchange = endpoint.createExchange();
+ List<Object[]> payload = new ArrayList<Object[]>(4);
+ payload.add(new Object[] {"project x", "ASF", "new project x"});
+ payload.add(new Object[] {"project y", "ASF", "new project y"});
+ payload.add(new Object[] {"project z", "ASF", "new project z"});
+ payload.add(new Object[] {"project q", "ASF", "new project q"});
+ exchange.getIn().setBody(payload);
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getOut());
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+
+ // it seems not to work with Derby...
+ assertEquals(4, generatedKeys.getKeyList().size());
+
+ int id = 3;
+ for (Map<String, Object> row: generatedKeys.getKeyList()) {
+ assertEquals("auto increment value should be " + id, Integer.valueOf(id++), row.get("ID"));
+ }
+
+ }
+
+ @Test
+ public void testRetrieveGeneratedKeyWithStringGeneratedColumns() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert");
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(new Object[] {"project x", "ASF", "new project"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+ exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_COLUMNS, new String[]{"ID"});
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getOut());
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+ assertEquals(1, generatedKeys.getKeyList().get(0).size());
+
+ Map<String, Object> row = generatedKeys.getKeys();
+ assertEquals("auto increment value should be 3", Integer.valueOf(3), row.get("ID"));
+
+ assertEquals("generated keys row count should be one", 1, generatedKeys.getKeyList().size());
+ }
+
+ @Test
+ public void testRetrieveGeneratedKeyWithIntGeneratedColumns() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert");
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(new Object[] {"project x", "ASF", "new project"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+ exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_COLUMNS, new int[]{1});
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+ assertEquals(1, generatedKeys.getKeyList().get(0).size());
+
+ Map<String, Object> row = generatedKeys.getKeys();
+ assertEquals("auto increment value should be 3", Integer.valueOf(3), row.get("ID"));
+
+ assertEquals("generated keys row count should be one", 1, generatedKeys.getKeyList().size());
+ }
+
+ @Test
+ public void testGivenAnInvalidGeneratedColumnsHeaderThenAnExceptionIsThrown() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert");
+
+ Exchange exchange = endpoint.createExchange();
+ // then we set the SQL on the in body
+ exchange.getIn().setBody(new Object[] {"project x", "ASF", "new project"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+
+ // set wrong data type for generated columns
+ exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_COLUMNS, new Object[]{});
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ template.send(endpoint, exchange);
+
+ assertTrue(exchange.isFailed());
+ }
+
+ @Test
+ public void testNoKeysForSelect() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:select");
+
+ Exchange exchange = endpoint.createExchange();
+ // then we set the SQL on the in body
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ @SuppressWarnings("unchecked")
+ List<Map<String, Object>> result = out.getIn().getBody(List.class);
+ assertEquals("We should get 3 projects", 3, result.size());
+
+ KeyHolder holder = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertEquals("We should not get any keys", 0, holder.getKeyList().size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/6919c57c/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase3.sql
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase3.sql b/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase3.sql
new file mode 100644
index 0000000..d26fd27
--- /dev/null
+++ b/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase3.sql
@@ -0,0 +1,27 @@
+-- ------------------------------------------------------------------------
+-- 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.
+-- ------------------------------------------------------------------------
+
+-- START SNIPPET: e1
+create table projects (id integer primary key GENERATED ALWAYS AS IDENTITY, project varchar(10), license varchar(5), description varchar(1000) default null);
+insert into projects (project, license, description) values ('Camel', 'ASF', '');
+insert into projects (project, license, description) values ('AMQ', 'ASF', '');
+insert into projects (project, license, description) values ('Linux', 'XXX', '');
+-- END SNIPPET: e1
+
+-- START SNIPPET: e2
+create table developers (id1 integer primary key GENERATED ALWAYS AS IDENTITY (START WITH 5), name varchar(20), position varchar(20), id2 integer GENERATED ALWAYS AS (id1+1));
+-- END SNIPPET: e2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/6919c57c/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index eacf016..b7fa009 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -179,6 +179,7 @@
<hbase-bundle-version>0.94.6_1</hbase-bundle-version>
<hibernate-validator-version>5.0.3.Final</hibernate-validator-version>
<hibernate-version>4.2.9.Final</hibernate-version>
+ <hsqldb-version>2.3.2</hsqldb-version>
<httpunit-version>1.7</httpunit-version>
<httpcore4-version>4.3.2</httpcore4-version>
<httpclient4-version>4.3.3</httpclient4-version>
@@ -1930,6 +1931,12 @@
<artifactId>derby</artifactId>
<version>${derby-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${hsqldb-version}</version>
+ <scope>test</scope>
+ </dependency>
<!-- optional SNMP4J -->
<dependency>
[6/8] git commit: Add unit test to support scenario
concurrentConsumers
Posted by ni...@apache.org.
Add unit test to support scenario concurrentConsumers
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/eee057cb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/eee057cb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/eee057cb
Branch: refs/heads/camel-2.12.x
Commit: eee057cb9f967bca5322244664ba0416c7682d6a
Parents: 0f11a6f
Author: Charles Moulliard <ch...@gmail.com>
Authored: Mon Mar 17 11:21:08 2014 +0100
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Mar 31 14:20:53 2014 +0800
----------------------------------------------------------------------
.../component/sjms/CamelJmsTestHelper.java | 83 ++++++++++++++++++++
.../consumer/InOutConcurrentConsumerTest.java | 80 +++++++++++++++++++
2 files changed, 163 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/eee057cb/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
new file mode 100644
index 0000000..00e3555
--- /dev/null
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
@@ -0,0 +1,83 @@
+package org.apache.camel.component.sjms;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.camel.util.FileUtil;
+
+import javax.jms.ConnectionFactory;
+import java.io.File;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * A helper for unit testing with Apache ActiveMQ as embedded JMS broker.
+ *
+ * @version
+ */
+public final class CamelJmsTestHelper {
+
+ private static AtomicInteger counter = new AtomicInteger(0);
+
+ private CamelJmsTestHelper() {
+ }
+
+ public static ConnectionFactory createConnectionFactory() {
+ return createConnectionFactory(null);
+ }
+
+ public static ConnectionFactory createConnectionFactory(String options) {
+ // using a unique broker name improves testing when running the entire test suite in the same JVM
+ int id = counter.incrementAndGet();
+ String url = "vm://test-broker-" + id + "?broker.persistent=false&broker.useJmx=false";
+ if (options != null) {
+ url = url + "&" + options;
+ }
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
+ // optimize AMQ to be as fast as possible so unit testing is quicker
+ connectionFactory.setCopyMessageOnSend(false);
+ connectionFactory.setOptimizeAcknowledge(true);
+ connectionFactory.setOptimizedMessageDispatch(true);
+
+ // When using asyncSend, producers will not be guaranteed to send in the order we
+ // have in the tests (which may be confusing for queues) so we need this set to false.
+ // Another way of guaranteeing order is to use persistent messages or transactions.
+ connectionFactory.setUseAsyncSend(false);
+
+ connectionFactory.setAlwaysSessionAsync(false);
+ // use a pooled connection factory
+ PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
+ pooled.setMaxConnections(8);
+ return pooled;
+ }
+
+ public static ConnectionFactory createPersistentConnectionFactory() {
+ return createPersistentConnectionFactory(null);
+ }
+
+ public static ConnectionFactory createPersistentConnectionFactory(String options) {
+ // using a unique broker name improves testing when running the entire test suite in the same JVM
+ int id = counter.incrementAndGet();
+
+ // use an unique data directory in target
+ String dir = "target/activemq-data-" + id;
+
+ // remove dir so its empty on startup
+ FileUtil.removeDir(new File(dir));
+
+ String url = "vm://test-broker-" + id + "?broker.persistent=true&broker.useJmx=false&broker.dataDirectory=" + dir;
+ if (options != null) {
+ url = url + "&" + options;
+ }
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
+ // optimize AMQ to be as fast as possible so unit testing is quicker
+ connectionFactory.setCopyMessageOnSend(false);
+ connectionFactory.setOptimizeAcknowledge(true);
+ connectionFactory.setOptimizedMessageDispatch(true);
+ connectionFactory.setUseAsyncSend(true);
+ connectionFactory.setAlwaysSessionAsync(false);
+
+ // use a pooled connection factory
+ PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
+ pooled.setMaxConnections(8);
+ return pooled;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/eee057cb/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
new file mode 100644
index 0000000..fc18efc
--- /dev/null
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
@@ -0,0 +1,80 @@
+package org.apache.camel.component.sjms.consumer;
+
+import org.apache.camel.*;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.*;
+
+/**
+ * Concurrent consumer with JMSReply test.
+ */
+public class InOutConcurrentConsumerTest extends JmsTestSupport {
+
+ @EndpointInject(uri = "mock:result")
+ MockEndpoint result;
+
+ @Test
+ public void testConcurrent() throws Exception {
+ doSendMessages(10, 5);
+ }
+
+ private void doSendMessages(int messages, int poolSize) throws Exception {
+
+ result.expectedMessageCount(messages);
+ result.expectsNoDuplicates(body());
+
+ ExecutorService executor = Executors.newFixedThreadPool(poolSize);
+ final List<Future<String>> futures = new ArrayList<Future<String>>();
+ for (int i = 0; i < messages; i++) {
+ final int index = i;
+ Future<String> out = executor.submit(new Callable<String>() {
+ public String call() throws Exception {
+ return template.requestBody("direct:start", "Message " + index, String.class);
+ }
+ });
+ futures.add(out);
+ }
+
+ assertMockEndpointsSatisfied();
+
+ for (int i = 0; i < futures.size(); i++) {
+ Object out = futures.get(i).get();
+ assertEquals("Bye Message " + i, out);
+ }
+ executor.shutdownNow();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+ return camelContext;
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("sjms:a?consumerCount=5&exchangePattern=InOut&namedReplyTo=myResponse")
+ .to("mock:result");
+
+ from("sjms:a?consumerCount=5&exchangePattern=InOut&namedReplyTo=myResponse")
+ .process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ String body = exchange.getIn().getBody(String.class);
+ // sleep a little to simulate heavy work and force concurrency processing
+ Thread.sleep(1000);
+ exchange.getOut().setBody("Bye " + body);
+ exchange.getOut().setHeader("threadName", Thread.currentThread().getName());
+ System.out.println("Thread ID : " + Thread.currentThread().getName());
+ }
+ });
+ }
+ };
+ }
+
+}
+
[2/8] git commit: Add unit test to support scenario
concurrentConsumers
Posted by ni...@apache.org.
Add unit test to support scenario concurrentConsumers
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/85833902
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/85833902
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/85833902
Branch: refs/heads/camel-2.13.x
Commit: 85833902ef13959ea07345f3b92696c1593c521e
Parents: 6919c57
Author: Charles Moulliard <ch...@gmail.com>
Authored: Mon Mar 17 11:21:08 2014 +0100
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Mar 31 14:19:08 2014 +0800
----------------------------------------------------------------------
.../component/sjms/CamelJmsTestHelper.java | 83 ++++++++++++++++++++
.../consumer/InOutConcurrentConsumerTest.java | 80 +++++++++++++++++++
2 files changed, 163 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/85833902/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
new file mode 100644
index 0000000..00e3555
--- /dev/null
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
@@ -0,0 +1,83 @@
+package org.apache.camel.component.sjms;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.camel.util.FileUtil;
+
+import javax.jms.ConnectionFactory;
+import java.io.File;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * A helper for unit testing with Apache ActiveMQ as embedded JMS broker.
+ *
+ * @version
+ */
+public final class CamelJmsTestHelper {
+
+ private static AtomicInteger counter = new AtomicInteger(0);
+
+ private CamelJmsTestHelper() {
+ }
+
+ public static ConnectionFactory createConnectionFactory() {
+ return createConnectionFactory(null);
+ }
+
+ public static ConnectionFactory createConnectionFactory(String options) {
+ // using a unique broker name improves testing when running the entire test suite in the same JVM
+ int id = counter.incrementAndGet();
+ String url = "vm://test-broker-" + id + "?broker.persistent=false&broker.useJmx=false";
+ if (options != null) {
+ url = url + "&" + options;
+ }
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
+ // optimize AMQ to be as fast as possible so unit testing is quicker
+ connectionFactory.setCopyMessageOnSend(false);
+ connectionFactory.setOptimizeAcknowledge(true);
+ connectionFactory.setOptimizedMessageDispatch(true);
+
+ // When using asyncSend, producers will not be guaranteed to send in the order we
+ // have in the tests (which may be confusing for queues) so we need this set to false.
+ // Another way of guaranteeing order is to use persistent messages or transactions.
+ connectionFactory.setUseAsyncSend(false);
+
+ connectionFactory.setAlwaysSessionAsync(false);
+ // use a pooled connection factory
+ PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
+ pooled.setMaxConnections(8);
+ return pooled;
+ }
+
+ public static ConnectionFactory createPersistentConnectionFactory() {
+ return createPersistentConnectionFactory(null);
+ }
+
+ public static ConnectionFactory createPersistentConnectionFactory(String options) {
+ // using a unique broker name improves testing when running the entire test suite in the same JVM
+ int id = counter.incrementAndGet();
+
+ // use an unique data directory in target
+ String dir = "target/activemq-data-" + id;
+
+ // remove dir so its empty on startup
+ FileUtil.removeDir(new File(dir));
+
+ String url = "vm://test-broker-" + id + "?broker.persistent=true&broker.useJmx=false&broker.dataDirectory=" + dir;
+ if (options != null) {
+ url = url + "&" + options;
+ }
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
+ // optimize AMQ to be as fast as possible so unit testing is quicker
+ connectionFactory.setCopyMessageOnSend(false);
+ connectionFactory.setOptimizeAcknowledge(true);
+ connectionFactory.setOptimizedMessageDispatch(true);
+ connectionFactory.setUseAsyncSend(true);
+ connectionFactory.setAlwaysSessionAsync(false);
+
+ // use a pooled connection factory
+ PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
+ pooled.setMaxConnections(8);
+ return pooled;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/85833902/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
new file mode 100644
index 0000000..fc18efc
--- /dev/null
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
@@ -0,0 +1,80 @@
+package org.apache.camel.component.sjms.consumer;
+
+import org.apache.camel.*;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.*;
+
+/**
+ * Concurrent consumer with JMSReply test.
+ */
+public class InOutConcurrentConsumerTest extends JmsTestSupport {
+
+ @EndpointInject(uri = "mock:result")
+ MockEndpoint result;
+
+ @Test
+ public void testConcurrent() throws Exception {
+ doSendMessages(10, 5);
+ }
+
+ private void doSendMessages(int messages, int poolSize) throws Exception {
+
+ result.expectedMessageCount(messages);
+ result.expectsNoDuplicates(body());
+
+ ExecutorService executor = Executors.newFixedThreadPool(poolSize);
+ final List<Future<String>> futures = new ArrayList<Future<String>>();
+ for (int i = 0; i < messages; i++) {
+ final int index = i;
+ Future<String> out = executor.submit(new Callable<String>() {
+ public String call() throws Exception {
+ return template.requestBody("direct:start", "Message " + index, String.class);
+ }
+ });
+ futures.add(out);
+ }
+
+ assertMockEndpointsSatisfied();
+
+ for (int i = 0; i < futures.size(); i++) {
+ Object out = futures.get(i).get();
+ assertEquals("Bye Message " + i, out);
+ }
+ executor.shutdownNow();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+ return camelContext;
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("sjms:a?consumerCount=5&exchangePattern=InOut&namedReplyTo=myResponse")
+ .to("mock:result");
+
+ from("sjms:a?consumerCount=5&exchangePattern=InOut&namedReplyTo=myResponse")
+ .process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ String body = exchange.getIn().getBody(String.class);
+ // sleep a little to simulate heavy work and force concurrency processing
+ Thread.sleep(1000);
+ exchange.getOut().setBody("Bye " + body);
+ exchange.getOut().setHeader("threadName", Thread.currentThread().getName());
+ System.out.println("Thread ID : " + Thread.currentThread().getName());
+ }
+ });
+ }
+ };
+ }
+
+}
+
[7/8] git commit: Fixed the CS error of camel-sjms
Posted by ni...@apache.org.
Fixed the CS error of camel-sjms
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ab75ad35
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ab75ad35
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ab75ad35
Branch: refs/heads/camel-2.12.x
Commit: ab75ad35e7963ad4ebd58646d63aaf052a506678
Parents: eee057c
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Mar 31 14:02:00 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Mar 31 14:21:01 2014 +0800
----------------------------------------------------------------------
.../component/sjms/CamelJmsTestHelper.java | 25 +++++-
.../component/sjms/bugfixes/CAMEL6820Test.java | 88 ++++++++++++++++++++
.../component/sjms/bugfixes/CAMEL_6820Test.java | 88 --------------------
.../consumer/InOutConcurrentConsumerTest.java | 32 +++++--
4 files changed, 136 insertions(+), 97 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ab75ad35/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
index 00e3555..f816147 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
@@ -1,13 +1,30 @@
+/**
+ * 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.sjms;
+import java.io.File;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jms.ConnectionFactory;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.pool.PooledConnectionFactory;
import org.apache.camel.util.FileUtil;
-import javax.jms.ConnectionFactory;
-import java.io.File;
-import java.util.concurrent.atomic.AtomicInteger;
-
/**
* A helper for unit testing with Apache ActiveMQ as embedded JMS broker.
*
http://git-wip-us.apache.org/repos/asf/camel/blob/ab75ad35/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java
new file mode 100644
index 0000000..1add845
--- /dev/null
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java
@@ -0,0 +1,88 @@
+/**
+ * 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.sjms.bugfixes;
+
+import java.io.File;
+import java.io.InputStream;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.SjmsComponent;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+
+/**
+ * Unit test for CAMEL_6820Test. This test is to verify the ability to
+ * support the Camel File Component more cleanly along with better support
+ * for ByteMessages.
+ */
+public class CAMEL6820Test extends JmsTestSupport {
+
+ private static final String TEST_DATA_DIR = "target/testdata";
+ private static final String FILE_OUTPUT_URI = "file:" + TEST_DATA_DIR;
+ private static final String FILE_INPUT_URI = "file:" + TEST_DATA_DIR;
+ private static final String SJMS_QUEUE_URI = "sjms:queue:file.converter.queue";
+ private static final String MOCK_RESULT_URI = "mock:result";
+
+ @Test
+ public void testCamelGenericFileConverterMessage() throws Exception {
+ File f = new File(TEST_DATA_DIR);
+
+ // First make sure the directories are empty or purged so we don't get bad data on a
+ // test that is run against an uncleaned target directory
+ if (f.exists()) {
+ FileUtils.deleteDirectory(new File(TEST_DATA_DIR));
+
+ }
+
+ // Then add the directory back
+ f.mkdirs();
+
+ // Make sure the SjmsComponent is available
+ SjmsComponent component = context.getComponent("sjms", SjmsComponent.class);
+ assertNotNull(component);
+
+ // Create the test String
+ final String expectedBody = "Hello World";
+
+ // Create the Mock endpoint
+ MockEndpoint mock = getMockEndpoint(MOCK_RESULT_URI);
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived(expectedBody);
+
+ // Send the message to a file to be read by the file component
+ template.sendBody(FILE_OUTPUT_URI, expectedBody);
+
+ // Verify that it is working correctly
+ mock.assertIsSatisfied();
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(FILE_INPUT_URI)
+ .convertBodyTo(InputStream.class)
+ .to(SJMS_QUEUE_URI);
+
+ from(SJMS_QUEUE_URI)
+ .convertBodyTo(String.class)
+ .to(MOCK_RESULT_URI);
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/ab75ad35/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java
deleted file mode 100644
index e6e0ce4..0000000
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.sjms.bugfixes;
-
-import java.io.File;
-import java.io.InputStream;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.sjms.SjmsComponent;
-import org.apache.camel.component.sjms.support.JmsTestSupport;
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-
-/**
- * Unit test for CAMEL_6820Test. This test is to verify the ability to
- * support the Camel File Component more cleanly along with better support
- * for ByteMessages.
- */
-public class CAMEL_6820Test extends JmsTestSupport {
-
- private static final String TEST_DATA_DIR = "target/testdata";
- private static final String FILE_OUTPUT_URI = "file:" + TEST_DATA_DIR;
- private static final String FILE_INPUT_URI = "file:" + TEST_DATA_DIR;
- private static final String SJMS_QUEUE_URI = "sjms:queue:file.converter.queue";
- private static final String MOCK_RESULT_URI = "mock:result";
-
- @Test
- public void testCamelGenericFileConverterMessage() throws Exception {
- File f = new File(TEST_DATA_DIR);
-
- // First make sure the directories are empty or purged so we don't get bad data on a
- // test that is run against an uncleaned target directory
- if (f.exists()) {
- FileUtils.deleteDirectory(new File(TEST_DATA_DIR));
-
- }
-
- // Then add the directory back
- f.mkdirs();
-
- // Make sure the SjmsComponent is available
- SjmsComponent component = context.getComponent("sjms", SjmsComponent.class);
- assertNotNull(component);
-
- // Create the test String
- final String expectedBody = "Hello World";
-
- // Create the Mock endpoint
- MockEndpoint mock = getMockEndpoint(MOCK_RESULT_URI);
- mock.expectedMessageCount(1);
- mock.expectedBodiesReceived(expectedBody);
-
- // Send the message to a file to be read by the file component
- template.sendBody(FILE_OUTPUT_URI, expectedBody);
-
- // Verify that it is working correctly
- mock.assertIsSatisfied();
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(FILE_INPUT_URI)
- .convertBodyTo(InputStream.class)
- .to(SJMS_QUEUE_URI);
-
- from(SJMS_QUEUE_URI)
- .convertBodyTo(String.class)
- .to(MOCK_RESULT_URI);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/ab75ad35/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
index fc18efc..a364c8c 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
@@ -1,15 +1,37 @@
+/**
+ * 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.sjms.consumer;
-import org.apache.camel.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.sjms.support.JmsTestSupport;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.*;
-
/**
* Concurrent consumer with JMSReply test.
*/
[3/8] git commit: Fixed the CS error of camel-sjms
Posted by ni...@apache.org.
Fixed the CS error of camel-sjms
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2010c0a5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2010c0a5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2010c0a5
Branch: refs/heads/camel-2.13.x
Commit: 2010c0a54966e80aee1e8c2648907bfd25355084
Parents: 8583390
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Mar 31 14:02:00 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Mar 31 14:19:38 2014 +0800
----------------------------------------------------------------------
.../component/sjms/CamelJmsTestHelper.java | 25 +++++-
.../component/sjms/bugfixes/CAMEL6820Test.java | 88 ++++++++++++++++++++
.../component/sjms/bugfixes/CAMEL_6820Test.java | 88 --------------------
.../consumer/InOutConcurrentConsumerTest.java | 32 +++++--
4 files changed, 136 insertions(+), 97 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2010c0a5/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
index 00e3555..f816147 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java
@@ -1,13 +1,30 @@
+/**
+ * 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.sjms;
+import java.io.File;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jms.ConnectionFactory;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.pool.PooledConnectionFactory;
import org.apache.camel.util.FileUtil;
-import javax.jms.ConnectionFactory;
-import java.io.File;
-import java.util.concurrent.atomic.AtomicInteger;
-
/**
* A helper for unit testing with Apache ActiveMQ as embedded JMS broker.
*
http://git-wip-us.apache.org/repos/asf/camel/blob/2010c0a5/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java
new file mode 100644
index 0000000..1add845
--- /dev/null
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java
@@ -0,0 +1,88 @@
+/**
+ * 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.sjms.bugfixes;
+
+import java.io.File;
+import java.io.InputStream;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.SjmsComponent;
+import org.apache.camel.component.sjms.support.JmsTestSupport;
+import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+
+/**
+ * Unit test for CAMEL_6820Test. This test is to verify the ability to
+ * support the Camel File Component more cleanly along with better support
+ * for ByteMessages.
+ */
+public class CAMEL6820Test extends JmsTestSupport {
+
+ private static final String TEST_DATA_DIR = "target/testdata";
+ private static final String FILE_OUTPUT_URI = "file:" + TEST_DATA_DIR;
+ private static final String FILE_INPUT_URI = "file:" + TEST_DATA_DIR;
+ private static final String SJMS_QUEUE_URI = "sjms:queue:file.converter.queue";
+ private static final String MOCK_RESULT_URI = "mock:result";
+
+ @Test
+ public void testCamelGenericFileConverterMessage() throws Exception {
+ File f = new File(TEST_DATA_DIR);
+
+ // First make sure the directories are empty or purged so we don't get bad data on a
+ // test that is run against an uncleaned target directory
+ if (f.exists()) {
+ FileUtils.deleteDirectory(new File(TEST_DATA_DIR));
+
+ }
+
+ // Then add the directory back
+ f.mkdirs();
+
+ // Make sure the SjmsComponent is available
+ SjmsComponent component = context.getComponent("sjms", SjmsComponent.class);
+ assertNotNull(component);
+
+ // Create the test String
+ final String expectedBody = "Hello World";
+
+ // Create the Mock endpoint
+ MockEndpoint mock = getMockEndpoint(MOCK_RESULT_URI);
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived(expectedBody);
+
+ // Send the message to a file to be read by the file component
+ template.sendBody(FILE_OUTPUT_URI, expectedBody);
+
+ // Verify that it is working correctly
+ mock.assertIsSatisfied();
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(FILE_INPUT_URI)
+ .convertBodyTo(InputStream.class)
+ .to(SJMS_QUEUE_URI);
+
+ from(SJMS_QUEUE_URI)
+ .convertBodyTo(String.class)
+ .to(MOCK_RESULT_URI);
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2010c0a5/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java
deleted file mode 100644
index e6e0ce4..0000000
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.sjms.bugfixes;
-
-import java.io.File;
-import java.io.InputStream;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.sjms.SjmsComponent;
-import org.apache.camel.component.sjms.support.JmsTestSupport;
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-
-/**
- * Unit test for CAMEL_6820Test. This test is to verify the ability to
- * support the Camel File Component more cleanly along with better support
- * for ByteMessages.
- */
-public class CAMEL_6820Test extends JmsTestSupport {
-
- private static final String TEST_DATA_DIR = "target/testdata";
- private static final String FILE_OUTPUT_URI = "file:" + TEST_DATA_DIR;
- private static final String FILE_INPUT_URI = "file:" + TEST_DATA_DIR;
- private static final String SJMS_QUEUE_URI = "sjms:queue:file.converter.queue";
- private static final String MOCK_RESULT_URI = "mock:result";
-
- @Test
- public void testCamelGenericFileConverterMessage() throws Exception {
- File f = new File(TEST_DATA_DIR);
-
- // First make sure the directories are empty or purged so we don't get bad data on a
- // test that is run against an uncleaned target directory
- if (f.exists()) {
- FileUtils.deleteDirectory(new File(TEST_DATA_DIR));
-
- }
-
- // Then add the directory back
- f.mkdirs();
-
- // Make sure the SjmsComponent is available
- SjmsComponent component = context.getComponent("sjms", SjmsComponent.class);
- assertNotNull(component);
-
- // Create the test String
- final String expectedBody = "Hello World";
-
- // Create the Mock endpoint
- MockEndpoint mock = getMockEndpoint(MOCK_RESULT_URI);
- mock.expectedMessageCount(1);
- mock.expectedBodiesReceived(expectedBody);
-
- // Send the message to a file to be read by the file component
- template.sendBody(FILE_OUTPUT_URI, expectedBody);
-
- // Verify that it is working correctly
- mock.assertIsSatisfied();
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(FILE_INPUT_URI)
- .convertBodyTo(InputStream.class)
- .to(SJMS_QUEUE_URI);
-
- from(SJMS_QUEUE_URI)
- .convertBodyTo(String.class)
- .to(MOCK_RESULT_URI);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/2010c0a5/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
index fc18efc..a364c8c 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
@@ -1,15 +1,37 @@
+/**
+ * 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.sjms.consumer;
-import org.apache.camel.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.sjms.support.JmsTestSupport;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.*;
-
/**
* Concurrent consumer with JMSReply test.
*/
[5/8] git commit: [CAMEL-7313] Adding support to retrieve generated
keys for camel-sql
Posted by ni...@apache.org.
[CAMEL-7313] Adding support to retrieve generated keys for camel-sql
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0f11a6fb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0f11a6fb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0f11a6fb
Branch: refs/heads/camel-2.12.x
Commit: 0f11a6fb218962612059b0b5b1c49b83fd3a140f
Parents: 18ac8cd
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri Mar 28 21:44:35 2014 +0100
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Mar 31 14:20:40 2014 +0800
----------------------------------------------------------------------
components/camel-sql/pom.xml | 5 +
.../camel/component/sql/SqlConstants.java | 25 ++
.../apache/camel/component/sql/SqlProducer.java | 48 +++-
.../component/sql/SqlGeneratedKeysTest.java | 261 +++++++++++++++++++
.../sql/createAndPopulateDatabase3.sql | 27 ++
parent/pom.xml | 7 +
6 files changed, 371 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0f11a6fb/components/camel-sql/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-sql/pom.xml b/components/camel-sql/pom.xml
index 62b9777..1ebb207 100644
--- a/components/camel-sql/pom.xml
+++ b/components/camel-sql/pom.xml
@@ -81,6 +81,11 @@
<artifactId>derby</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/camel/blob/0f11a6fb/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
index aef93a2..e2fef78 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
@@ -27,6 +27,31 @@ public final class SqlConstants {
public static final String SQL_ROW_COUNT = "CamelSqlRowCount";
+ /**
+ * Boolean input header.
+ * Set its value to true to retrieve generated keys, default is false
+ */
+ public static final String SQL_RETRIEVE_GENERATED_KEYS = "CamelSqlRetrieveGeneratedKeys";
+
+ /**
+ * <tt>String[]</tt> or <tt>int[]</tt> input header - optional
+ * Set it to specify the expected generated columns, see:
+ *
+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#execute(java.lang.String, int[])">
+ * java.sql.Statement.execute(java.lang.String, int[])</a>
+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#execute(java.lang.String, java.lang.String[])">
+ * java.sql.Statement.execute(java.lang.String, java.lang.String[])</a>
+ */
+ public static final String SQL_GENERATED_COLUMNS = "CamelGeneratedColumns";
+
+ /**
+ * <tt>org.springframework.jdbc.support.KeyHolder</tt> output header containing the generated keys retrieved
+ *
+ * @see <a href="http://docs.spring.io/spring/docs/3.2.x/javadoc-api/org/springframework/jdbc/support/KeyHolder.html">
+ * org.springframework.jdbc.support.KeyHolder</a>
+ */
+ public static final String SQL_GENERATED_KEY_HOLDER = "CamelSqlGeneratedKeyHolder";
+
private SqlConstants() {
// Utility class
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0f11a6fb/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
index 870e7b4..2df7941 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
@@ -16,9 +16,11 @@
*/
package org.apache.camel.component.sql;
+import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -27,6 +29,9 @@ import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultProducer;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCallback;
+import org.springframework.jdbc.core.PreparedStatementCreator;
+import org.springframework.jdbc.support.GeneratedKeyHolder;
+import org.springframework.jdbc.support.KeyHolder;
public class SqlProducer extends DefaultProducer {
private String query;
@@ -57,7 +62,33 @@ public class SqlProducer extends DefaultProducer {
final String sql = queryHeader != null ? queryHeader : query;
final String preparedQuery = sqlPrepareStatementStrategy.prepareQuery(sql, getEndpoint().isAllowNamedParameters());
- jdbcTemplate.execute(preparedQuery, new PreparedStatementCallback<Map<?, ?>>() {
+ // CAMEL-7313 - check whether to return generated keys
+ final Boolean shouldRetrieveGeneratedKeys =
+ exchange.getIn().getHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, false, Boolean.class);
+
+ PreparedStatementCreator statementCreator = new PreparedStatementCreator() {
+ @Override
+ public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
+ if (!shouldRetrieveGeneratedKeys) {
+ return con.prepareStatement(preparedQuery);
+ } else {
+ Object expectedGeneratedColumns = exchange.getIn().getHeader(SqlConstants.SQL_GENERATED_COLUMNS);
+ if (expectedGeneratedColumns == null) {
+ return con.prepareStatement(preparedQuery, Statement.RETURN_GENERATED_KEYS);
+ } else if (expectedGeneratedColumns instanceof String[]) {
+ return con.prepareStatement(preparedQuery, (String[]) expectedGeneratedColumns);
+ } else if (expectedGeneratedColumns instanceof int[]) {
+ return con.prepareStatement(preparedQuery, (int[]) expectedGeneratedColumns);
+ } else {
+ throw new IllegalArgumentException(
+ "Header specifying expected returning columns isn't an instance of String[] or int[] but "
+ + expectedGeneratedColumns.getClass());
+ }
+ }
+ }
+ };
+
+ jdbcTemplate.execute(statementCreator, new PreparedStatementCallback<Map<?, ?>>() {
public Map<?, ?> doInPreparedStatement(PreparedStatement ps) throws SQLException {
int expected = parametersCount > 0 ? parametersCount : ps.getParameterMetaData().getParameterCount();
@@ -78,6 +109,8 @@ public class SqlProducer extends DefaultProducer {
}
}
+ boolean isResultSet = false;
+
// execute the prepared statement and populate the outgoing message
if (batch) {
int[] updateCounts = ps.executeBatch();
@@ -87,7 +120,7 @@ public class SqlProducer extends DefaultProducer {
}
exchange.getIn().setHeader(SqlConstants.SQL_UPDATE_COUNT, total);
} else {
- boolean isResultSet = ps.execute();
+ isResultSet = ps.execute();
if (isResultSet) {
// preserve headers first, so we can override the SQL_ROW_COUNT header
exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
@@ -123,6 +156,17 @@ public class SqlProducer extends DefaultProducer {
}
}
+ if (shouldRetrieveGeneratedKeys) {
+ if (isResultSet) {
+ // we won't return generated keys for SELECT statements
+ exchange.getOut().setHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, new GeneratedKeyHolder());
+ } else {
+ List<Map<String, Object>> generatedKeys = getEndpoint().queryForList(ps.getGeneratedKeys());
+ KeyHolder holder = new GeneratedKeyHolder(generatedKeys);
+ exchange.getOut().setHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, holder);
+ }
+ }
+
// data is set on exchange so return null
return null;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0f11a6fb/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
new file mode 100644
index 0000000..ce3326e
--- /dev/null
+++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
@@ -0,0 +1,261 @@
+/**
+ * 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.sql;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import org.springframework.jdbc.support.KeyHolder;
+
+
+public class SqlGeneratedKeysTest extends CamelTestSupport {
+
+ private EmbeddedDatabase db;
+
+ @Before
+ public void setUp() throws Exception {
+ // Only HSQLDB seem to handle:
+ // - more than one generated column in row
+ // - return all keys generated in batch insert
+ db = new EmbeddedDatabaseBuilder()
+ .setType(EmbeddedDatabaseType.HSQL).addScript("sql/createAndPopulateDatabase3.sql").build();
+
+ super.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ db.shutdown();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ getContext().getComponent("sql", SqlComponent.class).setDataSource(db);
+ from("direct:insert").to("sql:insert into projects (project, license, description) values (#, #, #)").to("mock:result");
+ from("direct:batch").to("sql:insert into projects (project, license, description) values (#, #, #)?batch=true").to("mock:result");
+ from("direct:select").to("sql:select * from projects order by id asc").to("mock:result");
+ from("direct:insert2").to("sql:insert into developers (name, position) values (#, #)").to("mock:result");
+ }
+ };
+ }
+
+ @Test
+ public void testRetrieveGeneratedKey() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert");
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(new Object[] {"project x", "ASF", "new project"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getOut());
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+ assertEquals(1, generatedKeys.getKeyList().get(0).size());
+
+ Map<String, Object> row = generatedKeys.getKeys();
+ assertEquals("auto increment value should be 3", Integer.valueOf(3), row.get("ID"));
+
+ assertEquals("generated keys row count should be one", 1, generatedKeys.getKeyList().size());
+ }
+
+ @Test
+ public void testRetrieveGeneratedKeys() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert2");
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(new Object[] {"Star Swirl", "Wizard"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+ exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_COLUMNS, new String[]{"ID1", "ID2"});
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getOut());
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+ assertEquals(2, generatedKeys.getKeyList().get(0).size());
+
+ Map<String, Object> row = generatedKeys.getKeys();
+ assertEquals("auto increment value of ID1 should be 5", Integer.valueOf(5), row.get("ID1"));
+ assertEquals("auto increment value of ID2 should be 6", Integer.valueOf(6), row.get("ID2"));
+
+ assertEquals("generated keys row count should be one", 1, generatedKeys.getKeyList().size());
+ }
+
+ @Test
+ public void testRetrieveGeneratedKeysForBatch() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:batch");
+
+ Exchange exchange = endpoint.createExchange();
+ List<Object[]> payload = new ArrayList<Object[]>(4);
+ payload.add(new Object[] {"project x", "ASF", "new project x"});
+ payload.add(new Object[] {"project y", "ASF", "new project y"});
+ payload.add(new Object[] {"project z", "ASF", "new project z"});
+ payload.add(new Object[] {"project q", "ASF", "new project q"});
+ exchange.getIn().setBody(payload);
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getOut());
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+
+ // it seems not to work with Derby...
+ assertEquals(4, generatedKeys.getKeyList().size());
+
+ int id = 3;
+ for (Map<String, Object> row: generatedKeys.getKeyList()) {
+ assertEquals("auto increment value should be " + id, Integer.valueOf(id++), row.get("ID"));
+ }
+
+ }
+
+ @Test
+ public void testRetrieveGeneratedKeyWithStringGeneratedColumns() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert");
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(new Object[] {"project x", "ASF", "new project"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+ exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_COLUMNS, new String[]{"ID"});
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getOut());
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+ assertEquals(1, generatedKeys.getKeyList().get(0).size());
+
+ Map<String, Object> row = generatedKeys.getKeys();
+ assertEquals("auto increment value should be 3", Integer.valueOf(3), row.get("ID"));
+
+ assertEquals("generated keys row count should be one", 1, generatedKeys.getKeyList().size());
+ }
+
+ @Test
+ public void testRetrieveGeneratedKeyWithIntGeneratedColumns() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert");
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(new Object[] {"project x", "ASF", "new project"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+ exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_COLUMNS, new int[]{1});
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ // assertions of the response
+ assertNotNull(out);
+ assertNotNull(out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER));
+
+ KeyHolder generatedKeys = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertNotNull("out body could not be converted to a KeyHolder - was: "
+ + out.getIn().getBody(), generatedKeys);
+ assertEquals(1, generatedKeys.getKeyList().get(0).size());
+
+ Map<String, Object> row = generatedKeys.getKeys();
+ assertEquals("auto increment value should be 3", Integer.valueOf(3), row.get("ID"));
+
+ assertEquals("generated keys row count should be one", 1, generatedKeys.getKeyList().size());
+ }
+
+ @Test
+ public void testGivenAnInvalidGeneratedColumnsHeaderThenAnExceptionIsThrown() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:insert");
+
+ Exchange exchange = endpoint.createExchange();
+ // then we set the SQL on the in body
+ exchange.getIn().setBody(new Object[] {"project x", "ASF", "new project"});
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+
+ // set wrong data type for generated columns
+ exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_COLUMNS, new Object[]{});
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ template.send(endpoint, exchange);
+
+ assertTrue(exchange.isFailed());
+ }
+
+ @Test
+ public void testNoKeysForSelect() throws Exception {
+ // first we create our exchange using the endpoint
+ Endpoint endpoint = context.getEndpoint("direct:select");
+
+ Exchange exchange = endpoint.createExchange();
+ // then we set the SQL on the in body
+ exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, true);
+
+ // now we send the exchange to the endpoint, and receives the response from Camel
+ Exchange out = template.send(endpoint, exchange);
+
+ @SuppressWarnings("unchecked")
+ List<Map<String, Object>> result = out.getIn().getBody(List.class);
+ assertEquals("We should get 3 projects", 3, result.size());
+
+ KeyHolder holder = out.getIn().getHeader(SqlConstants.SQL_GENERATED_KEY_HOLDER, KeyHolder.class);
+ assertEquals("We should not get any keys", 0, holder.getKeyList().size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/0f11a6fb/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase3.sql
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase3.sql b/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase3.sql
new file mode 100644
index 0000000..d26fd27
--- /dev/null
+++ b/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase3.sql
@@ -0,0 +1,27 @@
+-- ------------------------------------------------------------------------
+-- 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.
+-- ------------------------------------------------------------------------
+
+-- START SNIPPET: e1
+create table projects (id integer primary key GENERATED ALWAYS AS IDENTITY, project varchar(10), license varchar(5), description varchar(1000) default null);
+insert into projects (project, license, description) values ('Camel', 'ASF', '');
+insert into projects (project, license, description) values ('AMQ', 'ASF', '');
+insert into projects (project, license, description) values ('Linux', 'XXX', '');
+-- END SNIPPET: e1
+
+-- START SNIPPET: e2
+create table developers (id1 integer primary key GENERATED ALWAYS AS IDENTITY (START WITH 5), name varchar(20), position varchar(20), id2 integer GENERATED ALWAYS AS (id1+1));
+-- END SNIPPET: e2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/0f11a6fb/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index dad5790..c0d78be 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -178,6 +178,7 @@
<hbase-bundle-version>0.94.6_1</hbase-bundle-version>
<hibernate-validator-version>5.0.3.Final</hibernate-validator-version>
<hibernate-version>4.2.9.Final</hibernate-version>
+ <hsqldb-version>2.3.2</hsqldb-version>
<httpunit-version>1.7</httpunit-version>
<httpcore4-version>4.2.4</httpcore4-version>
<httpclient4-version>4.2.5</httpclient4-version>
@@ -1905,6 +1906,12 @@
<artifactId>derby</artifactId>
<version>${derby-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${hsqldb-version}</version>
+ <scope>test</scope>
+ </dependency>
<!-- optional SNMP4J -->
<dependency>
[4/8] git commit: Remove the System.out in camel-sjms
Posted by ni...@apache.org.
Remove the System.out in camel-sjms
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f0fbc843
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f0fbc843
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f0fbc843
Branch: refs/heads/camel-2.13.x
Commit: f0fbc84300f9f316a16750a06c4b2c8ee0dc6b72
Parents: 2010c0a
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Mar 31 14:15:04 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Mar 31 14:19:53 2014 +0800
----------------------------------------------------------------------
.../camel/component/sjms/consumer/InOutConcurrentConsumerTest.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f0fbc843/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
index a364c8c..6ecbf51 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
@@ -91,7 +91,6 @@ public class InOutConcurrentConsumerTest extends JmsTestSupport {
Thread.sleep(1000);
exchange.getOut().setBody("Bye " + body);
exchange.getOut().setHeader("threadName", Thread.currentThread().getName());
- System.out.println("Thread ID : " + Thread.currentThread().getName());
}
});
}
[8/8] git commit: Remove the System.out in camel-sjms
Posted by ni...@apache.org.
Remove the System.out in camel-sjms
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/88b77a36
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/88b77a36
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/88b77a36
Branch: refs/heads/camel-2.12.x
Commit: 88b77a3635dcb935ad43ca369f6d3010f1afc78b
Parents: ab75ad3
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Mar 31 14:15:04 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Mar 31 14:21:09 2014 +0800
----------------------------------------------------------------------
.../camel/component/sjms/consumer/InOutConcurrentConsumerTest.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/88b77a36/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
index a364c8c..6ecbf51 100644
--- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
+++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java
@@ -91,7 +91,6 @@ public class InOutConcurrentConsumerTest extends JmsTestSupport {
Thread.sleep(1000);
exchange.getOut().setBody("Bye " + body);
exchange.getOut().setHeader("threadName", Thread.currentThread().getName());
- System.out.println("Thread ID : " + Thread.currentThread().getName());
}
});
}