camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r773471 - in /camel/trunk/components/camel-ibatis/src: main/java/org/apache/camel/component/ibatis/ test/java/org/apache/camel/component/ibatis/
Date Mon, 11 May 2009 05:22:31 GMT
Author: davsclaus
Date: Mon May 11 05:22:31 2009
New Revision: 773471

URL: http://svn.apache.org/viewvc?rev=773471&view=rev
Log:
CAMEL-1596: camel-ibatis: statementType is now mandatory to specify for ibatis producer as
the previous behavior was just to odd and to limited as you could not pass in arguments to
a SELECT query

Added:
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisUnknownStatementTypeTest.java
  (with props)
Modified:
    camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java
    camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
    camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueueTest.java
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteEmptyResultSetTest.java
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java

Modified: camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java?rev=773471&r1=773470&r2=773471&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java
(original)
+++ camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java
Mon May 11 05:22:31 2009
@@ -24,6 +24,7 @@
 import org.apache.camel.component.ibatis.strategy.DefaultIBatisProcessingStategy;
 import org.apache.camel.component.ibatis.strategy.IBatisProcessingStrategy;
 import org.apache.camel.impl.DefaultPollingEndpoint;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * An <a href="http://camel.apache.org/ibatis.html>iBatis Endpoint</a>
@@ -35,7 +36,7 @@
     private IBatisProcessingStrategy strategy;
     private boolean useTransactions;
     private String statement;
-    private StatementType statementType = StatementType.Default;
+    private StatementType statementType;
 
     public IBatisEndpoint() {
     }
@@ -56,6 +57,7 @@
     }
 
     public Producer createProducer() throws Exception {
+        ObjectHelper.notNull(statementType, "statementType", this);
         return new IBatisProducer(this);
     }
 

Modified: camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java?rev=773471&r1=773470&r2=773471&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
(original)
+++ camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
Mon May 11 05:22:31 2009
@@ -55,10 +55,8 @@
             doUpdate(exchange); break;
         case Delete:
             doDelete(exchange); break;
-        case Default:
-            doDefault(exchange); break;
         default:
-            doDefault(exchange); break;
+            throw new IllegalArgumentException("Unsupported statementType: " + endpoint.getStatementType());
         }
     }
 

Modified: camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java?rev=773471&r1=773470&r2=773471&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
(original)
+++ camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
Mon May 11 05:22:31 2009
@@ -18,13 +18,10 @@
 
 /**
  * Statement types to instruct which iBatis operation to use.
- * <p/>
- * Default will use the default Behavior in Camel: No body then <tt>QueryForList</tt>
is used, otherwise
- * <tt>Insert</tt> is used.
  *
  * @version $Revision$
  */
 public enum StatementType {
 
-    QueryForObject, QueryForList, Insert, Update, Delete, Default
+    QueryForObject, QueryForList, Insert, Update, Delete
 }

Modified: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java?rev=773471&r1=773470&r2=773471&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java
(original)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java
Mon May 11 05:22:31 2009
@@ -58,10 +58,10 @@
             public void configure() throws Exception {
                 // START SNIPPET: e1
                 // run this timer every 2nd second, that will select data from the database
and send it to the mock endpiont
-                from("timer://pollTheDatabase?delay=2000").to("ibatis:selectAllAccounts").to("mock:result");
+                from("timer://pollTheDatabase?delay=2000").to("ibatis:selectAllAccounts?statementType=QueryForList").to("mock:result");
                 // END SNIPPET: e1
 
-                from("direct:start").to("ibatis:insertAccount");
+                from("direct:start").to("ibatis:insertAccount?statementType=Insert");
             }
         };
     }

Modified: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueueTest.java?rev=773471&r1=773470&r2=773471&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueueTest.java
(original)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueueTest.java
Mon May 11 05:22:31 2009
@@ -50,7 +50,7 @@
         assertMockEndpointsSatisfied();
         
         // now lets poll that the account has been inserted
-        List body = template.requestBody("ibatis:selectProcessedAccounts", null, List.class);
+        List body = template.requestBody("ibatis:selectProcessedAccounts?statementType=QueryForList",
null, List.class);
 
         assertEquals("Wrong size: " + body, 2, body.size());
         Account actual = assertIsInstanceOf(Account.class, body.get(0));
