I am writing integration tests to test existing routes. The recommended way to get an answer is something like this: ( โCamel in actionโ), section 6.4.1):
public class TestGetClaim extends CamelTestSupport {
@Produce(uri = "seda:getClaimListStart")
protected ProducerTemplate producer;
@Test
public void testNormalClient() {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
producer.sendBody(new ClientRequestBean("TESTCLIENT", "Y", "A"));
boolean matches = notify.matches(5, TimeUnit.SECONDS);
assertTrue(matches);
BrowsableEndpoint be = context.getEndpoint("seda:getClaimListResponse", BrowsableEndpoint.class);
List<Exchange> list = be.getExchanges();
assertEquals(1, list.size());
System.out.println("***RESPONSE is type "+list.get(0).getIn().getBody().getClass().getName());
}
}
The test passes, but I get nothing. assertTrue(matches)fails after a 5 second timeout.
If I rewrote the test to look like this, I get the answer:
@Test
public void testNormalClient() {
producer.sendBody(new ClientRequestBean("TESTCLIENT", "Y", "A"));
Object resp = context.createConsumerTemplate().receiveBody("seda:getClaimListResponse");
System.out.println("***RESPONSE is type "+resp.getClass().getName());
}
The documentation is lit up a bit around this, so can someone tell me what I'm doing wrong with the first approach? Is there something wrong with the subsequent second approach?
Thank.
UPDATE
, , seda recipientList . NotifyBuilder ( ).
, :
public class TestRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("seda:start")
.recipientList(simple("exec:GetClaimList.bat?useStderrOnEmptyStdout=true&args=${body.client}"))
.to("seda:finish");
}
}
, NotifyTest " ", , .