camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1226088 - in /camel/trunk/components/camel-sql: ./ src/test/java/org/apache/camel/component/sql/ src/test/java/org/apache/camel/processor/aggregate/jdbc/ src/test/java/org/apache/camel/processor/idempotent/jdbc/ src/test/resources/org/apac...
Date Sat, 31 Dec 2011 13:43:10 GMT
Author: cmueller
Date: Sat Dec 31 13:43:09 2011
New Revision: 1226088

URL: http://svn.apache.org/viewvc?rev=1226088&view=rev
Log:
CAMEL-4734: Consolidate the database vendors in our unit tests

Added:
    camel/trunk/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase.sql
Modified:
    camel/trunk/components/camel-sql/pom.xml
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlEndpointTest.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlPreserveHeaderTest.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlTransactedRouteTest.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/AbstractJdbcAggregationTestSupport.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepositoryMultipleRepoTest.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/CustomizedJdbcMessageIdRepositoryTest.java
    camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepositoryTest.java
    camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/aggregate/jdbc/JdbcSpringDataSource.xml
    camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/customized-spring.xml
    camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/spring.xml
    camel/trunk/components/camel-sql/src/test/resources/sql/init.sql
    camel/trunk/components/camel-sql/src/test/resources/sql/init2.sql

Modified: camel/trunk/components/camel-sql/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/pom.xml?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/pom.xml (original)
+++ camel/trunk/components/camel-sql/pom.xml Sat Dec 31 13:43:09 2011
@@ -76,15 +76,10 @@
             <scope>test</scope>
         </dependency>
 	    <dependency>
-	      <groupId>org.hsqldb</groupId>
-	      <artifactId>hsqldb</artifactId>
+	      <groupId>org.apache.derby</groupId>
+	      <artifactId>derby</artifactId>
 	      <scope>test</scope>
 	    </dependency>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-            <scope>test</scope>
-        </dependency>
 	</dependencies>
 	
     <build>

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceRefTest.java
Sat Dec 31 13:43:09 2011
@@ -19,32 +19,36 @@ package org.apache.camel.component.sql;
 import java.util.List;
 import java.util.Map;
 
-import javax.sql.DataSource;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.SingleConnectionDataSource;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 
 /**
  * @version 
  */
 public class SqlDataSourceRefTest extends CamelTestSupport {
-    protected String driverClass = "org.hsqldb.jdbcDriver";
-    protected String url = "jdbc:hsqldb:mem:camel_jdbc";
-    protected String user = "sa";
-    protected String password = "";
-    private JdbcTemplate jdbcTemplate;
+    
+    private EmbeddedDatabase db;
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
-        jndi.bind("jdbc/myDataSource", createDataSource());
+        
+        // START SNIPPET: e2
+        // this is the database we create with some initial data for our unit test
+        db = new EmbeddedDatabaseBuilder()
+            .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
+        // END SNIPPET: e2
+        
+        jndi.bind("jdbc/myDataSource", db);
+        
         return jndi;
     }
 
@@ -73,31 +77,11 @@ public class SqlDataSourceRefTest extend
         // END SNIPPET: e3
     }
 
-    @Before
-    public void setUp() throws Exception {
-        Class.forName(driverClass);
-        super.setUp();
-
-        jdbcTemplate = new JdbcTemplate(createDataSource());
-        // START SNIPPET: e2
-        // this is the database we create with some initial data for our unit test
-        jdbcTemplate.execute("create table projects (id integer primary key,"
-                             + "project varchar(10), license varchar(5))");
-        jdbcTemplate.execute("insert into projects values (1, 'Camel', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (2, 'AMQ', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (3, 'Linux', 'XXX')");
-        // END SNIPPET: e2
-    }
-
     @After
     public void tearDown() throws Exception {
         super.tearDown();
-        JdbcTemplate jdbcTemplate = new JdbcTemplate(createDataSource());
-        jdbcTemplate.execute("drop table projects");
-    }
-
-    private DataSource createDataSource() {
-        return new SingleConnectionDataSource(url, user, password, true);
+        
+        db.shutdown();
     }
 
     @Override
@@ -112,5 +96,4 @@ public class SqlDataSourceRefTest extend
             }
         };
     }
