camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r905287 - /camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/
Date Mon, 01 Feb 2010 14:10:44 GMT
Author: davsclaus
Date: Mon Feb  1 14:10:43 2010
New Revision: 905287

URL: http://svn.apache.org/viewvc?rev=905287&view=rev
Log:
Fixing unit test which occationally fails on another box for no apparent reason.

Added:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientDataSourceSupport.java
  (with props)
Modified:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceHandledTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionRollbackTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionTest.java

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientDataSourceSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientDataSourceSupport.java?rev=905287&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientDataSourceSupport.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientDataSourceSupport.java
Mon Feb  1 14:10:43 2010
@@ -0,0 +1,48 @@
+package org.apache.camel.spring.interceptor;
+
+import javax.sql.DataSource;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+public class TransactionClientDataSourceSupport extends SpringTestSupport {
+    protected JdbcTemplate jdbc;
+    protected boolean useTransactionErrorHandler = true;
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext(
+                "/org/apache/camel/spring/interceptor/transactionalClientDataSource.xml");
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        disableJMX();
+        super.setUp();
+
+        // START SNIPPET: e5
+        // create database and insert dummy data
+        final DataSource ds = getMandatoryBean(DataSource.class, "dataSource");
+        jdbc = new JdbcTemplate(ds);
+        jdbc.execute("create table books (title varchar(50))");
+        jdbc.update("insert into books (title) values (?)", new Object[]{"Camel in Action"});
+        // END SNIPPET: e5
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        jdbc.execute("drop table books");
+        enableJMX();
+    }
+
+    public boolean isUseTransactionErrorHandler() {
+        return useTransactionErrorHandler;
+    }
+
+    @Override
+    protected int getExpectedRouteCount() {
+        return 0;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientDataSourceSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionClientDataSourceSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceHandledTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceHandledTest.java?rev=905287&r1=905286&r2=905287&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceHandledTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceHandledTest.java
Mon Feb  1 14:10:43 2010
@@ -34,7 +34,7 @@
         assertMockEndpointsSatisfied();
 
         int count = jdbc.queryForInt("select count(*) from books");
-        // there should be 2 books as the first insert operation succeded
+        // there should be 2 books as the first insert operation succeeded
         assertEquals("Number of books", 2, count);
     }
 

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java?rev=905287&r1=905286&r2=905287&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
Mon Feb  1 14:10:43 2010
@@ -16,54 +16,15 @@
  */
 package org.apache.camel.spring.interceptor;
 
-import javax.sql.DataSource;
-
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spring.SpringRouteBuilder;
-import org.apache.camel.spring.SpringTestSupport;
 import org.apache.camel.spring.spi.SpringTransactionPolicy;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
  * Unit test to demonstrate the transactional client pattern.
  */
