camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shyenuganti <shyenuga...@gmail.com>
Subject Questions about testing came routes
Date Mon, 25 Feb 2013 22:51:56 GMT
I am going through this example in the documentation:

http://camel.apache.org/camel-test.html
public class FilterTest extends CamelTestSupport {

    @EndpointInject(uri = "mock:result")
    protected MockEndpoint resultEndpoint;

    @Produce(uri = "direct:start")
    protected ProducerTemplate template;

    @Test
    public void testSendMatchingMessage() throws Exception {
        String expectedBody = "<matched/>";
        resultEndpoint.expectedBodiesReceived(expectedBody);
        template.sendBodyAndHeader(expectedBody, "foo", "bar");
        resultEndpoint.assertIsSatisfied();
    }

    @Test
    public void testSendNotMatchingMessage() throws Exception {
        resultEndpoint.expectedMessageCount(0);
        template.sendBodyAndHeader("<notMatched/>", "foo",
"notMatchedHeaderValue");
        resultEndpoint.assertIsSatisfied();
    }

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
               
from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
            }
        };
    }
}



In this test, we are testing a route 
"from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result")". 

But in the test class, we are overriding the RouteBuilder to insert a copy
of our prodcution route into the context which replaces the original
production route for the sake of testing. 

This test works fine here. But I have a question. 

If the original production route is changed, that changes will not be
reflected in our test route as we are duplicating the whole route in the
unit test. Then, the unit test will never fail even if we delete the
original route itself and this test will never fail. 

We use a test to check for any discrepancies in our routes. If the test
never fails even if change the production route, what is the use of having
this test in the first place? Am I missing anything in this whole concept.
Can anyone help me to understand this camel route testing?

Thank you.





--
View this message in context: http://camel.465427.n5.nabble.com/Questions-about-testing-came-routes-tp5728132.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message