You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Vincent Paturet (Jira)" <ji...@apache.org> on 2022/09/01 07:12:00 UTC
[jira] [Updated] (CAMEL-18446) Failure in adviced route in unit test
[ https://issues.apache.org/jira/browse/CAMEL-18446?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vincent Paturet updated CAMEL-18446:
------------------------------------
Description:
We experience a regression in unit tests when upgrading from Camel 3.18.0 to Camel 3.18.1:
Example project: [https://github.com/vpaturet/test-advice-unit-test]
The test passes with Camel 3.18.0 and fails with Camel 3.18.1
{code:java}
org.apache.camel.FailedToCreateRouteException: Failed to create route testedRoute at: >>> DoTry[[To[mock:testedSubRoute1], DoFinally[[To[direct:testedSubRoute2]]]]] <<< in route: Route(testedRoute)[From[direct:testedRoute] -> [DoTry[[To[mo... because of Multiple finally clauses added: DoFinally[[To[direct:testedSubRoute2]]] and DoFinally[[To[direct:testedSubRoute2]]] at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240) at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74) at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:862) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:750) at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2947) at org.apache.camel.support.service.BaseService.init(BaseService.java:83) at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2630) at org.apache.camel.support.service.BaseService.start(BaseService.java:111) at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2649) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262) at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:119) at org.test.route.MyRouteTest.testBugAdvice(MyRouteTest.java:38){code}
Route:
{code:java}
@Component
public class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() {
from("direct:testedRoute")
.doTry()
.to("direct:testedSubRoute1")
.doFinally()
.to("direct:testedSubRoute2")
.end()
.routeId("testedRoute");
from("direct:testedSubRoute1")
.log(LoggingLevel.INFO, "testedSubRoute1")
.routeId("testedSubRoute1");
from("direct:testedSubRoute2")
.log(LoggingLevel.INFO, "testedSubRoute2")
.routeId("testedSubRoute2");
}
}{code}
Unit test:
{code:java}
@CamelSpringBootTest
@UseAdviceWith
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = TestApp.class)
class MyRouteTest {
@Autowired
ModelCamelContext context;
@Produce("direct:testedRoute")
protected ProducerTemplate testedRoute;
@EndpointInject("mock:testedSubRoute1")
protected MockEndpoint testedSubRoute1;
@Test
void testBugAdvice() throws Exception {
AdviceWith.adviceWith(context, "testedRoute", a -> a.weaveByToUri("direct:testedSubRoute1").replace().to("mock:testedSubRoute1"));
testedSubRoute1.expectedMessageCount(1);
context.start();
testedRoute.requestBody(null);
testedSubRoute1.assertIsSatisfied();
}
}{code}
was:
We experience a regression in unit tests when upgrading from Camel 3.18.0 to Camel 3.18.1:
Example project: [https://github.com/vpaturet/test-advice-unit-test]
The test passes with Camel 3.18.0 and fails with Camel 3.18.1
{{}}
{code:java}
org.apache.camel.FailedToCreateRouteException: Failed to create route testedRoute at: >>> DoTry[[To[mock:testedSubRoute1], DoFinally[[To[direct:testedSubRoute2]]]]] <<< in route: Route(testedRoute)[From[direct:testedRoute] -> [DoTry[[To[mo... because of Multiple finally clauses added: DoFinally[[To[direct:testedSubRoute2]]] and DoFinally[[To[direct:testedSubRoute2]]] at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240) at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74) at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:862) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:750) at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2947) at org.apache.camel.support.service.BaseService.init(BaseService.java:83) at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2630) at org.apache.camel.support.service.BaseService.start(BaseService.java:111) at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2649) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262) at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:119) at org.test.route.MyRouteTest.testBugAdvice(MyRouteTest.java:38){code}
{{}}
Route:
{{}}
{{}}
{code:java}
@Component
public class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() {
from("direct:testedRoute")
.doTry()
.to("direct:testedSubRoute1")
.doFinally()
.to("direct:testedSubRoute2")
.end()
.routeId("testedRoute");
from("direct:testedSubRoute1")
.log(LoggingLevel.INFO, "testedSubRoute1")
.routeId("testedSubRoute1");
from("direct:testedSubRoute2")
.log(LoggingLevel.INFO, "testedSubRoute2")
.routeId("testedSubRoute2");
}
}{code}
{{}}
Unit test:
{{}}
{{}}
{{}}
{code:java}
@CamelSpringBootTest
@UseAdviceWith
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = TestApp.class)
class MyRouteTest {
@Autowired
ModelCamelContext context;
@Produce("direct:testedRoute")
protected ProducerTemplate testedRoute;
@EndpointInject("mock:testedSubRoute1")
protected MockEndpoint testedSubRoute1;
@Test
void testBugAdvice() throws Exception {
AdviceWith.adviceWith(context, "testedRoute", a -> a.weaveByToUri("direct:testedSubRoute1").replace().to("mock:testedSubRoute1"));
testedSubRoute1.expectedMessageCount(1);
context.start();
testedRoute.requestBody(null);
testedSubRoute1.assertIsSatisfied();
}
}{code}
{{}}
> Failure in adviced route in unit test
> -------------------------------------
>
> Key: CAMEL-18446
> URL: https://issues.apache.org/jira/browse/CAMEL-18446
> Project: Camel
> Issue Type: Bug
> Components: camel-test
> Affects Versions: 3.18.1
> Reporter: Vincent Paturet
> Priority: Major
>
> We experience a regression in unit tests when upgrading from Camel 3.18.0 to Camel 3.18.1:
> Example project: [https://github.com/vpaturet/test-advice-unit-test]
> The test passes with Camel 3.18.0 and fails with Camel 3.18.1
>
>
> {code:java}
> org.apache.camel.FailedToCreateRouteException: Failed to create route testedRoute at: >>> DoTry[[To[mock:testedSubRoute1], DoFinally[[To[direct:testedSubRoute2]]]]] <<< in route: Route(testedRoute)[From[direct:testedRoute] -> [DoTry[[To[mo... because of Multiple finally clauses added: DoFinally[[To[direct:testedSubRoute2]]] and DoFinally[[To[direct:testedSubRoute2]]] at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240) at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74) at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:862) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:750) at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2947) at org.apache.camel.support.service.BaseService.init(BaseService.java:83) at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2630) at org.apache.camel.support.service.BaseService.start(BaseService.java:111) at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2649) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262) at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:119) at org.test.route.MyRouteTest.testBugAdvice(MyRouteTest.java:38){code}
>
> Route:
>
> {code:java}
> @Component
> public class MyRouteBuilder extends RouteBuilder {
> @Override
> public void configure() {
> from("direct:testedRoute")
> .doTry()
> .to("direct:testedSubRoute1")
> .doFinally()
> .to("direct:testedSubRoute2")
> .end()
> .routeId("testedRoute");
> from("direct:testedSubRoute1")
> .log(LoggingLevel.INFO, "testedSubRoute1")
> .routeId("testedSubRoute1");
> from("direct:testedSubRoute2")
> .log(LoggingLevel.INFO, "testedSubRoute2")
> .routeId("testedSubRoute2");
> }
> }{code}
>
> Unit test:
>
> {code:java}
> @CamelSpringBootTest
> @UseAdviceWith
> @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = TestApp.class)
> class MyRouteTest {
> @Autowired
> ModelCamelContext context;
> @Produce("direct:testedRoute")
> protected ProducerTemplate testedRoute;
> @EndpointInject("mock:testedSubRoute1")
> protected MockEndpoint testedSubRoute1;
> @Test
> void testBugAdvice() throws Exception {
> AdviceWith.adviceWith(context, "testedRoute", a -> a.weaveByToUri("direct:testedSubRoute1").replace().to("mock:testedSubRoute1"));
> testedSubRoute1.expectedMessageCount(1);
> context.start();
> testedRoute.requestBody(null);
> testedSubRoute1.assertIsSatisfied();
> }
> }{code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)