[
https://issues.apache.org/jira/browse/CAMEL-14296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-14296.
---------------------------------
Resolution: Cannot Reproduce
On Camel 3
public class AdviceWithFailTest extends CamelTestSupport {
@EndpointInject("mock:out")
private MockEndpoint out;
@Override
public boolean isUseAdviceWith() {
return true;
}
@Override
@Before
public void setUp() throws Exception {
super.setUp();
}
@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());
}
};
}
@Test
public void test() throws Exception {
// Commenting this one or using out and not out.getEndpointUri() will
make this test pass
AdviceWithRouteBuilder.adviceWith(context, out.getEndpointUri(), rb -> {
rb.weaveAddFirst().setBody(constant("test"));
});
context.start();
out.expectedMessageCount(1);
out.assertIsSatisfied();
}
}
> Camel advice with
> -----------------
>
> Key: CAMEL-14296
> URL: https://issues.apache.org/jira/browse/CAMEL-14296
> Project: Camel
> Issue Type: Bug
> Components: camel-test
> Affects Versions: 2.24.2, 3.0.0
> Reporter: michael elbaz
> Priority: Major
> Attachments: camel-test-issue.zip
>
>
> 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)
> {code:java}
> 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"));
> }
> };
> }
> }
> {code}
> Is weird because before it fail i see this line in my log so it's mean that i
> get an exchange
> {code:java}
> 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}
> {code}
> By little changing the route to
> {code:java}
> @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());
> }
> };
> }
> {code}
> Will cause the test to pass so i think there is a bug here
--
This message was sent by Atlassian Jira
(v8.3.4#803005)