camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r785229 - in /camel/trunk/components/camel-jpa: ./ src/test/java/org/apache/camel/component/jpa/ src/test/java/org/apache/camel/processor/interceptor/ src/test/java/org/apache/camel/processor/jpa/
Date Tue, 16 Jun 2009 14:29:26 GMT
Author: ningjiang
Date: Tue Jun 16 14:29:25 2009
New Revision: 785229

URL: http://svn.apache.org/viewvc?rev=785229&view=rev
Log:
CAMEL-1712 Upgraded the camel-jpa to JUnit4

Modified:
    camel/trunk/components/camel-jpa/pom.xml
    camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
    camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryTest.java
    camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/interceptor/JpaTraceEventMessageTest.java
    camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/FileConsumerJpaIdempotentTest.java
    camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaBatchConsumerTest.java
    camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaIdempotentConsumerTest.java
    camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java
    camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java

Modified: camel/trunk/components/camel-jpa/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/pom.xml?rev=785229&r1=785228&r2=785229&view=diff
==============================================================================
--- camel/trunk/components/camel-jpa/pom.xml (original)
+++ camel/trunk/components/camel-jpa/pom.xml Tue Jun 16 14:29:25 2009
@@ -67,9 +67,7 @@
     <!-- testing -->
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-core</artifactId>
-      <type>test-jar</type>
-      <optional>true</optional>
+      <artifactId>camel-test</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java?rev=785229&r1=785228&r2=785229&view=diff
==============================================================================
--- camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
(original)
+++ camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
Tue Jun 16 14:29:25 2009
@@ -23,8 +23,6 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceException;
 
-import junit.framework.TestCase;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
@@ -35,6 +33,10 @@
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.springframework.orm.jpa.JpaCallback;
 import org.springframework.orm.jpa.JpaTemplate;
 
@@ -43,7 +45,7 @@
 /**
  * @version $Revision$
  */
