camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1152623 - /camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/
Date Sun, 31 Jul 2011 20:06:53 GMT
Author: cmueller
Date: Sun Jul 31 20:06:50 2011
New Revision: 1152623

URL: http://svn.apache.org/viewvc?rev=1152623&view=rev
Log:
CAMEL-4239: Improve the VM component tests

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/AbstractVmTestSupport.java
      - copied, changed from r1152592, camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmRouteTest.java
Removed:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmRequestReplyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmRouteTest.java
Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmConcurrentConsumersTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmDifferentOptionsOnConsumerAndProducerTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyChainedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTimeoutTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutWithErrorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmQueueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmShouldNotUseSameThreadTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmTimeoutIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmUseSameQueueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskIfReplyExpectedTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskNewerTest.java

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/AbstractVmTestSupport.java
(from r1152592, camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmRouteTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/AbstractVmTestSupport.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/AbstractVmTestSupport.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmRouteTest.java&r1=1152592&r2=1152623&rev=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmRouteTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/AbstractVmTestSupport.java
Sun Jul 31 20:06:50 2011
@@ -17,55 +17,47 @@
 package org.apache.camel.component.vm;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.TestSupport;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.util.ServiceHelper;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * @version 
  */
-public class VmRouteTest extends TestSupport {
-    private CamelContext context1 = new DefaultCamelContext();
-    private CamelContext context2 = new DefaultCamelContext();
-    private ProducerTemplate template;
-    private Object expectedBody = "<hello>world!</hello>";
-
-    public void testSedaQueue() throws Exception {
-        MockEndpoint result = context2.getEndpoint("mock:result", MockEndpoint.class);
-        result.expectedBodiesReceived(expectedBody);
-
-        template.sendBody("vm:test.a", expectedBody);
-
-        result.assertIsSatisfied();
-    }
-
+public abstract class AbstractVmTestSupport extends ContextTestSupport {
+    
+    protected CamelContext context2;
+    protected ProducerTemplate template2;
+    
     @Override
+    @Before
     protected void setUp() throws Exception {
         super.setUp();
-
-        context1.addRoutes(new RouteBuilder() {
-            public void configure() {
-                from("vm:test.a").to("vm:test.b");
-            }
-        });
-
-        context2.addRoutes(new RouteBuilder() {
-            public void configure() {
-                from("vm:test.b").to("mock:result");
-            }
-        });
-
-        ServiceHelper.startServices(context1, context2);
-
-        template = context1.createProducerTemplate();
+        
+        context2 = new DefaultCamelContext();
+        RouteBuilder routeBuilder = createRouteBuilderForSecondContext();
+        if (routeBuilder != null) {
+            context2.addRoutes(routeBuilder);            
+        }
+        
+        template2 = context2.createProducerTemplate();
+        
+        ServiceHelper.startServices(template2, context2);
     }
-
+    
     @Override
+    @After
     protected void tearDown() throws Exception {
-        ServiceHelper.stopServices(context2, context1, template);
+        ServiceHelper.stopServices(context2, template2);
+        
         super.tearDown();
     }
+    
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return null;
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmConcurrentConsumersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmConcurrentConsumersTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmConcurrentConsumersTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmConcurrentConsumersTest.java
Sun Jul 31 20:06:50 2011
@@ -16,20 +16,19 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * @version 
  */
-public class VmConcurrentConsumersTest extends ContextTestSupport {
-
+public class VmConcurrentConsumersTest extends AbstractVmTestSupport {
+    
     public void testSendToSeda() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
 
-        template.sendBody("vm:foo?concurrentConsumers=5", "Hello World");
+        template2.sendBody("vm:foo?concurrentConsumers=5", "Hello World");
 
         assertMockEndpointsSatisfied();
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmDifferentOptionsOnConsumerAndProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmDifferentOptionsOnConsumerAndProducerTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmDifferentOptionsOnConsumerAndProducerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmDifferentOptionsOnConsumerAndProducerTest.java
Sun Jul 31 20:06:50 2011
@@ -16,50 +16,13 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.util.ServiceHelper;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 /**
  * @version 
  */
-public class VmDifferentOptionsOnConsumerAndProducerTest extends ContextTestSupport {
-    
-    private CamelContext context2;
-    private ProducerTemplate template2;
-    
-    @Override
-    @Before
-    protected void setUp() throws Exception {
-        super.setUp();
-        
-        context2 = new DefaultCamelContext();
-        context2.addRoutes(new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from("direct:start")
-                    .to("vm:foo");
-            }
-        });
-        
-        template2 = context2.createProducerTemplate();
-        
-        ServiceHelper.startServices(template2, context2);
-    }
-    
-    @Override
-    @After
-    protected void tearDown() throws Exception {
-        ServiceHelper.stopServices(context2, template2);
-        
-        super.tearDown();
-    }
+public class VmDifferentOptionsOnConsumerAndProducerTest extends AbstractVmTestSupport {
 
     @Test
     public void testSendToVm() throws Exception {
@@ -80,4 +43,15 @@ public class VmDifferentOptionsOnConsume
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("vm:foo");
+            }
+        };
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyChainedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyChainedTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyChainedTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyChainedTest.java
Sun Jul 31 20:06:50 2011
@@ -16,22 +16,23 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * @version 
  */
-public class VmInOnlyChainedTest extends ContextTestSupport {
+public class VmInOnlyChainedTest extends AbstractVmTestSupport {
 
     public void testInOnlyVmChained() throws Exception {
         getMockEndpoint("mock:a").expectedBodiesReceived("start");
-        getMockEndpoint("mock:b").expectedBodiesReceived("start-a");
+        resolveMandatoryEndpoint(context2, "mock:b", MockEndpoint.class).expectedBodiesReceived("start-a");
         getMockEndpoint("mock:c").expectedBodiesReceived("start-a-b");
 
         template.sendBody("vm:a", "start");
 
         assertMockEndpointsSatisfied();
+        MockEndpoint.assertIsSatisfied(context2);
     }
 
     @Override
@@ -41,10 +42,18 @@ public class VmInOnlyChainedTest extends
             public void configure() throws Exception {
                 from("vm:a").to("mock:a").setBody(simple("${body}-a")).to("vm:b");
 
-                from("vm:b").to("mock:b").setBody(simple("${body}-b")).to("vm:c");
-
                 from("vm:c").to("mock:c").setBody(simple("${body}-c"));
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("vm:b").to("mock:b").setBody(simple("${body}-b")).to("vm:c");
+            }
+        };
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOnlyTest.java Sun
Jul 31 20:06:50 2011
@@ -16,18 +16,17 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 
 /**
  * @version 
  */
-public class VmInOnlyTest extends ContextTestSupport {
+public class VmInOnlyTest extends AbstractVmTestSupport {
 
     public void testInOnly() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
 
-        template.sendBody("direct:start", "Hello World");
+        template2.sendBody("direct:start", "Hello World");
 
         assertMockEndpointsSatisfied();
     }
@@ -37,10 +36,18 @@ public class VmInOnlyTest extends Contex
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("vm:foo");
-
                 from("vm:foo").to("mock:result");
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("vm:foo");
+            }
+        };
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTest.java
Sun Jul 31 20:06:50 2011
@@ -16,20 +16,20 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * @version 
  */
-public class VmInOutChainedTest extends ContextTestSupport {
+public class VmInOutChainedTest extends AbstractVmTestSupport {
 
     public void testInOutVmChained() throws Exception {
         getMockEndpoint("mock:a").expectedBodiesReceived("start");
-        getMockEndpoint("mock:b").expectedBodiesReceived("start-a");
+        resolveMandatoryEndpoint(context2, "mock:b", MockEndpoint.class).expectedBodiesReceived("start-a");
         getMockEndpoint("mock:c").expectedBodiesReceived("start-a-b");
 
-        String reply = template.requestBody("vm:a", "start", String.class);
+        String reply = template2.requestBody("vm:a", "start", String.class);
         assertEquals("start-a-b-c", reply);
 
         assertMockEndpointsSatisfied();
@@ -42,10 +42,18 @@ public class VmInOutChainedTest extends 
             public void configure() throws Exception {
                 from("vm:a").to("mock:a").transform(simple("${body}-a")).to("vm:b");
 
-                from("vm:b").to("mock:b").transform(simple("${body}-b")).to("vm:c");
-
                 from("vm:c").to("mock:c").transform(simple("${body}-c"));
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("vm:b").to("mock:b").transform(simple("${body}-b")).to("vm:c");
+            }
+        };
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTimeoutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTimeoutTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTimeoutTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutChainedTimeoutTest.java
Sun Jul 31 20:06:50 2011
@@ -17,7 +17,6 @@
 package org.apache.camel.component.vm;
 
 import org.apache.camel.CamelExecutionException;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.ExchangeTimedOutException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.StopWatch;
@@ -25,18 +24,20 @@ import org.apache.camel.util.StopWatch;
 /**
  * @version 
  */
-public class VmInOutChainedTimeoutTest extends ContextTestSupport {
+public class VmInOutChainedTimeoutTest extends AbstractVmTestSupport {
 
     public void testVmInOutChainedTimeout() throws Exception {
         StopWatch watch = new StopWatch();
+        
         try {
-            template.requestBody("vm:a?timeout=1000", "Hello World");
+            template2.requestBody("vm:a?timeout=1000", "Hello World");
             fail("Should have thrown an exception");
         } catch (CamelExecutionException e) {
             // the chained vm caused the timeout
             ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class,
e.getCause());
             assertEquals(200, cause.getTimeout());
         }
+        
         long delta = watch.stop();
 
         assertTrue("Should be faster than 1 sec, was: " + delta, delta < 1100);
@@ -47,14 +48,6 @@ public class VmInOutChainedTimeoutTest e
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                errorHandler(noErrorHandler());
-
-                from("vm:a")
-                        .to("mock:a")
-                        // this timeout will trigger an exception to occur
-                        .to("vm:b?timeout=200")
-                        .to("mock:a2");
-
                 from("vm:b")
                         .to("mock:b")
                         .delay(500)
@@ -62,4 +55,20 @@ public class VmInOutChainedTimeoutTest e
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(noErrorHandler());
+                
+                from("vm:a")
+                    .to("mock:a")
+                    // this timeout will trigger an exception to occur
+                    .to("vm:b?timeout=200")
+                    .to("mock:a2");
+            }
+        };
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutTest.java Sun
Jul 31 20:06:50 2011
@@ -16,18 +16,17 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 
 /**
  * @version 
  */
-public class VmInOutTest extends ContextTestSupport {
+public class VmInOutTest extends AbstractVmTestSupport {
 
     public void testInOut() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
 
-        String out = template.requestBody("direct:start", "Hello World", String.class);
+        String out = template2.requestBody("direct:start", "Hello World", String.class);
         assertEquals("Bye World", out);
 
         assertMockEndpointsSatisfied();
@@ -38,10 +37,18 @@ public class VmInOutTest extends Context
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("vm:foo");
-
                 from("vm:foo").transform(constant("Bye World")).to("mock:result");
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("vm:foo");
+            }
+        };
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutWithErrorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutWithErrorTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutWithErrorTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmInOutWithErrorTest.java
Sun Jul 31 20:06:50 2011
@@ -17,19 +17,18 @@
 package org.apache.camel.component.vm;
 
 import org.apache.camel.CamelExecutionException;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 
 /**
  * @version 
  */
-public class VmInOutWithErrorTest extends ContextTestSupport {
+public class VmInOutWithErrorTest extends AbstractVmTestSupport {
 
     public void testInOutWithError() throws Exception {
         getMockEndpoint("mock:result").expectedMessageCount(0);
 
         try {
-            template.requestBody("direct:start", "Hello World", String.class);
+            template2.requestBody("direct:start", "Hello World", String.class);
             fail("Should have thrown an exception");
         } catch (CamelExecutionException e) {
             assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
@@ -44,12 +43,20 @@ public class VmInOutWithErrorTest extend
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("vm:foo");
-
                 from("vm:foo").transform(constant("Bye World"))
                     .throwException(new IllegalArgumentException("Damn I cannot do this"))
                     .to("mock:result");
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("vm:foo");
+            }
+        };
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmQueueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmQueueTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmQueueTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmQueueTest.java Sun
Jul 31 20:06:50 2011
@@ -16,22 +16,21 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * @version 
  */
-public class VmQueueTest extends ContextTestSupport {
+public class VmQueueTest extends AbstractVmTestSupport {
 
     public void testQueue() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World", "Goodday World",
"Bar");
 
-        template.sendBody("vm:foo", "Hello World");
-        template.sendBody("vm:foo?size=20", "Bye World");
-        template.sendBody("vm:foo?concurrentConsumers=5", "Goodday World");
+        template2.sendBody("vm:foo", "Hello World");
+        template2.sendBody("vm:foo?size=20", "Bye World");
+        template2.sendBody("vm:foo?concurrentConsumers=5", "Goodday World");
         template.sendBody("vm:bar", "Bar");
     }
 
@@ -40,11 +39,18 @@ public class VmQueueTest extends Context
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("vm:foo?concurrentConsumers=2").to("mock:result");
-
                 from("vm:bar").to("mock:result");
             }
         };
     }
 
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("vm:foo?concurrentConsumers=2").to("mock:result");
+            }
+        };
+    }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmShouldNotUseSameThreadTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmShouldNotUseSameThreadTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmShouldNotUseSameThreadTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmShouldNotUseSameThreadTest.java
Sun Jul 31 20:06:50 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
@@ -25,15 +24,16 @@ import org.apache.camel.component.mock.M
 /**
  * Unit test to verify continuing using NOT same thread on the consumer side.
  */
-public class VmShouldNotUseSameThreadTest extends ContextTestSupport {
+public class VmShouldNotUseSameThreadTest extends AbstractVmTestSupport {
 
     private static long id;
+    private final ThreadLocal<String> local = new ThreadLocal<String>();
 
     public void testNotUseSameThread() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
 
-        template.sendBody("direct:start", "Hello World");
+        template2.sendBody("direct:start", "Hello World");
 
         assertMockEndpointsSatisfied();
     }
@@ -41,23 +41,28 @@ public class VmShouldNotUseSameThreadTes
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                final ThreadLocal<String> local = new ThreadLocal<String>();
+                from("vm:foo").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        assertNull(local.get());
+                        assertNotSame("Thread is should not be same", id, Thread.currentThread().getId());
+                    }
+                }).to("mock:result");
+            }
+        };
+    }
 
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
                 from("direct:start").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         local.set("Hello");
                         id = Thread.currentThread().getId();
                     }
                 }).to("vm:foo");
