camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [7/9] camel git commit: CAMEL-4725: Polished
Date Sat, 09 Jan 2016 10:44:50 GMT
CAMEL-4725: Polished


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

Branch: refs/heads/master
Commit: b240b3e4a2eb64ad760cace92ea2ca326e58a15b
Parents: 0dcd69a
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Jan 9 11:21:26 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Jan 9 11:21:26 2016 +0100

----------------------------------------------------------------------
 .../sql/stored/SqlStoredComponent.java          |  7 +--
 .../TemplateStoredProcedureFactory.java         |  4 +-
 .../sql/stored/template/ast/ParseHelper.java    | 58 ++++++++++----------
 .../template/ast/ParseRuntimeException.java     | 16 ++++++
 .../camel/component/sql/stored/ParserTest.java  | 16 +++---
 .../sql/stored/TemplateStoredProcedureTest.java |  4 +-
 .../sql/stored/TestStoredProcedure.java         |  5 +-
 7 files changed, 65 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b240b3e4/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/SqlStoredComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/SqlStoredComponent.java
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/SqlStoredComponent.java
index 4814be9..7012186 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/SqlStoredComponent.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/SqlStoredComponent.java
@@ -16,16 +16,15 @@
  */
 package org.apache.camel.component.sql.stored;
 
+import java.util.Map;
+import javax.sql.DataSource;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
-import org.apache.camel.component.sql.stored.template.TemplateStoredProcedureFactory;
 import org.apache.camel.impl.UriEndpointComponent;
 import org.apache.camel.util.CamelContextHelper;
 import org.springframework.jdbc.core.JdbcTemplate;
 