@@ -58,7 +58,7 @@
         assertEquals("Account.getFirstName()", "Bob", actual.getFirstName());
         assertEquals("Account.getLastName()", "Denver", actual.getLastName());
 
-        body = template.requestBody("ibatis:selectUnprocessedAccounts", null, List.class);
+        body = template.requestBody("ibatis:selectUnprocessedAccounts?statementType=QueryForList",
null, List.class);
         assertEquals("Wrong size: " + body, 0, body.size());
     }
     
@@ -70,7 +70,7 @@
                 from("ibatis:selectUnprocessedAccounts?consumer.onConsume=consumeAccount").to("mock:results");
                 // END SNIPPET: e1
 
-                from("direct:start").to("ibatis:insertAccount");
+                from("direct:start").to("ibatis:insertAccount?statementType=Insert");
             }
         };
     }

Modified: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteEmptyResultSetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteEmptyResultSetTest.java?rev=773471&r1=773470&r2=773471&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteEmptyResultSetTest.java
(original)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteEmptyResultSetTest.java
Mon May 11 05:22:31 2009
@@ -45,7 +45,7 @@
             public void configure() throws Exception {
                 from("ibatis:selectAllAccounts?consumer.useIterator=false&consumer.routeEmptyResultSet=true").to("mock:results");
 
-                from("direct:start").to("ibatis:insertAccount");
+                from("direct:start").to("ibatis:insertAccount?statementType=Insert");
             }
         };
     }

Modified: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java?rev=773471&r1=773470&r2=773471&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java
(original)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java
Mon May 11 05:22:31 2009
@@ -44,7 +44,7 @@
         assertMockEndpointsSatisfied();
 
         // now lets poll that the account has been inserted
-        List body = template.requestBody("ibatis:selectAllAccounts", null, List.class);
+        List body = template.requestBody("ibatis:selectAllAccounts?statementType=QueryForList",
null, List.class);
 
         assertEquals("Wrong size: " + body, 1, body.size());
         Account actual = assertIsInstanceOf(Account.class, body.get(0));
@@ -60,9 +60,9 @@
         return new RouteBuilder() {
             public void configure() throws Exception {
                 //Delaying the query so we will not get the "java.sql.SQLException: Table
not found in statement" on the slower box
-                from("timer://pollTheDatabase?delay=2000").to("ibatis:selectAllAccounts").to("mock:results");
+                from("timer://pollTheDatabase?delay=2000").to("ibatis:selectAllAccounts?statementType=QueryForList").to("mock:results");
 
-                from("direct:start").to("ibatis:insertAccount");
+                from("direct:start").to("ibatis:insertAccount?statementType=Insert");
             }
         };
     }

Modified: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java?rev=773471&r1=773470&r2=773471&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java
(original)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java
Mon May 11 05:22:31 2009
@@ -38,7 +38,7 @@
         account.setFirstName("James");
         account.setLastName("Strachan");
         account.setEmailAddress("TryGuessing@gmail.com");
-        template.sendBody("ibatis:insertAccount", account);
+        template.sendBody("ibatis:insertAccount?statementType=Insert", account);
 
         account = new Account();
         account.setId(456);
@@ -46,7 +46,7 @@
         account.setLastName("Ibsen");
         account.setEmailAddress("Noname@gmail.com");
 
-        template.sendBody("ibatis:insertAccount", account);
+        template.sendBody("ibatis:insertAccount?statementType=Insert", account);
     }
 
     @Override

Added: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisUnknownStatementTypeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisUnknownStatementTypeTest.java?rev=773471&view=auto
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisUnknownStatementTypeTest.java
(added)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisUnknownStatementTypeTest.java
Mon May 11 05:22:31 2009
@@ -0,0 +1,40 @@
+/**
+ * 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.ibatis;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class IBatisUnknownStatementTypeTest extends ContextTestSupport {
+
+    public void testStatementTypeNotSet() throws Exception {
+        try {
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("direct:start").to("ibatis:selectAllAccounts");
+                }
+            });
+            fail("Should have thrown an IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            assertEquals("statementType must be specified on: Endpoint[ibatis:selectAllAccounts]",
e.getMessage());
+        }
+    }
+}

Propchange: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisUnknownStatementTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisUnknownStatementTypeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message