OK, nailed the bastard! The option idempotent=true (together with noop=true) on the File component was causing the route to read the file content over an over.
-borut Dne 16. marec 2012 08:10 je Borut Bolčina <[email protected]>napisal/-a: > Hello, > > the route bellow splits the XML in smaller XML fragments which are then > umarshaled into an equal number of objects as there are fragments. The > number of fragments and therefore expected objects is 9. This XPath run on > the source XML count(//metData/domain_longTitle) proves the number. > > But the test is satisfied whatever numebr of expectedMessageCount I give > in the test method, for example > mock.expectedMessageCount(9); > mock.expectedMessageCount(5); > mock.expectedMessageCount(1); > > Why the test does not fail in cases other then 9? > > The code: > > ===================================================================================== > public class WeatherCurrentTest extends CamelTestSupport { > @EndpointInject(uri = "file:src/test/resources") > private ProducerTemplate inbox; > @Override > protected RouteBuilder createRouteBuilder() throws Exception { > return new RouteBuilder() { > @Override > public void configure() throws Exception { > DataFormat jaxbDataFormat = new > JaxbDataFormat("si.najdi.model.entities.weather"); > > from("file:src/test/resources/?fileName=observation_si_latest.xml&noop=true&idempotent=false") > .split() > .tokenizeXML("metData") > .unmarshal(jaxbDataFormat) > .to("log:si.najdi.datarobot?level=INFO") > .to("mock:meteo"); > } > }; > } > @Test > public void testMetData() throws Exception { > MockEndpoint mock = getMockEndpoint("mock:meteo"); > mock.expectedMessageCount(9); > File meteo = new File("src/test/resources/observation_si_latest.xml"); > String content = context.getTypeConverter().convertTo(String.class, > meteo); > inbox.sendBodyAndHeader(content, Exchange.FILE_NAME, > "src/test/resources/observation_si_latest.xml"); > mock.assertIsSatisfied(); > } > } >