-import javax.sql.DataSource;
-import java.util.Map;
-
 public class SqlStoredComponent extends UriEndpointComponent {
 
     private DataSource dataSource;

http://git-wip-us.apache.org/repos/asf/camel/blob/b240b3e4/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/TemplateStoredProcedureFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/TemplateStoredProcedureFactory.java
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/TemplateStoredProcedureFactory.java
index 78f034e..5d5a329 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/TemplateStoredProcedureFactory.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/TemplateStoredProcedureFactory.java
@@ -27,9 +27,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
 
 public class TemplateStoredProcedureFactory {
 
-    private final int TEMPLATE_CACHE_DEFAULT_SIZE = 200;
+    public static final int TEMPLATE_CACHE_DEFAULT_SIZE = 200;
     private final JdbcTemplate jdbcTemplate;
-    private LRUCache<String, TemplateStoredProcedure> templateCache = new LRUCache<String,
TemplateStoredProcedure>(200);
+    private LRUCache<String, TemplateStoredProcedure> templateCache = new LRUCache<String,
TemplateStoredProcedure>(TEMPLATE_CACHE_DEFAULT_SIZE);
 
     public TemplateStoredProcedureFactory(JdbcTemplate jdbcTemplate) {
         this.jdbcTemplate = jdbcTemplate;

http://git-wip-us.apache.org/repos/asf/camel/blob/b240b3e4/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseHelper.java
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseHelper.java
index 8e88691..19417de 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseHelper.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseHelper.java
@@ -5,9 +5,9 @@
  * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
+ *
+ *      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.
@@ -23,7 +23,10 @@ import java.sql.Types;
 
 import org.springframework.util.ReflectionUtils;
 
-public class ParseHelper {
+public final class ParseHelper {
+
+    private ParseHelper() {
+    }
 
     public static int parseSqlType(String sqlType) {
         Field field = ReflectionUtils.findField(Types.class, sqlType);
@@ -42,32 +45,31 @@ public class ParseHelper {
         //TODO: add test for each type.
         Class ret = null;
         switch (sqlType) {
-            case Types.INTEGER:
-                ret = Integer.class;
-                break;
-            case Types.VARCHAR:
-                ret = String.class;
-                break;
-            case Types.BIGINT:
-                ret = BigInteger.class;
-                break;
-            case Types.CHAR:
-                ret = String.class;
-                break;
-            case Types.BOOLEAN:
-                ret = Boolean.class;
-                break;
-            case Types.DATE:
-                ret = Date.class;
-                break;
-            case Types.TIMESTAMP:
-                ret = Date.class;
-                break;
-        }
-
-        if (ret == null) {
+        case Types.INTEGER:
+            ret = Integer.class;
+            break;
+        case Types.VARCHAR:
+            ret = String.class;
+            break;
+        case Types.BIGINT:
+            ret = BigInteger.class;
+            break;
+        case Types.CHAR:
+            ret = String.class;
+            break;
+        case Types.BOOLEAN:
+            ret = Boolean.class;
+            break;
+        case Types.DATE:
+            ret = Date.class;
+            break;
+        case Types.TIMESTAMP:
+            ret = Date.class;
+            break;
+        default:
             throw new ParseRuntimeException("Unable to map SQL type " + sqlTypeStr + " to
Java type");
         }
+
         return ret;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b240b3e4/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseRuntimeException.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseRuntimeException.java
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseRuntimeException.java
index 80fe52c..2092afa 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseRuntimeException.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/ParseRuntimeException.java
@@ -1,3 +1,19 @@
+/**
+ * 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.stored.template.ast;
 
 public class ParseRuntimeException extends RuntimeException {

http://git-wip-us.apache.org/repos/asf/camel/blob/b240b3e4/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ParserTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ParserTest.java
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ParserTest.java
index 1141886..36ccc76 100644
--- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ParserTest.java
+++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ParserTest.java
@@ -35,8 +35,8 @@ public class ParserTest extends CamelTestSupport {
 
     @Test
     public void shouldParseOk() {
-        Template template = parser.parseTemplate("addnumbers(INTEGER ${header.header1},"
+
-                "VARCHAR ${property.property1},BIGINT ${header.header2},OUT INTEGER header1)");
+        Template template = parser.parseTemplate("addnumbers(INTEGER ${header.header1},"
+                + "VARCHAR ${property.property1},BIGINT ${header.header2},OUT INTEGER header1)");
 
         Assert.assertEquals("addnumbers", template.getProcedureName());
         Assert.assertEquals(3, template.getInputParameterList().size());
@@ -69,21 +69,21 @@ public class ParserTest extends CamelTestSupport {
 
     @Test(expected = ParseRuntimeException.class)
     public void noOutputParameterShouldFail() {
-        parser.parseTemplate("ADDNUMBERS2" +
-                "(INTEGER VALUE1 ${header.v1},INTEGER VALUE2 ${header.v2})");
+        parser.parseTemplate("ADDNUMBERS2"
+                + "(INTEGER VALUE1 ${header.v1},INTEGER VALUE2 ${header.v2})");
 
     }
 
     @Test(expected = ParseRuntimeException.class)
     public void unexistingTypeShouldFail() {
-        parser.parseTemplate("ADDNUMBERS2" +
-                "(XML VALUE1 ${header.v1},OUT INTEGER VALUE2 ${header.v2})");
+        parser.parseTemplate("ADDNUMBERS2"
+                + "(XML VALUE1 ${header.v1},OUT INTEGER VALUE2 ${header.v2})");
     }
 
     @Test(expected = ParseRuntimeException.class)
     public void unmappedTypeShouldFaild() {
-        parser.parseTemplate("ADDNUMBERS2" +
-                "(OTHER VALUE1 ${header.v1},INTEGER VALUE2 ${header.v2})");
+        parser.parseTemplate("ADDNUMBERS2"
+                + "(OTHER VALUE1 ${header.v1},INTEGER VALUE2 ${header.v2})");
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b240b3e4/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TemplateStoredProcedureTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TemplateStoredProcedureTest.java
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TemplateStoredProcedureTest.java
index f92f7df..f538ce5 100644
--- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TemplateStoredProcedureTest.java
+++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TemplateStoredProcedureTest.java
@@ -47,8 +47,8 @@ public class TemplateStoredProcedureTest extends CamelTestSupport {
 
     @Test
     public void shouldExecuteStoredProcedure() {
-        TemplateStoredProcedure sp = new TemplateStoredProcedure(jdbcTemplate, parser.parseTemplate("ADDNUMBERS"
+
-                "(INTEGER ${header.v1},INTEGER ${header.v2},OUT INTEGER resultofsum)"));
+        TemplateStoredProcedure sp = new TemplateStoredProcedure(jdbcTemplate, parser.parseTemplate("ADDNUMBERS"
+                + "(INTEGER ${header.v1},INTEGER ${header.v2},OUT INTEGER resultofsum)"));
 
         Exchange exchange = createExchangeWithBody(null);
         exchange.getIn().setHeader("v1", 1);

http://git-wip-us.apache.org/repos/asf/camel/blob/b240b3e4/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TestStoredProcedure.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TestStoredProcedure.java
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TestStoredProcedure.java
index cf05611..55e2624 100644
--- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TestStoredProcedure.java
+++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/TestStoredProcedure.java
@@ -19,10 +19,13 @@ package org.apache.camel.component.sql.stored;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TestStoredProcedure {
+public final class TestStoredProcedure {
 
     private static final Logger LOG = LoggerFactory.getLogger(TestStoredProcedure.class);
 
+    private TestStoredProcedure() {
+    }
+
     public static void addnumbers(int val1, int val2, int[] ret) {
         LOG.info("calling addnumbers:{} + {}", val1, val2);
         ret[0] = val1 + val2;


Mime
View raw message