13

I am doing java camel development and I want to unit test(junit4) a bunch of functions with Exchange being passed in as parameter.

For example :

public finalObject getProperty(final Exchange exchange, final String property) throws Exception {
   //all about getting property from xml message in exchange via xpath
}

Question: 1>Can I use EasyMock to mock Exchange ? And how to set a predefined xml as incoming message inside the exchange ?

2>If not do I need to setup camel test ? How to set a predefined xml as incoming message inside the exchange with camel test.

Thanks a lot.

4

1 回答 1

38

您还可以像这样创建一个新的默认交换:

    CamelContext ctx = new DefaultCamelContext(); 
    Exchange ex = new DefaultExchange(ctx);
于 2014-06-17T19:40:58.567 回答