-
-                from("vm:foo").process(new Processor() {
-                    public void process(Exchange exchange) throws Exception {
-                        assertEquals(null, local.get());
-                        assertNotSame("Thread is should not be same", id, Thread.currentThread().getId());
-                    }
-                }).to("mock:result");
             }
         };
     }
-
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmTimeoutIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmTimeoutIssueTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmTimeoutIssueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmTimeoutIssueTest.java
Sun Jul 31 20:06:50 2011
@@ -17,7 +17,6 @@
 package org.apache.camel.component.vm;
 
 import org.apache.camel.CamelExecutionException;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangeTimedOutException;
 import org.apache.camel.Processor;
@@ -26,11 +25,11 @@ import org.apache.camel.builder.RouteBui
 /**
  * @version 
  */
-public class VmTimeoutIssueTest extends ContextTestSupport {
+public class VmTimeoutIssueTest extends AbstractVmTestSupport {
 
     public void testVmTimeoutWithAnotherVm() throws Exception {
         try {
-            template.requestBody("vm:start1?timeout=4000", "Hello");
+            template2.requestBody("vm:start1?timeout=4000", "Hello");
             fail("Should have thrown an exception");
         } catch (CamelExecutionException e) {
             ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class,
e.getCause());
@@ -40,7 +39,7 @@ public class VmTimeoutIssueTest extends 
 
     public void testVmTimeoutWithProcessor() throws Exception {
         try {
-            template.requestBody("vm:start2?timeout=4000", "Hello");
+            template2.requestBody("vm:start2?timeout=4000", "Hello");
             fail("Should have thrown an exception");
         } catch (CamelExecutionException e) {
             ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class,
e.getCause());
@@ -53,27 +52,34 @@ public class VmTimeoutIssueTest extends 
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
+                from("vm:end")
+                    .delay(3000).transform().constant("Bye World");
+            }
+        };
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
                 errorHandler(noErrorHandler());
 
                 from("vm:start1?timeout=4000")
-                        .to("log:AFTER_START1")
-                        .to("vm:end?timeout=2000")
-                        .to("log:AFTER_END");
+                    .to("log:AFTER_START1")
+                    .to("vm:end?timeout=2000")
+                    .to("log:AFTER_END");
 
                 from("vm:start2?timeout=4000")
-                        .to("log:AFTER_START2")
-                        .process(new Processor() {
-                            public void process(Exchange exchange) throws Exception {
-                                // this exception will trigger to stop asap
-                                throw new ExchangeTimedOutException(exchange, 2000);
-                            }
-                        })
-                        .to("log:AFTER_PROCESSOR");
-
-                from("vm:end")
-                    .delay(3000).transform().constant("Bye World");
+                    .to("log:AFTER_START2")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            // this exception will trigger to stop asap
+                            throw new ExchangeTimedOutException(exchange, 2000);
+                        }
+                    })
+                    .to("log:AFTER_PROCESSOR");
             }
         };
     }