-public class TransactionalClientDataSourceTest extends SpringTestSupport {
-
-    protected JdbcTemplate jdbc;
-    protected boolean useTransactionErrorHandler = true;
-
-    protected AbstractXmlApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext(
-            "/org/apache/camel/spring/interceptor/transactionalClientDataSource.xml");
-    }
-
-    protected int getExpectedRouteCount() {
-        return 0;
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        this.disableJMX();
-        super.setUp();
-
-        // START SNIPPET: e5
-        // create database and insert dummy data
-        final DataSource ds = getMandatoryBean(DataSource.class, "dataSource");
-        jdbc = new JdbcTemplate(ds);
-        jdbc.execute("create table books (title varchar(50))");
-        jdbc.update("insert into books (title) values (?)", new Object[] {"Camel in Action"});
-        // END SNIPPET: e5
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        jdbc.execute("drop table books");
-        this.enableJMX();
-    }
+public class TransactionalClientDataSourceTest extends TransactionClientDataSourceSupport
{
 
     // START SNIPPET: e3
     public void testTransactionSuccess() throws Exception {
@@ -102,7 +63,7 @@
 
                 // use this error handler instead of DeadLetterChannel that is the default
                 // Notice: transactionErrorHandler is in SpringRouteBuilder
-                if (useTransactionErrorHandler) {
+                if (isUseTransactionErrorHandler()) {
                     // useTransactionErrorHandler is only used for unit testing to reuse
code
                     // for doing a 2nd test without this transaction error handler, so ignore
                     // this. For spring based transaction, end users are encouraged to use
the

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java?rev=905287&r1=905286&r2=905287&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java
Mon Feb  1 14:10:43 2010
@@ -24,7 +24,17 @@
 /**
  * @version $Revision$
  */
-public class TransactionalClientDataSourceTransactedWithFileOnExceptionTest extends TransactionalClientDataSourceTransactedWithFileTest
{
+public class TransactionalClientDataSourceTransactedWithFileOnExceptionTest extends TransactionClientDataSourceSupport
{
+
+    public void testTransactionSuccess() throws Exception {
+        template.sendBodyAndHeader("file://target/transacted/okay", "Hello World", Exchange.FILE_NAME,
"okay.txt");
+
+        // wait for route to complete
+        Thread.sleep(3000);
+
+        int count = jdbc.queryForInt("select count(*) from books");
+        assertEquals("Number of books", 3, count);
+    }
 
     public void testTransactionRollback() throws Exception {
         MockEndpoint error = getMockEndpoint("mock:error");
@@ -36,7 +46,7 @@
         template.sendBodyAndHeader("file://target/transacted/fail", "Hello World", Exchange.FILE_NAME,
"fail.txt");
 
         // wait for route to complete
-        Thread.sleep(2000);
+        Thread.sleep(3000);
 
         // should not be able to process the file so we still got 1 book as we did from the
start
         int count = jdbc.queryForInt("select count(*) from books");

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java?rev=905287&r1=905286&r2=905287&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java
Mon Feb  1 14:10:43 2010
@@ -23,7 +23,7 @@
 /**
  * @version $Revision$
  */
-public class TransactionalClientDataSourceTransactedWithFileTest extends TransactionalClientDataSourceTransactedTest
{
+public class TransactionalClientDataSourceTransactedWithFileTest extends TransactionClientDataSourceSupport
{
 
     @Override
     protected void setUp() throws Exception {
@@ -32,7 +32,6 @@
     }
 
     public void testTransactionSuccess() throws Exception {
-        deleteDirectory("target/transacted");
         template.sendBodyAndHeader("file://target/transacted/okay", "Hello World", Exchange.FILE_NAME,
"okay.txt");
 
         // wait for route to complete
@@ -43,7 +42,6 @@
     }
 
     public void testTransactionRollback() throws Exception {
-        deleteDirectory("target/transacted");
         template.sendBodyAndHeader("file://target/transacted/fail", "Hello World", Exchange.FILE_NAME,
"fail.txt");
 
         // wait for route to complete

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionRollbackTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionRollbackTest.java?rev=905287&r1=905286&r2=905287&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionRollbackTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionRollbackTest.java
Mon Feb  1 14:10:43 2010
@@ -28,10 +28,6 @@
  */
 public class TransactionalClientDataSourceWithOnExceptionRollbackTest extends TransactionalClientDataSourceTest
{
 
-    protected int getExpectedRouteCount() {
-        return 0;
-    }
-
     public void testTransactionRollback() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:error");
         mock.expectedMessageCount(1);

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionTest.java?rev=905287&r1=905286&r2=905287&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionTest.java
Mon Feb  1 14:10:43 2010
@@ -27,10 +27,6 @@
  */
 public class TransactionalClientDataSourceWithOnExceptionTest extends TransactionalClientDataSourceTest
{
 
-    protected int getExpectedRouteCount() {
-        return 0;
-    }
-
     public void testTransactionRollback() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:error");
         mock.expectedMessageCount(1);



Mime
View raw message