camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: Lets avoid the mock endpoint in our production route in this example
Date Wed, 16 Dec 2015 15:55:30 GMT
Lets avoid the mock endpoint in our production route in this example


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

Branch: refs/heads/camel-2.16.x
Commit: ede3663e4494a71b182ae318a72afcbc79b64ab8
Parents: dc47b6b
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Dec 16 16:54:50 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Dec 16 16:55:20 2015 +0100

----------------------------------------------------------------------
 .../example/spring/boot/MySpringBootRouter.java   |  6 +++---
 .../spring/boot/MySpringBootRouterTest.java       | 18 ++++++++++++------
 2 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ede3663e/examples/camel-example-spring-boot/src/main/java/org/apache/camel/example/spring/boot/MySpringBootRouter.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot/src/main/java/org/apache/camel/example/spring/boot/MySpringBootRouter.java
b/examples/camel-example-spring-boot/src/main/java/org/apache/camel/example/spring/boot/MySpringBootRouter.java
index f1ebb57..c429d65 100644
--- a/examples/camel-example-spring-boot/src/main/java/org/apache/camel/example/spring/boot/MySpringBootRouter.java
+++ b/examples/camel-example-spring-boot/src/main/java/org/apache/camel/example/spring/boot/MySpringBootRouter.java
@@ -25,9 +25,9 @@ public class MySpringBootRouter extends FatJarRouter {
 
     @Override
     public void configure() {
-        from("timer://trigger").
-                transform().simple("ref:myBean").
-                to("log:out", "mock:test");
+        from("timer:trigger")
+                .transform().simple("ref:myBean")
+                .to("log:out");
     }
 
     @Bean

http://git-wip-us.apache.org/repos/asf/camel/blob/ede3663e/examples/camel-example-spring-boot/src/test/java/org/apache/camel/example/spring/boot/MySpringBootRouterTest.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot/src/test/java/org/apache/camel/example/spring/boot/MySpringBootRouterTest.java
b/examples/camel-example-spring-boot/src/test/java/org/apache/camel/example/spring/boot/MySpringBootRouterTest.java
index a11e4e2..91fc2aa 100644
--- a/examples/camel-example-spring-boot/src/test/java/org/apache/camel/example/spring/boot/MySpringBootRouterTest.java
+++ b/examples/camel-example-spring-boot/src/test/java/org/apache/camel/example/spring/boot/MySpringBootRouterTest.java
@@ -16,11 +16,14 @@
  */
 package org.apache.camel.example.spring.boot;
 
-import org.apache.camel.EndpointInject;
-import org.apache.camel.component.mock.MockEndpoint;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.NotifyBuilder;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.SpringApplicationConfiguration;
 import org.springframework.boot.test.WebIntegrationTest;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -30,13 +33,16 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 @WebIntegrationTest(randomPort = true)
 public class MySpringBootRouterTest extends Assert {
 
-    @EndpointInject(uri = "mock:test")
-    MockEndpoint mockEndpoint;
+    @Autowired
+    CamelContext camelContext;
 
     @Test
     public void shouldProduceMessages() throws InterruptedException {
-        mockEndpoint.setExpectedCount(1);
-        mockEndpoint.assertIsSatisfied();
+        // we expect that one or more messages is automatic done by the Camel
+        // route as it uses a timer to trigger
+        NotifyBuilder notify = new NotifyBuilder(camelContext).whenDone(1).create();
+
+        assertTrue(notify.matches(10, TimeUnit.SECONDS));
     }
 
 }


Mime
View raw message