1
有沒有方法比較Camel Junit中的XML消息?Camel Junit中的XML消息比較
我使用下面的代碼:
@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:camel-context-test.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
@MockEndpoints("*")
public class CamelRoutesTest/* extends XMLTestCase */{
private static final Log LOG = LogFactory.getLog(CamelRoutesTest.class);
@Autowired
protected CamelContext camelContext;
@EndpointInject(uri = "mock:d2")
protected MockEndpoint direct1;
@Produce(uri = "direct:d1")
protected ProducerTemplate d1;
@Test
public void test1() throws Exception {
LOG.info("Starting testTradeSaveToPL test");
//node1 comes BEFORE node2
String sendMsg = "<test><node1>1</node1><node2>2</node2></test>";
//node1 comes AFTER node2
String valMsg1 = "<test><node2>2</node2><node1>1</node1></test>";
direct1.expectedBodiesReceivedInAnyOrder(valMsg1);
d1.sendBody(sendMsg);
direct1.assertIsSatisfied(camelContext);
}
}
我的問題是,XML消息我送的路線,節點1,而在回覆節點2節點1來之前談到節點2之前。
通過查看我知道兩個XML都是平等的,但由於代碼沒有字符串比較,它失敗了。
我知道XMLJUnit比較工具,但我怎麼能將它集成到給定的測試用例?