camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1070800 - in /camel/trunk/components/camel-ibatis/src: main/java/org/apache/camel/component/ibatis/ main/java/org/apache/camel/component/ibatis/strategy/ test/java/org/apache/camel/component/ibatis/
Date Tue, 15 Feb 2011 08:09:37 GMT
Author: davsclaus
Date: Tue Feb 15 08:09:36 2011
New Revision: 1070800

URL: http://svn.apache.org/viewvc?rev=1070800&view=rev
Log:
Polished ibatis and renamed the consumer as its not a polling consumer EIP.

Added:
    camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisConsumer.java
  (contents, props changed)
      - copied, changed from r1070784, camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisPollingConsumer.java
Removed:
    camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisPollingConsumer.java
Modified:
    camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java
    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/strategy/DefaultIBatisProcessingStategy.java
    camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/strategy/IBatisProcessingStrategy.java
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisBatchConsumerTest.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/IBatisRouteEmptyResultSetTest.java
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownAllTasksTest.java
    camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownCurrentTaskOnlyTest.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/IBatisComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java?rev=1070800&r1=1070799&r2=1070800&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java
(original)
+++ camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisComponent.java
Tue Feb 15 08:09:36 2011
@@ -24,8 +24,6 @@ import java.util.Map;
 import com.ibatis.sqlmap.client.SqlMapClient;
 import com.ibatis.sqlmap.client.SqlMapClientBuilder;
 import org.apache.camel.component.ResourceBasedComponent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.core.io.Resource;
 
 /**
@@ -48,7 +46,7 @@ import org.springframework.core.io.Resou
  *
  * Using Ibatis as a source of data (<from>) you can use this component
  * to treat a database table as a logical queue.
- * Details are available in the {@link IBatisPollingConsumer}
+ * Details are available in the {@link IBatisConsumer}
  *
  * Using Ibatis as a destination for data (<to>) you can use this
  * component to run an insert statement either on a single message or if the
@@ -58,7 +56,7 @@ import org.springframework.core.io.Resou
  * </pre>
  *
  * @see IBatisProducer
- * @see IBatisPollingConsumer
+ * @see IBatisConsumer
  */
 public class IBatisComponent extends ResourceBasedComponent {
     private static final String DEFAULT_CONFIG_URI = "classpath:SqlMapConfig.xml";

Copied: camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisConsumer.java
(from r1070784, camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisPollingConsumer.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisConsumer.java?p2=camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisConsumer.java&p1=camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisPollingConsumer.java&r1=1070784&r2=1070800&rev=1070800&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisPollingConsumer.java
(original)
+++ camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisConsumer.java
Tue Feb 15 08:09:36 2011
@@ -34,73 +34,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * <pre>
- *  Ibatis Camel Component used to read data from a database.
- * 
- *  Example Configuration :
- *  &lt;route&gt;
- *   &lt;from uri=&quot;ibatis:selectRecords&quot; /&gt;
- *   &lt;to uri=&quot;jms:destinationQueue&quot; /&gt;
- *  &lt;/route&gt;
- * 
- * 
- *  This also can be configured to treat a table as a logical queue by defining
- *  an &quot;onConsume&quot; statement.
- * 
- *  Example Configuration :
- *  &lt;route&gt;
- *   &lt;from uri=&quot;ibatis:selectRecords?consumer.onConsume=updateRecord&quot;
/&gt;
- *   &lt;to uri=&quot;jms:destinationQueue&quot; /&gt;
- *  &lt;/route&gt;
- * 
- *  By default, if the select statement contains multiple rows, it will
- *  iterate over the set and deliver each row to the route.  If this is not the
- *  desired behavior then set &quot;useIterator=false&quot;.  This will deliver the
entire
- *  set to the route as a list.
- * </pre>
- *
- * <b>URI Options</b>
- * <table border="1">
- * <thead>
- * <th>Name</th>
- * <th>Default Value</th>
- * <th>description</th>
- * </thead>
- * <tbody>
- * <tr>
- * <td>initialDelay</td>
- * <td>1000 ms</td>
- * <td>time before polling starts</td>
- * </tr>
- * <tr>
- * <td>delay</td>
- * <td>500 ms</td>
- * <td>time before the next poll</td>
- * </tr>
- * <tr>
- * <td>timeUnit</td>
- * <td>MILLISECONDS</td>
- * <td>Time unit to use for delay properties (NANOSECONDS, MICROSECONDS,
- * MILLISECONDS, SECONDS)</td>
- * </tr>
- * <tr>
- * <td>useIterator</td>
- * <td>true</td>
- * <td>If true, processes one exchange per row. If false processes one exchange
- * for all rows</td>
- * </tr>
- * <tr>
- * <td>onConsume</td>
- * <td>null</td>
- * <td>statement to run after data has been processed</td>
- * </tr>
- * <tbody> </table>
+ * Consumer to read data from databaase.
  *
  * @see org.apache.camel.component.ibatis.strategy.IBatisProcessingStrategy
  */
-public class IBatisPollingConsumer extends ScheduledPollConsumer implements BatchConsumer,
ShutdownAware {
+public class IBatisConsumer extends ScheduledPollConsumer implements BatchConsumer, ShutdownAware
{
 
-    private static final Logger LOG = LoggerFactory.getLogger(IBatisPollingConsumer.class);
+    private static final Logger LOG = LoggerFactory.getLogger(IBatisConsumer.class);
 
     private final class DataHolder {
         private Exchange exchange;
@@ -130,7 +70,7 @@ public class IBatisPollingConsumer exten
     private int maxMessagesPerPoll;
     
 
-    public IBatisPollingConsumer(IBatisEndpoint endpoint, Processor processor) throws Exception
{
+    public IBatisConsumer(IBatisEndpoint endpoint, Processor processor) throws Exception
{
         super(endpoint, processor);
     }
 

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

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

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=1070800&r1=1070799&r2=1070800&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
Tue Feb 15 08:09:36 2011
@@ -63,8 +63,8 @@ public class IBatisEndpoint extends Defa
     }
 
     @Override
-    public IBatisPollingConsumer createConsumer(Processor processor) throws Exception {
-        IBatisPollingConsumer consumer = new IBatisPollingConsumer(this, processor);
+    public IBatisConsumer createConsumer(Processor processor) throws Exception {
+        IBatisConsumer consumer = new IBatisConsumer(this, processor);
         consumer.setMaxMessagesPerPoll(getMaxMessagesPerPoll());
         configureConsumer(consumer);
         return consumer;

Modified: camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/strategy/DefaultIBatisProcessingStategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/strategy/DefaultIBatisProcessingStategy.java?rev=1070800&r1=1070799&r2=1070800&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/strategy/DefaultIBatisProcessingStategy.java
(original)
+++ camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/strategy/DefaultIBatisProcessingStategy.java
Tue Feb 15 08:09:36 2011
@@ -20,10 +20,9 @@ import java.sql.Connection;
 import java.util.List;
 
 import com.ibatis.sqlmap.client.SqlMapClient;
-
 import org.apache.camel.Exchange;
+import org.apache.camel.component.ibatis.IBatisConsumer;
 import org.apache.camel.component.ibatis.IBatisEndpoint;
-import org.apache.camel.component.ibatis.IBatisPollingConsumer;
 
 /**
  * Default strategy for consuming messages for a route
@@ -51,7 +50,7 @@ public class DefaultIBatisProcessingStat
         }
     }
 
-    public List poll(IBatisPollingConsumer consumer, IBatisEndpoint endpoint) throws Exception
{
+    public List poll(IBatisConsumer consumer, IBatisEndpoint endpoint) throws Exception {
         SqlMapClient client = endpoint.getSqlMapClient();
         return client.queryForList(endpoint.getStatement(), null);
     }

Modified: camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/strategy/IBatisProcessingStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/strategy/IBatisProcessingStrategy.java?rev=1070800&r1=1070799&r2=1070800&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/strategy/IBatisProcessingStrategy.java
(original)
+++ camel/trunk/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/strategy/IBatisProcessingStrategy.java
Tue Feb 15 08:09:36 2011
@@ -19,30 +19,30 @@ package org.apache.camel.component.ibati
 import java.util.List;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.component.ibatis.IBatisConsumer;
 import org.apache.camel.component.ibatis.IBatisEndpoint;
-import org.apache.camel.component.ibatis.IBatisPollingConsumer;
 
 /**
- * Processing strategy for dealing with IBatis.
+ * Processing strategy for dealing with IBatis when consuming.
  */
 public interface IBatisProcessingStrategy {
 
     /**
      * Called when record is being queried.
-     * 
-     * @param consumer The Ibatis Polling Consumer
-     * @param endpoint The Ibatis Endpoint
-     * @return Results of the query as a java.util.List
+     *
+     * @param consumer the consumer
+     * @param endpoint the endpoint
+     * @return Results of the query as a {@link List}
      * @throws Exception can be thrown in case of error
      */
-    List poll(IBatisPollingConsumer consumer, IBatisEndpoint endpoint) throws Exception;
+    List poll(IBatisConsumer consumer, IBatisEndpoint endpoint) throws Exception;
 
     /**
      * Commit callback if there are a statements to be run after processing.
-     * 
-     * @param endpoint The Ibatis Enpoint
-     * @param exchange The exchange after it has been processed
-     * @param data The original data delivered to the route
+     *
+     * @param endpoint          the endpoint
+     * @param exchange          The exchange after it has been processed
+     * @param data              The original data delivered to the route
      * @param consumeStatements Name of the statement(s) to run, will use SQL update. Use
comma to provide multiple statements to run.
      * @throws Exception can be thrown in case of error
      */

Modified: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisBatchConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisBatchConsumerTest.java?rev=1070800&r1=1070799&r2=1070800&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisBatchConsumerTest.java
(original)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisBatchConsumerTest.java
Tue Feb 15 08:09:36 2011
@@ -44,8 +44,7 @@ public class IBatisBatchConsumerTest ext
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("ibatis:selectAllAccounts?statementType=QueryForList")
-                        .to("mock:result");
+                from("ibatis:selectAllAccounts").to("mock:result");
             }
         };
     }

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=1070800&r1=1070799&r2=1070800&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
Tue Feb 15 08:09:36 2011
@@ -16,25 +16,17 @@
  */
 package org.apache.camel.component.ibatis;
 
-import java.sql.Connection;
-import java.sql.Statement;
-
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class IBatisPollingDelayRouteTest extends CamelTestSupport {
+public class IBatisPollingDelayRouteTest extends IBatisTestSupport {
 
     @Test
     public void testSendAccountBean() throws Exception {
-        createTestData();
-
         long start = System.currentTimeMillis();
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(2);
@@ -45,56 +37,16 @@ public class IBatisPollingDelayRouteTest
         assertTrue("Should not take that long: " + delta, delta < 7000);
     }
 
-    private void createTestData() {
-        // insert test data
-        Account account = new Account();
-        account.setId(123);
-        account.setFirstName("James");
-        account.setLastName("Strachan");
-        account.setEmailAddress("TryGuessing@gmail.com");
-        template.sendBody("direct:start", account);
-    }
-
-
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             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
+                // run this timer every 2nd second, that will select data from the database
and send it to the mock endpoint
                 from("timer://pollTheDatabase?delay=2000").to("ibatis:selectAllAccounts?statementType=QueryForList").to("mock:result");
                 // END SNIPPET: e1
-
-                from("direct:start").to("ibatis:insertAccount?statementType=Insert");
             }
         };
     }
 
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-
-        // lets create the database...
-        Connection connection = createConnection();
-        Statement statement = connection.createStatement();
-        statement.execute("create table ACCOUNT ( ACC_ID INTEGER , ACC_FIRST_NAME VARCHAR(255),
ACC_LAST_NAME VARCHAR(255), ACC_EMAIL VARCHAR(255)  )");
-        connection.close();
-    }
-
-    @Override
-    @After
-    public void tearDown() throws Exception {
-        Connection connection = createConnection();
-        Statement statement = connection.createStatement();
-        statement.execute("drop table ACCOUNT");
-        connection.close();
-
-        super.tearDown();
-    }
-
-    private Connection createConnection() throws Exception {
-        IBatisEndpoint endpoint = resolveMandatoryEndpoint("ibatis:selectAllAccounts", IBatisEndpoint.class);
-        return endpoint.getSqlMapClient().getDataSource().getConnection();
-    }
 }
\ No newline at end of file

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=1070800&r1=1070799&r2=1070800&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
Tue Feb 15 08:09:36 2011
@@ -16,21 +16,16 @@
  */
 package org.apache.camel.component.ibatis;
 
-import java.sql.Connection;
-import java.sql.Statement;
 import java.util.ArrayList;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class IBatisRouteEmptyResultSetTest extends CamelTestSupport {
+public class IBatisRouteEmptyResultSetTest extends IBatisTestSupport {
 
     @Test
     public void testRouteEmptyResultSet() throws Exception {
@@ -48,37 +43,13 @@ public class IBatisRouteEmptyResultSetTe
         return new RouteBuilder() {
             public void configure() throws Exception {
                 from("ibatis:selectAllAccounts?consumer.useIterator=false&consumer.routeEmptyResultSet=true").to("mock:results");
-
-                from("direct:start").to("ibatis:insertAccount?statementType=Insert");
             }
         };
     }
 
     @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-
-        // lets create the database...
-        Connection connection = createConnection();
-        Statement statement = connection.createStatement();
-        statement.execute("create table ACCOUNT ( ACC_ID INTEGER , ACC_FIRST_NAME VARCHAR(255),
ACC_LAST_NAME VARCHAR(255), ACC_EMAIL VARCHAR(255)  )");
-        connection.close();
-    }
-
-    @Override
-    @After
-    public void tearDown() throws Exception {
-        Connection connection = createConnection();
-        Statement statement = connection.createStatement();
-        statement.execute("drop table ACCOUNT");
-        connection.close();
-
-        super.tearDown();
-    }
-
-    private Connection createConnection() throws Exception {
-        IBatisEndpoint endpoint = resolveMandatoryEndpoint("ibatis:Account", IBatisEndpoint.class);
-        return endpoint.getSqlMapClient().getDataSource().getConnection();
+    protected boolean createTestData() {
+        // no test data so an empty resultset
+        return false;
     }
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownAllTasksTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownAllTasksTest.java?rev=1070800&r1=1070799&r2=1070800&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownAllTasksTest.java
(original)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownAllTasksTest.java
Tue Feb 15 08:09:36 2011
@@ -108,7 +108,7 @@ public class IBatisShutdownAllTasksTest 
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("ibatis:selectAllAccounts?statementType=QueryForList").noAutoStartup().routeId("route1")
+                from("ibatis:selectAllAccounts").noAutoStartup().routeId("route1")
                      // let it complete all tasks
                      .shutdownRunningTask(ShutdownRunningTask.CompleteAllTasks)
                      .delay(1000).to("seda:foo");

Modified: camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownCurrentTaskOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownCurrentTaskOnlyTest.java?rev=1070800&r1=1070799&r2=1070800&view=diff
==============================================================================
--- camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownCurrentTaskOnlyTest.java
(original)
+++ camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/IBatisShutdownCurrentTaskOnlyTest.java
Tue Feb 15 08:09:36 2011
@@ -103,7 +103,7 @@ public class IBatisShutdownCurrentTaskOn
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("ibatis:selectAllAccounts?statementType=QueryForList").routeId("route1")
+                from("ibatis:selectAllAccounts").routeId("route1")
                      // let it complete only current task so we shutdown faster
                      .shutdownRunningTask(ShutdownRunningTask.CompleteCurrentTaskOnly)
                      .delay(1000).to("seda:foo");

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=1070800&r1=1070799&r2=1070800&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
Tue Feb 15 08:09:36 2011
@@ -26,6 +26,10 @@ import org.junit.Before;
 
 public class IBatisTestSupport extends CamelTestSupport {
 
+    protected boolean createTestData() {
+        return true;
+    }
+
     @Override
     @Before
     public void setUp() throws Exception {
@@ -37,20 +41,22 @@ public class IBatisTestSupport extends C
         statement.execute("create table ACCOUNT ( ACC_ID INTEGER , ACC_FIRST_NAME VARCHAR(255),
ACC_LAST_NAME VARCHAR(255), ACC_EMAIL VARCHAR(255)  )");
         connection.close();
 
-        Account account = new Account();
-        account.setId(123);
-        account.setFirstName("James");
-        account.setLastName("Strachan");
-        account.setEmailAddress("TryGuessing@gmail.com");
-        template.sendBody("ibatis:insertAccount?statementType=Insert", account);
-
-        account = new Account();
-        account.setId(456);
-        account.setFirstName("Claus");
-        account.setLastName("Ibsen");
-        account.setEmailAddress("Noname@gmail.com");
+        if (createTestData()) {
+            Account account = new Account();
+            account.setId(123);
+            account.setFirstName("James");
+            account.setLastName("Strachan");
+            account.setEmailAddress("TryGuessing@gmail.com");
+            template.sendBody("ibatis:insertAccount?statementType=Insert", account);
+
+            account = new Account();
+            account.setId(456);
+            account.setFirstName("Claus");
+            account.setLastName("Ibsen");
+            account.setEmailAddress("Noname@gmail.com");
 
-        template.sendBody("ibatis:insertAccount?statementType=Insert", account);
+            template.sendBody("ibatis:insertAccount?statementType=Insert", account);
+        }
     }
 
     @Override



Mime
View raw message