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 2019/07/01 03:10:41 UTC
[camel] 03/03: unit test to validate column type
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 47bca8500d8e3b5eec6eb20a41acf6fbd6bae11b
Author: Otávio Prado <ot...@sensedia.com>
AuthorDate: Fri Jun 28 21:37:49 2019 -0300
unit test to validate column type
---
.../camel/component/jdbc/JdbcColumnTypeTest.java | 53 ++++++++++++++++++++++
.../camel-jdbc/src/test/resources/sql/init.sql | 5 +-
2 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcColumnTypeTest.java b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcColumnTypeTest.java
new file mode 100644
index 0000000..3f63e8a
--- /dev/null
+++ b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcColumnTypeTest.java
@@ -0,0 +1,53 @@
+package org.apache.camel.component.jdbc;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.logging.log4j.core.util.IOUtils;
+import org.junit.Test;
+
+public class JdbcColumnTypeTest extends AbstractJdbcTestSupport {
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testClobColumnType() throws SQLException {
+ Endpoint directHelloEndpoint = context.getEndpoint("direct:hello");
+ Exchange directHelloExchange = directHelloEndpoint.createExchange();
+
+ directHelloExchange.getIn().setBody("select * from tableWithClob");
+
+ Exchange out = template.send(directHelloEndpoint, directHelloExchange);
+ assertNotNull(out);
+ assertNotNull(out.getOut());
+
+ List<Map<String, Object>> returnValues = out.getOut().getBody(List.class);
+ assertNotNull(returnValues);
+ assertEquals(1, returnValues.size());
+ Map<String, Object> row = returnValues.get(0);
+ assertEquals("id1", row.get("ID"));
+ assertNotNull(row.get("PICTURE"));
+
+ Set<String> columnNames = (Set<String>) out.getOut().getHeader(JdbcConstants.JDBC_COLUMN_NAMES);
+ assertNotNull(columnNames);
+ assertEquals(2, columnNames.size());
+ assertTrue(columnNames.contains("ID"));
+ assertTrue(columnNames.contains("PICTURE"));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:hello").to("jdbc:testdb?readSize=100");
+ }
+ };
+ }
+}
diff --git a/components/camel-jdbc/src/test/resources/sql/init.sql b/components/camel-jdbc/src/test/resources/sql/init.sql
index 9e3a468..7ccf135 100644
--- a/components/camel-jdbc/src/test/resources/sql/init.sql
+++ b/components/camel-jdbc/src/test/resources/sql/init.sql
@@ -21,4 +21,7 @@ insert into customer values('cust2','nsandhu');
insert into customer values('cust3','willem');
create table tableWithAutoIncr (id int not null GENERATED ALWAYS AS IDENTITY, content varchar(10));
-insert into tableWithAutoIncr (content) values ('value1');
\ No newline at end of file
+insert into tableWithAutoIncr (content) values ('value1');
+
+create table tableWithClob (id varchar(15), picture clob(10M));
+insert into tableWithClob values ('id1', cast('\x0123456789ABCDEF' as clob));
\ No newline at end of file