Hi

I'm experiencing some side effects when using
expectedHeaderValuesReceivedInAnyOrder in a testcase.

The following test will result in a ArrayOutOfBoundsException :

public void testResultingInArrayOutOfBoundsException() throws Exception {
                String xmlFile = FileUtils.readFileToString(new
File("src/test/data/good.xml"));
                MockEndpoint mockBar = getMockEndpoint("mock:bar");
                mockBar.expectedMessageCount(2);
                mockBar.expectedHeaderValuesReceivedInAnyOrder("MessageID",
"563516592469");

                template.sendBodyAndHeader("file:target/input", xmlFile,
Exchange.FILE_NAME, "test_name_header.xml");

                assertMockEndpointsSatisfied();
                List<Exchange> receivedExchanges = 
mockBar.getReceivedExchanges();
                String body = 
receivedExchanges.get(0).getIn().getBody(String.class);
                assertTrue(body.contains("<id>563516592469</id>"));
                body = receivedExchanges.get(1).getIn().getBody(String.class);
                assertTrue(body.contains("<id>563516592470</id>"));
        }
I know the expectedHeaderValues method ought to get 1 additional parameter,
but I would have guessed that if only the one  param is satisfied then the
test expectation would be satisfied. 

An other test runs green even if it should fail on the expectedMessageCount
->
public void testRunningGreenThatShouldFail() throws Exception {
                String xmlFile = FileUtils.readFileToString(new
File("src/test/data/good.xml"));
                MockEndpoint mockBar = getMockEndpoint("mock:bar");
                mockBar.expectedMessageCount(200);
                mockBar.expectedHeaderValuesReceivedInAnyOrder("MessageID",
"563516592469", "563516592470");

                template.sendBodyAndHeader("file:target/input", xmlFile,
Exchange.FILE_NAME, "test_name_header.xml");

                assertMockEndpointsSatisfied();
        }


Route config ->
 
  protected RouteBuilder createRouteBuilder() throws Exception {
                return new RouteBuilder() {
                        public void configure() {
                                from("file:target/input").
                                        
split().xpath("/odPublicationMessages/odPublicationMessage").
                                        
setHeader("MessageID").xpath("/odPublicationMessage/odPublication/id",
String.class).
                                        log("${body}").
                                        to("mock:bar")
                                .end();
                        }
                };
        }

The tests is done with Camel v. 2.15.1 and I have attached a small project.

Best,
Preben



--
View this message in context: 
http://camel.465427.n5.nabble.com/Strange-side-effects-when-testing-with-expectedHeaderValuesReceivedInAnyOrder-tp5766203.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to