-
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlEndpointTest.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlEndpointTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlEndpointTest.java
Sat Dec 31 13:43:09 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.component.sql;
 
-import javax.sql.DataSource;
-
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
@@ -25,18 +23,16 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.SingleConnectionDataSource;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 
 /**
  * @version 
  */
 public class SqlEndpointTest extends CamelTestSupport {
-    protected String driverClass = "org.hsqldb.jdbcDriver";
-    protected String url = "jdbc:hsqldb:mem:camel_jdbc";
-    protected String user = "sa";
-    protected String password = "";
-    private DataSource ds;
-    private JdbcTemplate jdbcTemplate;
+
+    private EmbeddedDatabase db;
 
     @Test
     public void testSQLEndpoint() throws Exception {
@@ -50,33 +46,26 @@ public class SqlEndpointTest extends Cam
 
     @Before
     public void setUp() throws Exception {
-        Class.forName(driverClass);
+        db = new EmbeddedDatabaseBuilder()
+            .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
+        
         super.setUp();
-
-        jdbcTemplate = new JdbcTemplate(ds);
-        jdbcTemplate.execute("create table projects (id integer primary key,"
-                             + "project varchar(10), license varchar(5))");
-        jdbcTemplate.execute("insert into projects values (1, 'Camel', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (2, 'AMQ', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (3, 'Linux', 'XXX')");
     }
 
     @After
     public void tearDown() throws Exception {
         super.tearDown();
-        JdbcTemplate jdbcTemplate = new JdbcTemplate(ds);
-        jdbcTemplate.execute("drop table projects");
+        
+        db.shutdown();
     }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                ds = new SingleConnectionDataSource(url, user, password, true);
-
                 SqlEndpoint sql = new SqlEndpoint();
                 sql.setCamelContext(context);
-                sql.setJdbcTemplate(new JdbcTemplate(ds));
+                sql.setJdbcTemplate(new JdbcTemplate(db));
                 sql.setQuery("select * from projects");
 
                 context.addEndpoint("mysql", sql);

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlPreserveHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlPreserveHeaderTest.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlPreserveHeaderTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlPreserveHeaderTest.java
Sat Dec 31 13:43:09 2011
@@ -16,27 +16,22 @@
  */
 package org.apache.camel.component.sql;
 
-import javax.sql.DataSource;
-
 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;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.SingleConnectionDataSource;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 
 /**
  * @version 
  */
 public class SqlPreserveHeaderTest extends CamelTestSupport {
-    protected String driverClass = "org.hsqldb.jdbcDriver";
-    protected String url = "jdbc:hsqldb:mem:camel_jdbc";
-    protected String user = "sa";
-    protected String password = "";
-    private DataSource ds;
-    private JdbcTemplate jdbcTemplate;
+    
+    private EmbeddedDatabase db;
 
     @Test
     public void testPreserveHeaders() throws Exception {
@@ -51,31 +46,24 @@ public class SqlPreserveHeaderTest exten
 
     @Before
     public void setUp() throws Exception {
-        Class.forName(driverClass);
+        db = new EmbeddedDatabaseBuilder()
+            .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
+        
         super.setUp();
-
-        jdbcTemplate = new JdbcTemplate(ds);
-        jdbcTemplate.execute("create table projects (id integer primary key,"
-                             + "project varchar(10), license varchar(5))");
-        jdbcTemplate.execute("insert into projects values (1, 'Camel', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (2, 'AMQ', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (3, 'Linux', 'XXX')");
     }
 
     @After
     public void tearDown() throws Exception {
         super.tearDown();
-        JdbcTemplate jdbcTemplate = new JdbcTemplate(ds);
-        jdbcTemplate.execute("drop table projects");
+        
+        db.shutdown();
     }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-                ds = new SingleConnectionDataSource(url, user, password, true);
-
-                getContext().getComponent("sql", SqlComponent.class).setDataSource(ds);
+                getContext().getComponent("sql", SqlComponent.class).setDataSource(db);
 
                 errorHandler(noErrorHandler());
 
@@ -86,5 +74,4 @@ public class SqlPreserveHeaderTest exten
             }
         };
     }
-
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java
Sat Dec 31 13:43:09 2011
@@ -23,26 +23,26 @@ import java.util.concurrent.ConcurrentHa
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
-import javax.sql.DataSource;
 
+import org.apache.camel.EndpointInject;
 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;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.SingleConnectionDataSource;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 
 /**
  * @version 
  */
 public class SqlProducerConcurrentTest extends CamelTestSupport {
-    protected String driverClass = "org.hsqldb.jdbcDriver";
-    protected String url = "jdbc:hsqldb:mem:camel_jdbc";
-    protected String user = "sa";
-    protected String password = "";
-    private DataSource ds;
-    private JdbcTemplate jdbcTemplate;
+    
+    @EndpointInject(uri = "mock:result")
+    private MockEndpoint mockEndpoint;
+    private EmbeddedDatabase db;
 
     @Test
     public void testNoConcurrentProducers() throws Exception {
@@ -55,15 +55,16 @@ public class SqlProducerConcurrentTest e
     }
 
     private void doSendMessages(int files, int poolSize) throws Exception {
-        getMockEndpoint("mock:result").expectedMessageCount(files);
+        mockEndpoint.expectedMessageCount(files);
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
         Map<Integer, Future<?>> responses = new ConcurrentHashMap<Integer,
Future<?>>();
+
         for (int i = 0; i < files; i++) {
             final int index = i;
             Future<?> out = executor.submit(new Callable<Object>() {
                 public Object call() throws Exception {
-                    int id = index % 3;
+                    int id = (index % 3) + 1;
                     return template.requestBody("direct:simple", "" + id);
                 }
             });
@@ -71,7 +72,6 @@ public class SqlProducerConcurrentTest e
         }
 
         assertMockEndpointsSatisfied();
-
         assertEquals(files, responses.size());
 
         for (int i = 0; i < files; i++) {
@@ -90,34 +90,27 @@ public class SqlProducerConcurrentTest e
 
     @Before
     public void setUp() throws Exception {
-        Class.forName(driverClass);
+        db = new EmbeddedDatabaseBuilder()
+            .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
+        
         super.setUp();
-
-        jdbcTemplate = new JdbcTemplate(ds);
-        jdbcTemplate.execute("create table projects (id integer primary key,"
-                             + "project varchar(10), license varchar(5))");
-        jdbcTemplate.execute("insert into projects values (0, 'Camel', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (1, 'AMQ', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (2, 'Linux', 'XXX')");
     }
 
     @After
     public void tearDown() throws Exception {
         super.tearDown();
-        JdbcTemplate jdbcTemplate = new JdbcTemplate(ds);
-        jdbcTemplate.execute("drop table projects");
+        
+        db.shutdown();
     }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-                ds = new SingleConnectionDataSource(url, user, password, true);
-                getContext().getComponent("sql", SqlComponent.class).setDataSource(ds);
+                getContext().getComponent("sql", SqlComponent.class).setDataSource(db);
 
                 from("direct:simple").to("sql:select * from projects where id = # order by
id").to("mock:result");
             }
         };
     }
-
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlRouteTest.java
Sat Dec 31 13:43:09 2011
@@ -23,8 +23,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import javax.sql.DataSource;
-
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -36,17 +34,16 @@ import org.springframework.dao.DataAcces
 import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.jdbc.UncategorizedSQLException;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.SingleConnectionDataSource;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 
 /**
  * @version 
  */
 public class SqlRouteTest extends CamelTestSupport {
-    protected String driverClass = "org.hsqldb.jdbcDriver";
-    protected String url = "jdbc:hsqldb:mem:camel_jdbc";
-    protected String user = "sa";
-    protected String password = "";
-    private DataSource ds;
+
+    private EmbeddedDatabase db;
     private JdbcTemplate jdbcTemplate;
 
     @Test
@@ -256,14 +253,10 @@ public class SqlRouteTest extends CamelT
     
     @Before
     public void setUp() throws Exception {
-        Class.forName(driverClass);
-        ds = new SingleConnectionDataSource(url, user, password, true);
+        db = new EmbeddedDatabaseBuilder()
+            .setType(EmbeddedDatabaseType.DERBY).addScript("sql/createAndPopulateDatabase.sql").build();
         
-        jdbcTemplate = new JdbcTemplate(ds);
-        jdbcTemplate.execute("create table projects (id integer primary key, project varchar(10),
license varchar(5))");
-        jdbcTemplate.execute("insert into projects values (1, 'Camel', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (2, 'AMQ', 'ASF')");
-        jdbcTemplate.execute("insert into projects values (3, 'Linux', 'XXX')");
+        jdbcTemplate = new JdbcTemplate(db);
         
         super.setUp();
     }
@@ -272,15 +265,14 @@ public class SqlRouteTest extends CamelT
     public void tearDown() throws Exception {
         super.tearDown();
         
-        jdbcTemplate.execute("drop table projects");
-        ((SingleConnectionDataSource) ds).destroy();
+        db.shutdown();
     }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-                getContext().getComponent("sql", SqlComponent.class).setDataSource(ds);
+                getContext().getComponent("sql", SqlComponent.class).setDataSource(db);
 
                 errorHandler(noErrorHandler());
                 

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlTransactedRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlTransactedRouteTest.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlTransactedRouteTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlTransactedRouteTest.java
Sat Dec 31 13:43:09 2011
@@ -18,8 +18,6 @@ package org.apache.camel.component.sql;
 
 import java.util.Map;
 
-import javax.sql.DataSource;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
@@ -31,21 +29,17 @@ import org.junit.Before;
 import org.junit.Test;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.jdbc.datasource.DriverManagerDataSource;
-import org.springframework.jdbc.datasource.SingleConnectionDataSource;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 
 /**
  * @version 
  */
 public class SqlTransactedRouteTest extends CamelTestSupport {
     
-    protected DataSource ds;
-    protected JdbcTemplate jdbc;
-    
-    private String driverClass = "org.hsqldb.jdbcDriver";
-    private String url = "jdbc:hsqldb:mem:camel_jdbc";
-    private String user = "sa";
-    private String password = "";
+    private EmbeddedDatabase db;
+    private JdbcTemplate jdbc;
     
     private String startEndpoint = "direct:start";
     private String sqlEndpoint = "sql:overriddenByTheHeader?dataSourceRef=testdb";
@@ -54,7 +48,7 @@ public class SqlTransactedRouteTest exte
     public void setUp() throws Exception {
         super.setUp();
         
-        jdbc = new JdbcTemplate(ds);
+        jdbc = new JdbcTemplate(db);
         jdbc.execute("CREATE TABLE CUSTOMER (ID VARCHAR(15) NOT NULL PRIMARY KEY, NAME VARCHAR(100))");
     }
 
@@ -62,12 +56,12 @@ public class SqlTransactedRouteTest exte
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry reg = super.createRegistry();
         
-        ds = new SingleConnectionDataSource(url, user, password, true);
-        ((DriverManagerDataSource) ds).setDriverClassName(driverClass);
-        reg.bind("testdb", ds);
+        db = new EmbeddedDatabaseBuilder()
+            .setType(EmbeddedDatabaseType.DERBY).build();
+        reg.bind("testdb", db);
         
         DataSourceTransactionManager txMgr = new DataSourceTransactionManager();
-        txMgr.setDataSource(ds);
+        txMgr.setDataSource(db);
         reg.bind("txManager", txMgr);
         
         SpringTransactionPolicy txPolicy = new SpringTransactionPolicy();
@@ -82,8 +76,7 @@ public class SqlTransactedRouteTest exte
     public void tearDown() throws Exception {
         super.tearDown();
         
-        JdbcTemplate jdbc = new JdbcTemplate(ds);
-        jdbc.execute("drop table customer");
+        db.shutdown();
     }
     
     @Test

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/AbstractJdbcAggregationTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/AbstractJdbcAggregationTestSupport.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/AbstractJdbcAggregationTestSupport.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/AbstractJdbcAggregationTestSupport.java
Sat Dec 31 13:43:09 2011
@@ -19,29 +19,25 @@ package org.apache.camel.processor.aggre
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public abstract class AbstractJdbcAggregationTestSupport extends CamelTestSupport {
+public abstract class AbstractJdbcAggregationTestSupport extends CamelSpringTestSupport {
 
     JdbcAggregationRepository repo;
 
-    @Before
     @Override
-    public void setUp() throws Exception {
-        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/processor/aggregate/jdbc/JdbcSpringDataSource.xml");
-        repo = applicationContext.getBean("repo1", JdbcAggregationRepository.class);
+    public void postProcessTest() throws Exception {
+        super.postProcessTest();
         
+        repo = applicationContext.getBean("repo1", JdbcAggregationRepository.class);
         configureJdbcAggregationRepository();
-        
-        super.setUp();
     }
-
+    
     void configureJdbcAggregationRepository() {
     }
-
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -62,6 +58,16 @@ public abstract class AbstractJdbcAggreg
     long getCompletionInterval() {
         return 5000;
     }
+    
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/processor/aggregate/jdbc/JdbcSpringDataSource.xml");
+    }
+
+    @Override
+    protected int getExpectedRouteCount() {
+        return 0;
+    }
 
     public static class MyAggregationStrategy implements AggregationStrategy {
 

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepositoryMultipleRepoTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepositoryMultipleRepoTest.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepositoryMultipleRepoTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/aggregate/jdbc/JdbcAggregationRepositoryMultipleRepoTest.java
Sat Dec 31 13:43:09 2011
@@ -18,21 +18,12 @@ package org.apache.camel.processor.aggre
 
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultExchange;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
 import org.junit.Test;
-import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class JdbcAggregationRepositoryMultipleRepoTest extends CamelTestSupport {
-
-    ApplicationContext applicationContext;
-
-    @Override
-    public void setUp() throws Exception {
-        applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/processor/aggregate/jdbc/JdbcSpringDataSource.xml");
-
-        super.setUp();
-    }
+public class JdbcAggregationRepositoryMultipleRepoTest extends CamelSpringTestSupport {
 
     @Test
     public void testMultipeRepo() {
@@ -103,4 +94,14 @@ public class JdbcAggregationRepositoryMu
         actual = repo2.get(context, "foo");
         assertEquals("Bye World", actual.getIn().getBody());
     }
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/processor/aggregate/jdbc/JdbcSpringDataSource.xml");
+    }
+
+    @Override
+    protected int getExpectedRouteCount() {
+        return 0;
+    }
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/CustomizedJdbcMessageIdRepositoryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/CustomizedJdbcMessageIdRepositoryTest.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/CustomizedJdbcMessageIdRepositoryTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/CustomizedJdbcMessageIdRepositoryTest.java
Sat Dec 31 13:43:09 2011
@@ -28,16 +28,10 @@ import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.TransactionCallback;
-import org.springframework.transaction.support.TransactionTemplate;
 
 public class CustomizedJdbcMessageIdRepositoryTest extends CamelSpringTestSupport {
 
     protected static final String SELECT_ALL_STRING = "SELECT messageId FROM CUSTOMIZED_MESSAGE_REPOSITORY
WHERE processorName = ?";
-    protected static final String DELETE_ALL_STRING = "DELETE FROM CUSTOMIZED_MESSAGE_REPOSITORY
WHERE processorName = ?";
     protected static final String PROCESSOR_NAME = "myProcessorName";
 
     protected JdbcTemplate jdbcTemplate;
@@ -57,28 +51,8 @@ public class CustomizedJdbcMessageIdRepo
         dataSource = context.getRegistry().lookup("dataSource", DataSource.class);
         jdbcTemplate = new JdbcTemplate(dataSource);
         jdbcTemplate.afterPropertiesSet();
-        
-        setupRepository();
     }
     
-    @Override
-    protected AbstractApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/processor/idempotent/jdbc/customized-spring.xml");
-    }
-
-    protected void setupRepository() {
-        TransactionTemplate transactionTemplate = new TransactionTemplate();
-        transactionTemplate.setTransactionManager(new DataSourceTransactionManager(dataSource));
-        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
-        
-        transactionTemplate.execute(new TransactionCallback<Boolean>() {
-            public Boolean doInTransaction(TransactionStatus status) {
-                jdbcTemplate.update(DELETE_ALL_STRING, PROCESSOR_NAME);
-                return Boolean.TRUE;
-            }
-        });
-    }
-
     @Test
     public void testDuplicateMessagesAreFilteredOut() throws Exception {
         resultEndpoint.expectedBodiesReceived("one", "two", "three");
@@ -101,4 +75,9 @@ public class CustomizedJdbcMessageIdRepo
         assertTrue(receivedMessageIds.contains("2"));
         assertTrue(receivedMessageIds.contains("3"));
     }
+    
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/processor/idempotent/jdbc/customized-spring.xml");
+    }
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepositoryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepositoryTest.java?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepositoryTest.java
(original)
+++ camel/trunk/components/camel-sql/src/test/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepositoryTest.java
Sat Dec 31 13:43:09 2011
@@ -31,18 +31,11 @@ import org.junit.Before;
 import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.dao.DataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.TransactionCallback;
-import org.springframework.transaction.support.TransactionTemplate;
 
 public class JdbcMessageIdRepositoryTest extends CamelSpringTestSupport {
 
     protected static final String SELECT_ALL_STRING = "SELECT messageId FROM CAMEL_MESSAGEPROCESSED
WHERE processorName = ?";
-    protected static final String DELETE_ALL_STRING = "DELETE FROM CAMEL_MESSAGEPROCESSED
WHERE processorName = ?";
     protected static final String PROCESSOR_NAME = "myProcessorName";
 
     protected JdbcTemplate jdbcTemplate;
@@ -62,33 +55,8 @@ public class JdbcMessageIdRepositoryTest
         dataSource = context.getRegistry().lookup("dataSource", DataSource.class);
         jdbcTemplate = new JdbcTemplate(dataSource);
         jdbcTemplate.afterPropertiesSet();
-        
-        setupRepository();
     }
     
-    @Override
-    protected AbstractApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/processor/idempotent/jdbc/spring.xml");
-    }
-
-    protected void setupRepository() {
-        TransactionTemplate transactionTemplate = new TransactionTemplate();
-        transactionTemplate.setTransactionManager(new DataSourceTransactionManager(dataSource));
-        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
-        
-        transactionTemplate.execute(new TransactionCallback<Boolean>() {
-            public Boolean doInTransaction(TransactionStatus status) {
-                try {
-                    jdbcTemplate.execute("CREATE TABLE CAMEL_MESSAGEPROCESSED (processorName
VARCHAR(20), messageId VARCHAR(10), createdAt timestamp)");
-                } catch (DataAccessException e) {
-                    // noop if table already exists 
-                }
-                jdbcTemplate.update(DELETE_ALL_STRING, PROCESSOR_NAME);
-                return Boolean.TRUE;
-            }
-        });
-    }
-
     @Test
     public void testDuplicateMessagesAreFilteredOut() throws Exception {
         resultEndpoint.expectedBodiesReceived("one", "two", "three");
@@ -151,4 +119,9 @@ public class JdbcMessageIdRepositoryTest
         assertTrue("Should contain message 1", receivedMessageIds.contains("1"));
         assertTrue("Should contain message 3", receivedMessageIds.contains("3"));
     }
+    
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/processor/idempotent/jdbc/spring.xml");
+    }
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/aggregate/jdbc/JdbcSpringDataSource.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/aggregate/jdbc/JdbcSpringDataSource.xml?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/aggregate/jdbc/JdbcSpringDataSource.xml
(original)
+++ camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/aggregate/jdbc/JdbcSpringDataSource.xml
Sat Dec 31 13:43:09 2011
@@ -35,12 +35,12 @@
     <tx:annotation-driven transaction-manager="txManager"/>
 
 	<!-- In Memory Database #1 -->
-    <jdbc:embedded-database id="dataSource1" type="H2">
+    <jdbc:embedded-database id="dataSource1" type="DERBY">
         <jdbc:script location="classpath:/sql/init.sql"/>
     </jdbc:embedded-database>
 
     <!-- In Memory Database #2 -->
-    <jdbc:embedded-database id="dataSource2" type="H2">
+    <jdbc:embedded-database id="dataSource2" type="DERBY">
         <jdbc:script location="classpath:/sql/init2.sql"/>
     </jdbc:embedded-database>
 

Modified: camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/customized-spring.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/customized-spring.xml?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/customized-spring.xml
(original)
+++ camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/customized-spring.xml
Sat Dec 31 13:43:09 2011
@@ -17,24 +17,21 @@
 -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:camel="http://camel.apache.org/schema/spring"
+       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+           http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
            http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
-    <bean id="dataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
-        <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
-        <property name="url" value="jdbc:hsqldb:mem:camel_jdbc"/>
-        <property name="username" value="sa"/>
-        <property name="password" value=""/>
-    </bean>
+    <jdbc:embedded-database id="dataSource" type="DERBY" />
     
     <!-- START SNIPPET: e1 -->
     <bean id="messageIdRepository" class="org.apache.camel.processor.idempotent.jdbc.JdbcMessageIdRepository">
     	<constructor-arg ref="dataSource" />
     	<constructor-arg value="myProcessorName" />
     	<property name="tableExistsString" value="SELECT 1 FROM CUSTOMIZED_MESSAGE_REPOSITORY
WHERE 1 = 0" />
-    	<property name="createString" value="CREATE TABLE CUSTOMIZED_MESSAGE_REPOSITORY (processorName
VARCHAR(255), messageId VARCHAR(100), createdAt DATETIME)" />
+    	<property name="createString" value="CREATE TABLE CUSTOMIZED_MESSAGE_REPOSITORY (processorName
VARCHAR(255), messageId VARCHAR(100), createdAt TIMESTAMP)" />
     	<property name="queryString" value="SELECT COUNT(*) FROM CUSTOMIZED_MESSAGE_REPOSITORY
WHERE processorName = ? AND messageId = ?" />
     	<property name="insertString" value="INSERT INTO CUSTOMIZED_MESSAGE_REPOSITORY (processorName,
messageId, createdAt) VALUES (?, ?, ?)" />
     	<property name="deleteString" value="DELETE FROM CUSTOMIZED_MESSAGE_REPOSITORY WHERE
processorName = ? AND messageId = ?" />

Modified: camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/spring.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/spring.xml?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/spring.xml
(original)
+++ camel/trunk/components/camel-sql/src/test/resources/org/apache/camel/processor/idempotent/jdbc/spring.xml
Sat Dec 31 13:43:09 2011
@@ -17,18 +17,15 @@
 -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:camel="http://camel.apache.org/schema/spring"
+       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+           http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
            http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
 	<!-- START SNIPPET: e1 -->
-    <bean id="dataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource">
-        <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
-        <property name="url" value="jdbc:hsqldb:mem:camel_jdbc"/>
-        <property name="username" value="sa"/>
-        <property name="password" value=""/>
-    </bean>
+	<jdbc:embedded-database id="dataSource" type="DERBY" />
     <!-- END SNIPPET: e1 -->
     
     <!-- START SNIPPET: e2 -->

Added: camel/trunk/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase.sql
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase.sql?rev=1226088&view=auto
==============================================================================
--- camel/trunk/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase.sql
(added)
+++ camel/trunk/components/camel-sql/src/test/resources/sql/createAndPopulateDatabase.sql
Sat Dec 31 13:43:09 2011
@@ -0,0 +1,6 @@
+-- START SNIPPET: e1
+create table projects (id integer primary key, project varchar(10), license varchar(5));
+insert into projects values (1, 'Camel', 'ASF');
+insert into projects values (2, 'AMQ', 'ASF');
+insert into projects values (3, 'Linux', 'XXX');
+-- END SNIPPET: e1
\ No newline at end of file

Modified: camel/trunk/components/camel-sql/src/test/resources/sql/init.sql
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/resources/sql/init.sql?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/resources/sql/init.sql (original)
+++ camel/trunk/components/camel-sql/src/test/resources/sql/init.sql Sat Dec 31 13:43:09 2011
@@ -1,5 +1,3 @@
-DROP TABLE aggregationRepo1 IF EXISTS;
-DROP TABLE aggregationRepo1_completed IF EXISTS;
 CREATE TABLE aggregationRepo1 (
     id varchar(255) NOT NULL,
     exchange blob NOT NULL,

Modified: camel/trunk/components/camel-sql/src/test/resources/sql/init2.sql
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/test/resources/sql/init2.sql?rev=1226088&r1=1226087&r2=1226088&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/test/resources/sql/init2.sql (original)
+++ camel/trunk/components/camel-sql/src/test/resources/sql/init2.sql Sat Dec 31 13:43:09
2011
@@ -1,5 +1,3 @@
-DROP TABLE aggregationRepo2 IF EXISTS;
-DROP TABLE aggregationRepo2_completed IF EXISTS;
 CREATE TABLE aggregationRepo2 (
     id varchar(255) NOT NULL,
     exchange blob NOT NULL,



Mime
View raw message