You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Jan Bednar (JIRA)" <ji...@apache.org> on 2019/05/18 13:20:00 UTC

[jira] [Commented] (CAMEL-13540) isUseAdviceWith causes test to hang

    [ https://issues.apache.org/jira/browse/CAMEL-13540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16843160#comment-16843160 ] 

Jan Bednar commented on CAMEL-13540:
------------------------------------

Please read documentation : [https://camel.apache.org/advicewith.html]
{quote}It is recommended to override the method *{{isUseAdviceWith}}* and return *{{true}}* to instruct Camel that you are using *{{adviceWith}}* in the unit tests. Then in your unit test methods, after you have done the *{{adviceWith}}* you *must* start *{{CamelContext}}* by invoke the *{{start}}* method on the {{context}} instance.
{quote}
And JavaDoc:
{quote}*Important:* Its important to start CamelContext manually from the unit test after you are done doing all the advice with.
{quote}

> isUseAdviceWith causes test to hang
> -----------------------------------
>
>                 Key: CAMEL-13540
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13540
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-test
>    Affects Versions: 2.24.0
>            Reporter: Kamil
>            Priority: Major
>
> Having this test:
> {code:java}
> import org.apache.camel.CamelContext;
> 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.Test;
> public class MyRouteTest extends CamelTestSupport {
>   private static final String ROUTE_ID = "mytest";
>   @Override
>   public RoutesBuilder createRouteBuilder() throws Exception {
>     return new RouteBuilder() {
>       @Override
>       public void configure() throws Exception {
>         from("direct:mytest")
>           .id(ROUTE_ID)
>           .to("stream:out");
>       }
>     };
>   }
>   @Override
>   public void setUp() throws Exception {
>       super.setUp();
>       final CamelContext camelContext = context();
>       camelContext.getRouteDefinition(ROUTE_ID)
>         .adviceWith(camelContext, new AdviceWithRouteBuilder() {
>           @Override
>           public void configure() throws Exception {
>             weaveAddLast().to("mock:extract");
>           }
>         });
>   }
>   @Override
>   public boolean isUseAdviceWith() {
>       return true; // <- here is the problem
>   }
>   @Test
>   public void shouldFire() throws InterruptedException {
>     // given
>     final MockEndpoint myMock = getMockEndpoint("mock:extract");
>     myMock.expectedMessageCount(1);
>     myMock.expectedBodiesReceived("test");
>     // when
>     template.sendBody("direct:mytest", "test");
>     // then
>     myMock.assertIsSatisfied();
>   }
> }
> {code}
>  Causes Camel to hang



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)