Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Cannot Reproduce
-
2.24.2, 3.0.0
-
None
-
None
-
Unknown
Description
This test pass only if i directly use out (MockEnpoint) and not out.getEndpointUri() or string representation but only when i use adviceWith (is weird because i was always doing that in past and never faced this situation)
package com.demo.camel; import org.apache.camel.EndpointInject; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.AdviceWithRouteBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Before; import org.junit.Test; public class AdviceWithFailTest extends CamelTestSupport { @EndpointInject(uri = "mock:out") private MockEndpoint out; @Override @Before public void setUp() throws Exception { super.setUp(); // Commenting this one or using out and not out.getEndpointUri() will make this test pass context.getRouteDefinition(out.getEndpointUri()).adviceWith(context, adviceWithRouteBuilder()); } @Override protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("timer:foo?repeatCount=1") .setBody(constant("test")) .routeId(out.getEndpointUri()) .to(out.getEndpointUri()); // Worked one is weird ! // .to(out); } }; } @Test public void test() throws InterruptedException { out.expectedMessageCount(1); out.assertIsSatisfied(); } private AdviceWithRouteBuilder adviceWithRouteBuilder() { return new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { weaveAddFirst().setBody(constant("test")); } }; } }
Is weird because before it fail i see this line in my log so it's mean that i get an exchange
2019-12-14 11:59:56,292 [3 - timer://foo] DEBUG SendProcessor - >>>> mock://out Exchange[ID-DESKTOP-S8PM2C4-1576321194338-0-1] 2019-12-14 11:59:56,292 [3 - timer://foo] DEBUG MockEndpoint - mock://out >>>> 0 : Exchange[ID-DESKTOP-S8PM2C4-1576321194338-0-1] with body: test and headers:{breadcrumbId=ID-DESKTOP-S8PM2C4-1576321194338-0-1, firedTime=Sat Dec 14 11:59:56 CET 2019}
By little changing the route to
@Override protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("timer:foo?repeatCount=1") .setBody(constant("test")) .routeId(out.getEndpointUri()) .to("direct:glue"); from("direct:glue") .to(out.getEndpointUri()); } }; }
Will cause the test to pass so i think there is a bug here