camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r773474 - in /camel/branches/camel-1.x/components/camel-ibatis/src: main/java/org/apache/camel/component/ibatis/ test/java/org/apache/camel/component/ibatis/ test/resources/ test/resources/org/apache/camel/component/ibatis/
Date Mon, 11 May 2009 05:50:01 GMT
Author: davsclaus
Date: Mon May 11 05:50:01 2009
New Revision: 773474

URL: http://svn.apache.org/viewvc?rev=773474&view=rev
Log:
CAMEL-1596: camel-ibatis. Introduced statementType option to specify which SqlMapClient operation
to invoke. Allowing you to have fine grained control of using ibatis. And camel-ibatis is
much more like camel-sql or camel-jdbc.

Added:
    camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
  (with props)
    camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForDeleteTest.java
      - copied, changed from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForDeleteTest.java
    camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForInsertTest.java
      - copied, changed from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForInsertTest.java
    camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListTest.java
      - copied unchanged from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListTest.java
    camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListWithSplitTest.java
      - copied, changed from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListWithSplitTest.java
    camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForObjectTest.java
      - copied unchanged from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForObjectTest.java
    camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForUpdateTest.java
      - copied, changed from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForUpdateTest.java
    camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java
      - copied, changed from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java
Modified:
    camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java
    camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java
    camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
    camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java
    camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java
    camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/log4j.properties
    camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/org/apache/camel/component/ibatis/Account.xml

Modified: camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java?rev=773474&r1=773473&r2=773474&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java
Mon May 11 05:50:01 2009
@@ -78,7 +78,9 @@
     // Implementation methods
     //-------------------------------------------------------------------------
     protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws
Exception {
-        return new IBatisEndpoint(uri, this, remaining);
+        IBatisEndpoint answer = new IBatisEndpoint(uri, this, remaining);
+        setProperties(answer, parameters);
+        return answer;
     }
 
     protected SqlMapClient createSqlMapClient() throws IOException {

Modified: camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java?rev=773474&r1=773473&r2=773474&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisEndpoint.java
Mon May 11 05:50:01 2009
@@ -21,11 +21,11 @@
 import java.util.List;
 
 import com.ibatis.sqlmap.client.SqlMapClient;
-
 import org.apache.camel.Message;
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultPollingEndpoint;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * An <a href="http://activemq.apache.org/camel/ibatis.html>iBatis Endpoint</a>
@@ -35,6 +35,7 @@
  */
 public class IBatisEndpoint extends DefaultPollingEndpoint {
     private final String entityName;
+    private StatementType statementType;
 
     public IBatisEndpoint(String endpointUri, IBatisComponent component, String entityName)
{
         super(endpointUri, component);
@@ -56,6 +57,7 @@
     }
 
     public Producer createProducer() throws Exception {
+        ObjectHelper.notNull(statementType, "statementType", this);
         return new IBatisProducer(this);
     }
 
@@ -80,6 +82,13 @@
         List list = getSqlClient().queryForList(name);
         message.setBody(list);
         message.setHeader("org.apache.camel.ibatis.queryName", name);
+    }
+
+    public StatementType getStatementType() {
+        return statementType;
+    }
 
+    public void setStatementType(StatementType statementType) {
+        this.statementType = statementType;
     }
 }

Modified: camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java?rev=773474&r1=773473&r2=773474&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
Mon May 11 05:50:01 2009
@@ -18,19 +18,26 @@
 
 import java.util.Iterator;
 
+import com.ibatis.sqlmap.client.SqlMapClient;
 import org.apache.camel.Exchange;
