activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r530740 - in /activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor: ChoiceTest.java FilterTest.java IdempotentConsumerTest.java JoinRoutesTest.java MulticastTest.java PipelineTest.java SplitterTest.java
Date Fri, 20 Apr 2007 11:01:54 GMT
Author: jstrachan
Date: Fri Apr 20 04:01:53 2007
New Revision: 530740

URL: http://svn.apache.org/viewvc?view=rev&rev=530740
Log:
minor refactor to use  ContextTestSupport more to simplify the testing code further &
make it a little easier to read

Modified:
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/JoinRoutesTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java?view=diff&rev=530740&r1=530739&r2=530740
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java
Fri Apr 20 04:01:53 2007
@@ -86,9 +86,9 @@
 
         startEndpoint = resolveMandatoryEndpoint("direct:a");
 
-        x = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:x");
-        y = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:y");
-        z = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:z");
+        x = (MockEndpoint) resolveMandatoryEndpoint("mock:x");
+        y = (MockEndpoint) resolveMandatoryEndpoint("mock:y");
+        z = (MockEndpoint) resolveMandatoryEndpoint("mock:z");
     }
 
     protected RouteBuilder createRouteBuilder() {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java?view=diff&rev=530740&r1=530739&r2=530740
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java
Fri Apr 20 04:01:53 2007
@@ -23,6 +23,7 @@
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.TestSupport;
+import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultCamelContext;
@@ -31,11 +32,9 @@
 /**
  * @version $Revision: 1.1 $
  */
-public class FilterTest extends TestSupport {
-    protected CamelContext context = new DefaultCamelContext();
+public class FilterTest extends ContextTestSupport {
     protected Endpoint<Exchange> startEndpoint;
     protected MockEndpoint resultEndpoint;
-    protected ProducerCache<Exchange> client = new ProducerCache<Exchange>();
 
     public void testSendMatchingMessage() throws Exception {
         resultEndpoint.expectedMessageCount(1);
@@ -55,12 +54,10 @@
 
     @Override
     protected void setUp() throws Exception {
-        context.addRoutes(createRouteBuilder());
+        super.setUp();
 
-        startEndpoint = resolveMandatoryEndpoint(context, "direct:a");
-        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:result");
-
-        context.start();
+        startEndpoint = resolveMandatoryEndpoint("direct:a");
+        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint("mock:result");
     }
 
     protected RouteBuilder createRouteBuilder() {
@@ -80,11 +77,5 @@
                 in.setHeader("foo", headerValue);
             }
         });
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        client.stop();
-        context.stop();
     }
 }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerTest.java?view=diff&rev=530740&r1=530739&r2=530740
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/IdempotentConsumerTest.java
Fri Apr 20 04:01:53 2007
@@ -23,6 +23,7 @@
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.TestSupport;
+import org.apache.camel.ContextTestSupport;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.DefaultCamelContext;
@@ -38,10 +39,7 @@
 /**
  * @version $Revision: 1.1 $
  */
-public class IdempotentConsumerTest extends TestSupport {
-    protected CamelContext context;
-    protected ProducerCache<Exchange> client = new ProducerCache<Exchange>();
-
+public class IdempotentConsumerTest extends ContextTestSupport {
     protected Endpoint<Exchange> startEndpoint;
     protected MockEndpoint resultEndpoint;
 
@@ -71,35 +69,17 @@
 
     @Override
     protected void setUp() throws Exception {
-        context = createContext();
-
-        String fromUri = "direct:test.a";
-        String toUri = "mock:result";
-
-        // lets add some routes
-        context.addRoutes(createRouteBuilder(fromUri, toUri));
+        super.setUp();
 
-        startEndpoint = resolveMandatoryEndpoint(context, fromUri);
-        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint(context, toUri);
-
-        context.start();
+        startEndpoint = resolveMandatoryEndpoint("direct:test.a");
+        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint("mock:result");
     }
 
-    protected CamelContext createContext() throws Exception {
-        return new DefaultCamelContext();
-    }
-
-    protected RouteBuilder createRouteBuilder(final String fromUri, final String toUri) {
+    protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from(fromUri).idempotentConsumer(header("messageId"), memoryMessageIdRepository()).to(toUri);
+                from("direct:test.a").idempotentConsumer(header("messageId"), memoryMessageIdRepository()).to("mock:result");
             }
         };
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        client.stop();
-        context.stop();
     }
 }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/JoinRoutesTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/JoinRoutesTest.java?view=diff&rev=530740&r1=530739&r2=530740
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/JoinRoutesTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/JoinRoutesTest.java
Fri Apr 20 04:01:53 2007
@@ -22,6 +22,7 @@
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.TestSupport;
+import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultCamelContext;
@@ -30,11 +31,9 @@
 /**
  * @version $Revision: 1.1 $
  */
-public class JoinRoutesTest extends TestSupport {
-    protected CamelContext context = new DefaultCamelContext();
+public class JoinRoutesTest extends ContextTestSupport {
     protected Endpoint<Exchange> startEndpoint;
     protected MockEndpoint resultEndpoint;
-    protected ProducerCache<Exchange> client = new ProducerCache<Exchange>();
 
     public void testMessagesThroughDifferentRoutes() throws Exception {
         resultEndpoint.expectedBodiesReceived("one", "two", "three");
@@ -59,12 +58,10 @@
 
     @Override
     protected void setUp() throws Exception {
-        context.addRoutes(createRouteBuilder());
+        super.setUp();
 
-        startEndpoint = resolveMandatoryEndpoint(context, "direct:a");
-        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:result");
-
-        context.start();
+        startEndpoint = resolveMandatoryEndpoint("direct:a");
+        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint("mock:result");
     }
 
     protected RouteBuilder createRouteBuilder() {
@@ -80,11 +77,5 @@
                 from("direct:d").to("mock:result");
             }
         };
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        client.stop();
-        context.stop();
     }
 }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastTest.java?view=diff&rev=530740&r1=530739&r2=530740
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastTest.java
Fri Apr 20 04:01:53 2007
@@ -53,9 +53,9 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        x = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:x");
-        y = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:y");
-        z = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:z");
+        x = (MockEndpoint) resolveMandatoryEndpoint("mock:x");
+        y = (MockEndpoint) resolveMandatoryEndpoint("mock:y");
+        z = (MockEndpoint) resolveMandatoryEndpoint("mock:z");
     }
 
     protected RouteBuilder createRouteBuilder() {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java?view=diff&rev=530740&r1=530739&r2=530740
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/PipelineTest.java
Fri Apr 20 04:01:53 2007
@@ -50,7 +50,7 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:result");
+        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint("mock:result");
     }
 
     protected RouteBuilder createRouteBuilder() {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java?view=diff&rev=530740&r1=530739&r2=530740
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
Fri Apr 20 04:01:53 2007
@@ -50,7 +50,7 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:result");
+        resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint("mock:result");
     }
 
     protected RouteBuilder createRouteBuilder() {



Mime
View raw message