Repository: camel Updated Branches: refs/heads/camel-2.16.x dc47b6b52 -> ede3663e4 refs/heads/master 596346707 -> 8377a194a
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/8377a194 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8377a194 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8377a194 Branch: refs/heads/master Commit: 8377a194a7073b14eec943ee0486d68002570115 Parents: 5963467 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Dec 16 16:54:50 2015 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Dec 16 16:54:50 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/8377a194/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/8377a194/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)); } }