+import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * @version $Revision$
  */
 public class IBatisProducer extends DefaultProducer {
+    private static final Log LOG = LogFactory.getLog(IBatisProducer.class);
+    private String statement;
     private final IBatisEndpoint endpoint;
 
     public IBatisProducer(IBatisEndpoint endpoint) {
         super(endpoint);
         this.endpoint = endpoint;
+        this.statement = endpoint.getEntityName();
     }
 
     @Override
@@ -39,25 +46,141 @@
     }
 
     public void process(Exchange exchange) throws Exception {
-        Object body = exchange.getIn().getBody();
-        if (body == null) {
-            // must be a poll so lets do a query
-            endpoint.query(exchange.getOut(true));
+        switch (endpoint.getStatementType()) {
+        case QueryForObject:
+            doQueryForObject(exchange); break;
+        case QueryForList:
+            doQueryForList(exchange); break;
+        case Insert:
+            doInsert(exchange); break;
+        case Update:
+            doUpdate(exchange); break;
+        case Delete:
+            doDelete(exchange); break;
+        default:
+            throw new IllegalArgumentException("Unsupported statementType: " + endpoint.getStatementType());
+        }
+    }
+
+    private void doQueryForObject(Exchange exchange) throws Exception {
+        SqlMapClient client = endpoint.getSqlClient();
+
+        Object result;
+        Object in = exchange.getIn().getBody();
+        if (in != null) {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("QueryForObject: " + in + "  using statement: " + statement);
+            }
+            result = client.queryForObject(statement, in);
+        } else {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("QueryForObject using statement: " + statement);
+            }
+            result = client.queryForObject(statement);
+        }
+
+        doProcessResult(exchange, result);
+    }
+
+    private void doQueryForList(Exchange exchange) throws Exception {
+        SqlMapClient client = endpoint.getSqlClient();
+
+        Object result;
+        Object in = exchange.getIn().getBody();
+        if (in != null) {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("QueryForList: " + in + "  using statement: " + statement);
+            }
+            result = client.queryForList(statement, in);
         } else {
-            String operation = getOperationName(exchange);
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("QueryForList using statement: " + statement);
+            }
+            result = client.queryForList(statement);
+        }
 
+        doProcessResult(exchange, result);
+    }
+
+    private void doInsert(Exchange exchange) throws Exception {
+        SqlMapClient client = endpoint.getSqlClient();
+
+        Object result;
+        Object in = exchange.getIn().getBody();
+        if (in != null) {
             // lets handle arrays or collections of objects
-            Iterator iter = ObjectHelper.createIterator(body);
+            Iterator iter = ObjectHelper.createIterator(in);
             while (iter.hasNext()) {
-                endpoint.getSqlClient().insert(operation, iter.next());
+                Object value = iter.next();
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("Inserting: " + value + " using statement: " + statement);
+                }
+                result = client.insert(statement, value);
+                doProcessResult(exchange, result);
+            }
+        } else {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Inserting using statement: " + statement);
             }
+            result = client.insert(statement);
+            doProcessResult(exchange, result);
         }
     }
 
-    /**
-     * Returns the iBatis insert operation name
-     */
-    protected String getOperationName(Exchange exchange) {
-        return endpoint.getEntityName();
+    private void doUpdate(Exchange exchange) throws Exception {
+        SqlMapClient client = endpoint.getSqlClient();
+
+        Object result;
+        Object in = exchange.getIn().getBody();
+        if (in != null) {
+            // lets handle arrays or collections of objects
+            Iterator iter = ObjectHelper.createIterator(in);
+            while (iter.hasNext()) {
+                Object value = iter.next();
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("Updating: " + value + " using statement: " + statement);
+                }
+                result = client.update(statement, value);
+                doProcessResult(exchange, result);
+            }
+        } else {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Updating using statement: " + statement);
+            }
+            result = client.update(statement);
+            doProcessResult(exchange, result);
+        }
     }
+
+    private void doDelete(Exchange exchange) throws Exception {
+        SqlMapClient client = endpoint.getSqlClient();
+
+        Object result;
+        Object in = exchange.getIn().getBody();
+        if (in != null) {
+            // lets handle arrays or collections of objects
+            Iterator iter = ObjectHelper.createIterator(in);
+            while (iter.hasNext()) {
+                Object value = iter.next();
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("Deleting: " + value + " using statement: " + statement);
+                }
+                result = client.delete(statement, value);
+                doProcessResult(exchange, result);
+            }
+        } else {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Deleting using statement: " + statement);
+            }
+            result = client.delete(statement);
+            doProcessResult(exchange, result);
+        }
+    }
+
+    private void doProcessResult(Exchange exchange, Object result) {
+        Message msg = exchange.getOut();
+        msg.setBody(result);
+        msg.setHeader("org.apache.camel.ibatis.queryName", statement);
+    }
+
 }

