OK. Ending the wire tap works. I.e. doing

.wireTap("direct:null").end()

instead of

.wireTap("direct:null")



On Sat, Aug 3, 2019 at 12:02 AM Sebastian Czort <scz...@gmail.com> wrote:

> Hi,
>
> Is there an issue when calling id() after a bean() call after a wireTap()
> call when configuring routes?
>
> It looks like the ID gets set on the WireTapDefinition instead of on the
> BeanDefinition, which is illustrated by the failing test below.
>
> Is there a preferred workaround for mocking a bean out in a test under
> this scenario?
>
> public class WeaveByIdTest extends CamelTestSupport {
>
>     @Override
>     public boolean isUseAdviceWith() {
>         // remember to override this method and return true to tell Camel
> that we are using advice-with in the routes
>         return true;
>     }
>
>     @Test
>     public void testWeaveById() throws Exception {
>         RouteDefinition route = context.getRouteDefinition("quotes");
>         route.adviceWith(context, new AdviceWithRouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 // select the route node with the id=transform
>                 // and then replace it with the following route parts
>                 weaveById("transform").replace()
>                     .transform().simple("${body.toUpperCase()}");
>
>                 // and add at the end of the route to route to this mock
> endpoint
>                 weaveAddLast().to("mock:result");
>             }
>         });
>
>         context.start();
>
>         // we have replaced the bean transformer call with a simple
> expression that
>         // performs an upper case
>         getMockEndpoint("mock:result").expectedBodiesReceived("HELLO
> CAMEL");
>
>         template.sendBody("seda:quotes", "Hello Camel");
>
>         assertMockEndpointsSatisfied();
>     }
>
>     @Override
>     protected RoutesBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from("seda:quotes").routeId("quotes")
>                         // wire tap appears to get id == "transform"
> rather than bean
>                         .wireTap("direct:null")
>                         .bean("transformer").id("transform")
>                         .to("seda:lower");
>
>                 from("direct:null")
>                         .log("null");
>             }
>         };
>     }
> }
>

Reply via email to