You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Frank Dietrich <bi...@gmx.de> on 2016/02/21 19:29:23 UTC

strange behavior of CamelSpringTestSupport and adviceWith

Hello list,

I known (now) how correctly use adviceWith. But during solving some
initial problems I step over a case which at least behave in a
unexpected way.

- in the XML Spring configuration I have two routes

  <route id="routeOne">
      <from uri="direct:startOne"/>
      <to uri="mock:result"/>
  </route>
  <route id="routeTwo">
      <from uri="direct:startTwo"/>
      <to uri="mock:result"/>
  </route>

- the unit test class extends CamelSpringTestSupport and the route
  start and end are declared as
    @Produce(uri = "direct:start")
    private ProducerTemplate start;
    @EndpointInject(uri = "mock:result")
    private MockEndpoint mockResult;
- in the test only route "routeTwo" is used
- in the configure() of an implemented AdviceWithRouteBuilder
  the start of route "routeTwo" is overriden
  using replaceFromWith("direct:start");
- the test doesn't override the method isUseAdviceWith() and do not
  start the Camel context with context().start()

As long the routes "routeOne" and "routeTwo" are in the Spring
configuration file the message is sent to the endpoint referenced
by "mockResult" and test finishes successful.

If the route "routeOne" is removed from the configuration file than
the test fails. But in the debug output I can see that the route
definition is as expected, the message is sent but not to the
endpoint referenced by "mockResult".

Is this a bug which should be reported? At least I don't see why
having an additional route defined to the same endpoint let the test
finish successful. Shouldn't it fail in both cases?

PS: I know that I have to override the method "isUseAdviceWith()" and
have to start the Camel context with "context().start()". So that's not
the meaning of my question. ;-)

cheers
Frank
--