Hi,

I'm trying to test a route that has a error handler installed and I cannot find 
a way to replace an enpoint (in the error handler) for which I do not have a 
component in my unit test.

I chose a strategy to test an existing (final) route and modify it (using 
weaving) in the unit test in a way that allows me to test a given 
feature/functionality.


The contents of the route builder's configure method are like the following 
(that's of course just a simplification of my code).

public void configure() throws Exception {
    errorHandler(deadLetterChannel("oaq:queue:ERROR"));

    from("oaq:queue:{{inputQueue}}")
        .to("xslt:someXslFile.xsl")
        .to("oaq:queue:{{outputQueue}}").id("outputQueueId");
}

and my test is as follows:

public void regularForeignTransferToBeWrittenToDB() throws Exception {
    camelContext.getRouteDefinition("handleForeignTransfers")
        .adviceWith(camelContext, new AdviceWithRouteBuilder() {
                                
              @Override
              public void configure() throws Exception {
                  replaceFromWith("direct:start");
                  weaveById("outputQueueId").replace().to("mock:queue");
              }
              camelContext.start();

              // producer.sendBodyAndHeaders(input, headers);   send some input

              // make some assertions
}

It works fine if I comment out the invocation of "errorHandler" method.

I'd rather not have the "oaq" component - I'd like to replace it on the fly in 
my test method. If I have to I'll install a mock compenent for "oaq" namespace.

Is there a way to "weave" changes into the error handler or a way of replacing 
the error handler's enpoint uri before the route is actually created in such a 
scenario?


Regards,
Tom

Reply via email to