camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject [4/4] git commit: simplified the unit test by using CamelSpringTestSupport
Date Sat, 25 May 2013 16:09:11 GMT
simplified the unit test by using CamelSpringTestSupport


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d3dcf50f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d3dcf50f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d3dcf50f

Branch: refs/heads/camel-2.11.x
Commit: d3dcf50f463fdcc28bdecf27968b1e15eca81dd4
Parents: 93f717c
Author: cmueller <cmueller@apache.org>
Authored: Sat May 25 17:41:45 2013 +0200
Committer: cmueller <cmueller@apache.org>
Committed: Sat May 25 18:07:26 2013 +0200

----------------------------------------------------------------------
 .../spring/batch/SpringBatchIntegrationTest.java   |   32 +++++++-------
 1 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d3dcf50f/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
index 12e9f80..77e3ad2 100644
--- a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
+++ b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
@@ -16,35 +16,30 @@
  */
 package org.apache.camel.component.spring.batch;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
+import org.apache.camel.EndpointInject;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
 import org.junit.Before;
 import org.junit.Test;
-import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class SpringBatchIntegrationTest {
-
-    ApplicationContext applicationContext;
-
-    ProducerTemplate producerTemplate;
+public class SpringBatchIntegrationTest extends CamelSpringTestSupport {
 
+    @EndpointInject(uri = "mock:output")
     MockEndpoint outputEndpoint;
 
+    @EndpointInject(uri = "mock:jobExecutionEventsQueue")
     MockEndpoint jobExecutionEventsQueueEndpoint;
 
     String[] inputMessages = new String[]{"foo", "bar", "baz", null};
 
     @Before
-    public void setUp() {
-        applicationContext = new ClassPathXmlApplicationContext("classpath:org/apache/camel/component/spring/batch/springBatchtestContext.xml");
-        producerTemplate = applicationContext.getBean(ProducerTemplate.class);
-        outputEndpoint = applicationContext.getBean(CamelContext.class).getEndpoint("mock:output",
MockEndpoint.class);
-        jobExecutionEventsQueueEndpoint = applicationContext.getBean(CamelContext.class).getEndpoint("mock:jobExecutionEventsQueue",
MockEndpoint.class);
+    public void setUp() throws Exception {
+        super.setUp();
 
         for (String message : inputMessages) {
-            producerTemplate.sendBody("seda:inputQueue", message);
+            template.sendBody("seda:inputQueue", message);
         }
     }
 
@@ -52,7 +47,7 @@ public class SpringBatchIntegrationTest {
     public void shouldEchoInBatch() throws InterruptedException {
         outputEndpoint.expectedBodiesReceived("Echo foo", "Echo bar", "Echo baz");
 
-        producerTemplate.sendBody("direct:start", "Start batch!");
+        template.sendBody("direct:start", "Start batch!");
 
         outputEndpoint.assertIsSatisfied();
     }
@@ -61,8 +56,13 @@ public class SpringBatchIntegrationTest {
     public void shouldGenerateBatchExecutionEvents() throws InterruptedException {
         jobExecutionEventsQueueEndpoint.setExpectedMessageCount(2);
 
-        producerTemplate.sendBody("direct:start", "Start batch!");
+        template.sendBody("direct:start", "Start batch!");
 
         jobExecutionEventsQueueEndpoint.assertIsSatisfied();
     }
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/spring/batch/springBatchtestContext.xml");
+    }
 }


Mime
View raw message