Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 77C05200C5B for ; Thu, 27 Apr 2017 13:15:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 76713160BA7; Thu, 27 Apr 2017 11:15:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 96749160B98 for ; Thu, 27 Apr 2017 13:15:47 +0200 (CEST) Received: (qmail 49745 invoked by uid 500); 27 Apr 2017 11:15:46 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 49734 invoked by uid 99); 27 Apr 2017 11:15:46 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Apr 2017 11:15:46 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id E5A36C074C for ; Thu, 27 Apr 2017 11:15:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.314 X-Spam-Level: ** X-Spam-Status: No, score=2.314 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 0IapAlTjB42S for ; Thu, 27 Apr 2017 11:15:44 +0000 (UTC) Received: from mwork.nabble.com (mwork.nabble.com [162.253.133.43]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 167C95FC1C for ; Thu, 27 Apr 2017 11:15:43 +0000 (UTC) Received: from static.162.255.23.22.macminivault.com (unknown [162.255.23.22]) by mwork.nabble.com (Postfix) with ESMTP id 98C9E3D1C8053 for ; Thu, 27 Apr 2017 04:15:43 -0700 (MST) Date: Thu, 27 Apr 2017 04:15:43 -0700 (MST) From: owain To: users@camel.apache.org Message-ID: <1493291743620-5798402.post@n5.nabble.com> Subject: 2.18.3 - Rest DSL MockEndpoint - second unit test weaveByToUri fails with "no output which matches: direct:RouteB in the Route(getRoute) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit archived-at: Thu, 27 Apr 2017 11:15:48 -0000 I have discovered an issue when I run multiple tests on a route using weaveByToUri on the same endpoint. I have it replicated in my sample app. https://github.com/owain68/camel-spring-boot-examples It looks as though the .replace() replaces the endpoint for the whole test class, not just the individual test. Each test passes individually but mockTestOneNotFound() fails when both are run together. If I comment out the weaveByToUri in mockTestOneNotFound() then both tests pass when run together. Is this something to do with the routes being generated by Rest DSL and then not being regenerated for each test? I can't think of anything else. The route is. RestRoute @Override public void configure() throws Exception { rest("/") .get("{body}") .id("getRoute") .produces("application/json") .to("direct:RouteB"); } and the test class is: RestMockTests @RunWith(CamelSpringBootRunner.class) @MockEndpoints @UseAdviceWith @SpringBootTest(classes = mydomain.springbootcamel.SpringBootCamelExamples.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class RestMockTests { @Autowired private CamelContext camelContext; @Autowired private TestRestTemplate restTemplate; @Test public void mockTestOneNotFound() throws Exception { camelContext.getRouteDefinition("getRoute") .adviceWith(camelContext, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { // send the outgoing message to mock weaveByToUri("direct:RouteB").replace().inOut("mock:routeB"); } }); camelContext.start(); MockEndpoint mockOut = camelContext.getEndpoint("mock:routeB", MockEndpoint.class); mockOut.expectedMessageCount(0); ResponseEntity response = restTemplate.getForEntity("/dummy", String.class); mockOut.assertIsSatisfied(); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); } @Test public void mockTestTwoFound() throws Exception { camelContext.getRouteDefinition("getRoute") .adviceWith(camelContext, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { // send the outgoing message to mock weaveByToUri("direct:RouteB").replace().inOut("mock:routeB"); } }); camelContext.start(); MockEndpoint mockOut = camelContext.getEndpoint("mock:routeB", MockEndpoint.class); mockOut.expectedMessageCount(1); ResponseEntity response = restTemplate.getForEntity("/api/something", String.class); mockOut.assertIsSatisfied(); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); } } The error on the second test is: https://gist.github.com/owain68/58aa626ac4a17db3ce47dce21e7c12ab java.lang.IllegalArgumentException: There are no outputs which matches: direct:RouteB in the route: Route(getRoute)[[From[rest:get:/:{body}?routeId=getRoute&produces=application%2Fjson]] -> [RestBinding, pipeline -> [[To[mock:routeB]]]]] at org.apache.camel.builder.AdviceWithTasks$1.task(AdviceWithTasks.java:194) at org.apache.camel.model.RouteDefinition.adviceWith(RouteDefinition.java:280) at org.apache.camel.model.RouteDefinition.adviceWith(RouteDefinition.java:215) at mydomain.springbootcamel.RestMockTests.mockTestOneNotFound(RestMockTests.java:33) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) -- View this message in context: http://camel.465427.n5.nabble.com/2-18-3-Rest-DSL-MockEndpoint-second-unit-test-weaveByToUri-fails-with-no-output-which-matches-direct-tp5798402.html Sent from the Camel - Users mailing list archive at Nabble.com.