Added: camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java?rev=773474&view=auto
==============================================================================
--- camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
(added)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
Mon May 11 05:50:01 2009
@@ -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.
+ */
+package org.apache.camel.component.ibatis;
+
+/**
+ * Statement types to instruct which iBatis operation to use.
+ *
+ * @version $Revision$
+ */
+public enum StatementType {
+
+    QueryForObject, QueryForList, Insert, Update, Delete
+}

Propchange: camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/StatementType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java?rev=773474&r1=773473&r2=773474&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisPollingDelayRouteTest.java
Mon May 11 05:50:01 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");
             }
         };
     }

Copied: camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForDeleteTest.java
(from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForDeleteTest.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForDeleteTest.java?p2=camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForDeleteTest.java&p1=camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForDeleteTest.java&r1=773359&r2=773474&rev=773474&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForDeleteTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForDeleteTest.java
Mon May 11 05:50:01 2009
@@ -33,13 +33,13 @@
         assertMockEndpointsSatisfied();
 
         // there should be 1 rows now
-        Integer rows = template.requestBody("ibatis:count?statementType=QueryForObject",
null, Integer.class);
+        Integer rows = (Integer) template.requestBody("ibatis:count?statementType=QueryForObject",
null);
         assertEquals("There should be 1 rows", 1, rows.intValue());
 
         template.sendBody("direct:start", 123);
 
         // there should be 0 rows now
-        rows = template.requestBody("ibatis:count?statementType=QueryForObject", null, Integer.class);
+        rows = (Integer) template.requestBody("ibatis:count?statementType=QueryForObject",
null);
         assertEquals("There should be 0 rows", 0, rows.intValue());
     }
 
@@ -52,7 +52,7 @@
         assertMockEndpointsSatisfied();
 
         // there should be 2 rows now
-        Integer rows = template.requestBody("ibatis:count?statementType=QueryForObject",
null, Integer.class);
+        Integer rows = (Integer) template.requestBody("ibatis:count?statementType=QueryForObject",
null);
         assertEquals("There should be 2 rows", 2, rows.intValue());
     }
 

Copied: camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForInsertTest.java
(from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForInsertTest.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForInsertTest.java?p2=camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForInsertTest.java&p1=camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForInsertTest.java&r1=773359&r2=773474&rev=773474&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForInsertTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForInsertTest.java
Mon May 11 05:50:01 2009
@@ -39,7 +39,7 @@
         assertMockEndpointsSatisfied();
 
         // there should be 3 rows now
-        Integer rows = template.requestBody("ibatis:count?statementType=QueryForObject",
null, Integer.class);
+        Integer rows = (Integer) template.requestBody("ibatis:count?statementType=QueryForObject",
null);
         assertEquals("There should be 3 rows", 3, rows.intValue());
     }
 

Copied: camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListWithSplitTest.java
(from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListWithSplitTest.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListWithSplitTest.java?p2=camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListWithSplitTest.java&p1=camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListWithSplitTest.java&r1=773359&r2=773474&rev=773474&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListWithSplitTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForListWithSplitTest.java
Mon May 11 05:50:01 2009
@@ -47,7 +47,7 @@
                 from("direct:start")
                     .to("ibatis:selectAllAccounts?statementType=QueryForList")
                     // just use split body to split the List into individual objects
-                    .split(body())
+                    .splitter(body())
                     .to("mock:result");
                 // END SNIPPET: e1
             }

