I want to unit test a route for which i used the AdviceWith function replaceFromWith("Direct:Start"); with which i unit tested the route. I got success on that.
But the issue is I replaced the FROM URI which is itself very complicated , Given Below :
I want to unit test the FROM URI , i used the weaveByType(ToDefinition.class).selectFirst().replace().to("mock:out");
This replaced the TO URI with MOCK:OUT But i am unable to keep the route in start mode. How can i use the Producer Template or Is there any other method by which i can test this , without making any changes to my CamelContext.xml
Given below is the code :
Public class CamelAdviceWith extends CamelSpringTestSupport{
@Override
protected AbstractApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("Camelcontext.xml");
}
@Override
public boolean isUseAdviceWith() {
return true;
}
@Test
public void testAdviceWith() throws Exception
{
context.getRouteDefinition("gsm-inbound").adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveByType(ToDefinition.class).selectFirst().replace().to("mock:out");
}
});
context.start();
// template.sendBody(?????????????); --- Commented Code, What should i use here..
context.stop();
}
}
Aucun commentaire:
Enregistrer un commentaire