-
-}
+}
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmUseSameQueueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmUseSameQueueTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmUseSameQueueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmUseSameQueueTest.java
Sun Jul 31 20:06:50 2011
@@ -16,19 +16,18 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 
 /**
  * @version 
  */
-public class VmUseSameQueueTest extends ContextTestSupport {
+public class VmUseSameQueueTest extends AbstractVmTestSupport {
 
     public void testVmUseSameQueue() throws Exception {
         getMockEndpoint("mock:result").expectedMessageCount(2);
 
-        template.sendBody("direct:start", "Hello World");
-        template.sendBody("direct:start", "Bye World");
+        template2.sendBody("direct:start", "Hello World");
+        template2.sendBody("direct:start", "Bye World");
 
         assertMockEndpointsSatisfied();
     }
@@ -38,11 +37,18 @@ public class VmUseSameQueueTest extends 
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start")
-                    .to("vm:foo?size=500");
-
                 from("vm:foo").to("mock:result");
             }
         };
     }
-}
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("vm:foo?size=500");
+            }
+        };
+    }
+}
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskCompleteTest.java
Sun Jul 31 20:06:50 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
@@ -25,12 +24,12 @@ import org.apache.camel.builder.RouteBui
 /**
  * @version 
  */
-public class VmWaitForTaskCompleteTest extends ContextTestSupport {
+public class VmWaitForTaskCompleteTest extends AbstractVmTestSupport {
 
     public void testInOut() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
 
-        String out = template.requestBody("direct:start", "Hello World", String.class);
+        String out = template2.requestBody("direct:start", "Hello World", String.class);
         assertEquals("Bye World", out);
 
         assertMockEndpointsSatisfied();
@@ -41,7 +40,7 @@ public class VmWaitForTaskCompleteTest e
 
         // we send an in only but we use Always to wait for it to complete
         // and since the route changes the payload we can get the response anyway
-        Exchange out = template.send("direct:start", new Processor() {
+        Exchange out = template2.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
                 exchange.getIn().setBody("Hello World");
                 exchange.setPattern(ExchangePattern.InOnly);
@@ -57,10 +56,18 @@ public class VmWaitForTaskCompleteTest e
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("vm:foo?waitForTaskToComplete=Always");
-
                 from("vm:foo?waitForTaskToComplete=Always").transform(constant("Bye World")).to("mock:result");
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("vm:foo?waitForTaskToComplete=Always");
+            }
+        };
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskIfReplyExpectedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskIfReplyExpectedTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskIfReplyExpectedTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskIfReplyExpectedTest.java
Sun Jul 31 20:06:50 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
@@ -25,12 +24,12 @@ import org.apache.camel.builder.RouteBui
 /**
  * @version 
  */
-public class VmWaitForTaskIfReplyExpectedTest extends ContextTestSupport {
+public class VmWaitForTaskIfReplyExpectedTest extends AbstractVmTestSupport {
 
     public void testInOut() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
 
-        String out = template.requestBody("direct:start", "Hello World", String.class);
+        String out = template2.requestBody("direct:start", "Hello World", String.class);
         assertEquals("Bye World", out);
 
         assertMockEndpointsSatisfied();
@@ -39,7 +38,7 @@ public class VmWaitForTaskIfReplyExpecte
     public void testInOnly() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
 
-        Exchange out = template.send("direct:start", new Processor() {
+        Exchange out = template2.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
                 exchange.getIn().setBody("Hello World");
                 exchange.setPattern(ExchangePattern.InOnly);
@@ -47,7 +46,7 @@ public class VmWaitForTaskIfReplyExpecte
         });
         // we do not expecy a reply and thus do no wait so we just get our own input back
         assertEquals("Hello World", out.getIn().getBody());
-        assertEquals(null, out.getOut().getBody());
+        assertNull(out.getOut().getBody());
 
         assertMockEndpointsSatisfied();
     }
@@ -57,10 +56,18 @@ public class VmWaitForTaskIfReplyExpecte
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("vm:foo?waitForTaskToComplete=IfReplyExpected");
-
                 from("vm:foo?waitForTaskToComplete=IfReplyExpected").transform(constant("Bye
World")).to("mock:result");
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("vm:foo?waitForTaskToComplete=IfReplyExpected");
+            }
+        };
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskNewerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskNewerTest.java?rev=1152623&r1=1152622&r2=1152623&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskNewerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/vm/VmWaitForTaskNewerTest.java
Sun Jul 31 20:06:50 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.vm;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
@@ -25,12 +24,12 @@ import org.apache.camel.builder.RouteBui
 /**
  * @version 
  */
-public class VmWaitForTaskNewerTest extends ContextTestSupport {
+public class VmWaitForTaskNewerTest extends AbstractVmTestSupport {
 
     public void testInOut() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
 
-        String out = template.requestBody("direct:start", "Hello World", String.class);
+        String out = template2.requestBody("direct:start", "Hello World", String.class);
         // we do not wait for the response so we just get our own input back
         assertEquals("Hello World", out);
 
@@ -40,7 +39,7 @@ public class VmWaitForTaskNewerTest exte
     public void testInOnly() throws Exception {
         getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
 
-        Exchange out = template.send("direct:start", new Processor() {
+        Exchange out = template2.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
                 exchange.getIn().setBody("Hello World");
                 exchange.setPattern(ExchangePattern.InOnly);
@@ -48,7 +47,7 @@ public class VmWaitForTaskNewerTest exte
         });
         // we do not wait for the response so we just get our own input back
         assertEquals("Hello World", out.getIn().getBody());
-        assertEquals(null, out.getOut().getBody());
+        assertNull(out.getOut().getBody());
 
         assertMockEndpointsSatisfied();
     }
@@ -58,10 +57,18 @@ public class VmWaitForTaskNewerTest exte
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("vm:foo?waitForTaskToComplete=Never");
-
                 from("vm:foo?waitForTaskToComplete=Never").transform(constant("Bye World")).to("mock:result");
             }
         };
     }
+    
+    @Override
+    protected RouteBuilder createRouteBuilderForSecondContext() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("vm:foo?waitForTaskToComplete=Never");
+            }
+        };
+    }
 }
\ No newline at end of file



Mime
View raw message