-public class JpaTest extends TestCase {
+public class JpaTest extends Assert {
     private static final transient Log LOG = LogFactory.getLog(JpaTest.class);
     protected CamelContext camelContext = new DefaultCamelContext();
     protected ProducerTemplate template = camelContext.createProducerTemplate();
@@ -56,6 +58,7 @@
     protected String entityName = SendEmail.class.getName();
     protected String queryText = "select o from " + entityName + " o";
 
+    @Test
     public void testProducerInsertsIntoDatabaseThenConsumerFiresMessageExchange() throws
Exception {
         transactionStrategy.execute(new JpaCallback() {
             public Object doInJpa(EntityManager entityManager) throws PersistenceException
{
@@ -100,10 +103,9 @@
         assertEquals("address property", "foo@bar.com", result.getAddress());
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
+    @Before
+    public void setUp() throws Exception {
+        
         startServices(template, camelContext);
 
         Endpoint value = camelContext.getEndpoint(getEndpointUri());
@@ -119,11 +121,10 @@
         return "jpa://" + SendEmail.class.getName();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
 
         stopServices(consumer, template, camelContext);
-
-        super.tearDown();
+        
     }
 }

Modified: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryTest.java?rev=785229&r1=785228&r2=785229&view=diff
==============================================================================
--- camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryTest.java
(original)
+++ camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryTest.java
Tue Jun 16 14:29:25 2009
@@ -23,8 +23,6 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceException;
 
-import junit.framework.TestCase;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
@@ -36,13 +34,17 @@
 import org.apache.camel.util.ServiceHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.springframework.orm.jpa.JpaCallback;
 import org.springframework.orm.jpa.JpaTemplate;
 
 /**
  * @version $Revision$
  */
-public class JpaWithNamedQueryTest extends TestCase {
+public class JpaWithNamedQueryTest extends Assert {
     private static final transient Log LOG = LogFactory.getLog(JpaWithNamedQueryTest.class);
     protected CamelContext camelContext = new DefaultCamelContext();
     protected ProducerTemplate template = camelContext.createProducerTemplate();
@@ -55,6 +57,7 @@
     protected String entityName = MultiSteps.class.getName();
     protected String queryText = "select o from " + entityName + " o where o.step = 1";
 
+    @Test
     public void testProducerInsertsIntoDatabaseThenConsumerFiresMessageExchange() throws
Exception {
         transactionStrategy.execute(new JpaCallback() {
             public Object doInJpa(EntityManager entityManager) throws PersistenceException
{
@@ -132,10 +135,9 @@
         });
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
+    @Before
+    public void setUp() throws Exception {
+        
         ServiceHelper.startServices(template, camelContext);
 
         Endpoint value = camelContext.getEndpoint(getEndpointUri());
@@ -151,11 +153,10 @@
         return "jpa://" + MultiSteps.class.getName() + "?consumer.namedQuery=step1";
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
 
         ServiceHelper.stopServices(consumer, template, camelContext);
 
-        super.tearDown();
     }
 }

Modified: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/interceptor/JpaTraceEventMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/interceptor/JpaTraceEventMessageTest.java?rev=785229&r1=785228&r2=785229&view=diff
==============================================================================
--- camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/interceptor/JpaTraceEventMessageTest.java
(original)
+++ camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/interceptor/JpaTraceEventMessageTest.java
Tue Jun 16 14:29:25 2009
@@ -19,11 +19,12 @@
 import java.util.List;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.spring.SpringRouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.orm.jpa.JpaTemplate;
@@ -36,12 +37,13 @@
 /**
  * @version $Revision$
  */
-public class JpaTraceEventMessageTest extends ContextTestSupport {
+public class JpaTraceEventMessageTest extends CamelTestSupport {
     protected static final String SELECT_ALL_STRING = "select x from " + JpaTraceEventMessage.class.getName()
+ " x";
 
     protected ApplicationContext applicationContext;
     protected JpaTemplate jpaTemplate;
 
+    @Test
     public void testSendTraceMessage() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);

Modified: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/FileConsumerJpaIdempotentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/FileConsumerJpaIdempotentTest.java?rev=785229&r1=785228&r2=785229&view=diff
==============================================================================
--- camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/FileConsumerJpaIdempotentTest.java
(original)
+++ camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/FileConsumerJpaIdempotentTest.java
Tue Jun 16 14:29:25 2009
@@ -20,12 +20,14 @@
 import java.util.List;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.processor.idempotent.jpa.MessageProcessed;
 import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.orm.jpa.JpaTemplate;
@@ -38,7 +40,7 @@
 /**
  * Unit test using jpa idempotent repository for the file consumer.
  */
-public class FileConsumerJpaIdempotentTest extends ContextTestSupport {
+public class FileConsumerJpaIdempotentTest extends CamelTestSupport {
 
     protected static final String SELECT_ALL_STRING = "select x from " + MessageProcessed.class.getName()
+ " x where x.processorName = ?1";
     protected static final String PROCESSOR_NAME = "FileConsumer";
@@ -52,8 +54,8 @@
         return SpringCamelContext.springCamelContext(applicationContext);
     }
 
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         super.setUp();
         cleanupRepository();
         deleteDirectory("target/idempotent");
@@ -88,6 +90,7 @@
         });
     }
 
+    @Test
     public void testFileConsumerJpaIdempotent() throws Exception {
         // consume the file the first time
         MockEndpoint mock = getMockEndpoint("mock:result");

Modified: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaBatchConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaBatchConsumerTest.java?rev=785229&r1=785228&r2=785229&view=diff
==============================================================================
--- camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaBatchConsumerTest.java
(original)
+++ camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaBatchConsumerTest.java
Tue Jun 16 14:29:25 2009
@@ -19,12 +19,13 @@
 import java.util.List;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.examples.SendEmail;
 import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.orm.jpa.JpaTemplate;
@@ -37,13 +38,14 @@
 /**
  * @version $Revision$
  */
-public class JpaBatchConsumerTest extends ContextTestSupport {
+public class JpaBatchConsumerTest extends CamelTestSupport {
 
     protected static final String SELECT_ALL_STRING = "select x from " + SendEmail.class.getName()
+ " x";
 
     protected ApplicationContext applicationContext;
     protected JpaTemplate jpaTemplate;
 
+    @Test
     public void testBatchConsumer() throws Exception {
         // first create two records
         template.sendBody("jpa://" + SendEmail.class.getName(), new SendEmail("foo@beer.org"));

Modified: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaIdempotentConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaIdempotentConsumerTest.java?rev=785229&r1=785228&r2=785229&view=diff
==============================================================================
--- camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaIdempotentConsumerTest.java
(original)
+++ camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaIdempotentConsumerTest.java
Tue Jun 16 14:29:25 2009
@@ -19,7 +19,6 @@
 import java.util.List;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -28,6 +27,9 @@
 import org.apache.camel.processor.idempotent.jpa.MessageProcessed;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.spring.SpringRouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -43,7 +45,7 @@
 /**
  * @version $Revision$
  */
-public class JpaIdempotentConsumerTest extends ContextTestSupport {
+public class JpaIdempotentConsumerTest extends CamelTestSupport {
     protected static final String SELECT_ALL_STRING = "select x from " + MessageProcessed.class.getName()
+ " x where x.processorName = ?1";
     protected static final String PROCESSOR_NAME = "myProcessorName";
 
@@ -84,13 +86,14 @@
     }
 
     @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         super.setUp();
-
         startEndpoint = resolveMandatoryEndpoint("direct:start");
         resultEndpoint = getMockEndpoint("mock:result");
     }
 
+    @Test
     public void testDuplicateMessagesAreFilteredOut() throws Exception {
         context.addRoutes(new SpringRouteBuilder() {
             @Override
@@ -117,6 +120,7 @@
         assertMockEndpointsSatisfied();
     }
 
+    @Test
     public void testFailedExchangesNotAdded() throws Exception {
         context.addRoutes(new SpringRouteBuilder() {
             @Override

Modified: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java?rev=785229&r1=785228&r2=785229&view=diff
==============================================================================
--- camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java
(original)
+++ camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java
Tue Jun 16 14:29:25 2009
@@ -25,11 +25,12 @@
 import java.util.concurrent.Future;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.examples.SendEmail;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.spring.SpringRouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.orm.jpa.JpaTemplate;
@@ -42,16 +43,18 @@
 /**
  * @version $Revision$
  */
-public class JpaProducerConcurrentTest extends ContextTestSupport {
+public class JpaProducerConcurrentTest extends CamelTestSupport {
     protected static final String SELECT_ALL_STRING = "select x from " + SendEmail.class.getName()
+ " x";
 
     protected ApplicationContext applicationContext;
     protected JpaTemplate jpaTemplate;
 
+    @Test
     public void testNoConcurrentProducers() throws Exception {
         doSendMessages(1, 1);
     }
 
+    @Test
     public void testConcurrentProducers() throws Exception {
         doSendMessages(10, 5);
     }

Modified: camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java?rev=785229&r1=785228&r2=785229&view=diff
==============================================================================
--- camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java
(original)
+++ camel/trunk/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java
Tue Jun 16 14:29:25 2009
@@ -19,12 +19,13 @@
 import java.util.List;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.examples.SendEmail;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.spring.SpringRouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.orm.jpa.JpaTemplate;
@@ -37,12 +38,13 @@
 /**
  * @version $Revision$
  */
-public class JpaRouteTest extends ContextTestSupport {
+public class JpaRouteTest extends CamelTestSupport {
     protected static final String SELECT_ALL_STRING = "select x from " + SendEmail.class.getName()
+ " x";
 
     protected ApplicationContext applicationContext;
     protected JpaTemplate jpaTemplate;
 
+    @Test
     public void testRouteJpa() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);



Mime
View raw message