Copied: camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForUpdateTest.java
(from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForUpdateTest.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForUpdateTest.java?p2=camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForUpdateTest.java&p1=camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForUpdateTest.java&r1=773359&r2=773474&rev=773474&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForUpdateTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisQueryForUpdateTest.java
Mon May 11 05:50:01 2009
@@ -39,10 +39,10 @@
         assertMockEndpointsSatisfied();
 
         // there should be 2 rows now
-        Integer rows = template.requestBody("ibatis:count?statementType=QueryForObject",
null, Integer.class);
+        Integer rows = (Integer) template.requestBody("ibatis:count?statementType=QueryForObject",
null);
         assertEquals("There should be 2 rows", 2, rows.intValue());
 
-        Account claus = template.requestBody("ibatis:selectAccountById?statementType=QueryForObject",
456, Account.class);
+        Account claus = (Account) template.requestBody("ibatis:selectAccountById?statementType=QueryForObject",
456);
         assertEquals("Claus", claus.getFirstName());
         assertEquals("Jensen", claus.getLastName());
         assertEquals("Other@gmail.com", claus.getEmailAddress());

Modified: camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java?rev=773474&r1=773473&r2=773474&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisRouteTest.java
Mon May 11 05:50:01 2009
@@ -44,7 +44,7 @@
         assertMockEndpointsSatisfied();
 
         // now lets poll that the account has been inserted
-        Object answer = template.sendBody("ibatis:selectAllAccounts", null);
+        Object answer = template.sendBody("ibatis:selectAllAccounts??statementType=QueryForList",
null);
         List body = assertIsInstanceOf(List.class, answer);
 
         assertEquals("Wrong size: " + body, 1, body.size());
@@ -61,9 +61,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");
             }
         };
     }

Copied: camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java
(from r773359, camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java?p2=camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java&p1=camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java&r1=773359&r2=773474&rev=773474&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisTestSupport.java
Mon May 11 05:50:01 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
@@ -61,6 +61,6 @@
 
     private Connection createConnection() throws Exception {
         IBatisEndpoint endpoint = resolveMandatoryEndpoint("ibatis:Account", IBatisEndpoint.class);
-        return endpoint.getSqlMapClient().getDataSource().getConnection();
+        return endpoint.getSqlClient().getDataSource().getConnection();
     }
 }
\ No newline at end of file

Modified: camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/log4j.properties?rev=773474&r1=773473&r2=773474&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/log4j.properties (original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/log4j.properties Mon
May 11 05:50:01 2009
@@ -18,10 +18,11 @@
 #
 # The logging properties used for eclipse testing, We want to see debug output on the console.
 #
-log4j.rootLogger=INFO, out
+log4j.rootLogger=INFO, file
 
 # uncomment the following to enable debug of Camel
-log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.com.ibatis=DEBUG
 
 #log4j.logger.org.apache.activemq=DEBUG
 
@@ -32,8 +33,8 @@
 #log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
 
 # File appender
-log4j.appender.out=org.apache.log4j.FileAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-log4j.appender.out.file=target/camel-ibatis-test.log
-log4j.appender.out.append=true
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.file.file=target/camel-ibatis-test.log
+log4j.appender.file.append=true

Modified: camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/org/apache/camel/component/ibatis/Account.xml
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/org/apache/camel/component/ibatis/Account.xml?rev=773474&r1=773473&r2=773474&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/org/apache/camel/component/ibatis/Account.xml
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/test/resources/org/apache/camel/component/ibatis/Account.xml
Mon May 11 05:50:01 2009
@@ -37,7 +37,7 @@
 
   <!-- Select with no parameters using the result map for Account class. -->
   <select id="selectAllAccounts" resultMap="AccountResult">
-    select * from ACCOUNT
+    select * from ACCOUNT order by ACC_ID
   </select>
 
   <!-- A simpler select example without the result map.  Note the
@@ -80,4 +80,8 @@
     delete from ACCOUNT where ACC_ID = #id#
   </delete>
 
+  <select id="count" resultClass="int">
+       select count(*) from ACCOUNT
+  </select>
+
 </sqlMap>
\ No newline at end of file



Mime
View raw message