Robert Courtney created CAMEL-7901:
--------------------------------------
Summary: MockEndpoint expectedBodiesReceived fails with "but was:
<null>" message
Key: CAMEL-7901
URL: https://issues.apache.org/jira/browse/CAMEL-7901
Project: Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 2.13.0
Environment: scala 2.10.3
camel 2.13.0
akka 2.3.1
OSX 10.8.5
Intellij IDEA 13.0.2
Reporter: Robert Courtney
A small scala + akka + camel test seems to show that the
MockEndpoint.expectedBodiesReceived(final List<?> bodies) method is not working
as expected.
the following scala code excerpt:
val mep = camelContext.getEndpoint("mock:file").asInstanceOf[MockEndpoint]
camel.template.sendBody(mep, "test body")
println("all exchanges:")
val exchanges = mep.getReceivedExchanges
println(exchanges)
// mep.expectedMessageCount(1) // WORKS
mep.expectedBodiesReceived("test body") // FAILS
mep.assertIsSatisfied
fails with this output:
2014-10-10 16:41:58,692 DEBUG o.a.c.component.mock.MockEndpoint - mock://file
>>>> 0 : Exchange[Message: test body] with body: test body and
headers:{breadcrumbId=ID-nbns-MacBook-Pro-local-59447-1412919718220-0-1}
all exchanges:
[Exchange[Message: test body]]
2014-10-10 16:41:58,693 INFO o.a.c.component.mock.MockEndpoint - Asserting:
Endpoint[mock://file] is satisfied
2014-10-10 16:41:58,694 DEBUG o.a.c.component.mock.MockEndpoint - mock://file
failed and received[1]: Exchange[Message: test body]
mock://file Body of message: 0. Expected: <test body> but was: <null>
java.lang.AssertionError: mock://file Body of message: 0. Expected: <test body>
but was: <null>
at
org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:1333)
at
org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:1315)
at
org.apache.camel.component.mock.MockEndpoint$5.run(MockEndpoint.java:628)
at
org.apache.camel.component.mock.MockEndpoint.doAssertIsSatisfied(MockEndpoint.java:394)
at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:362)
at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:350)
It looks like the problem is in MockEndpoint.java (line 613), where the
actualBodyValues variable is initialised to an empty ArrayList on each
invocation of expectedBodiesReceived(...), wiping out any values which were
added to this List at line 1220 in performAssertions()
I've looked through the same code in camel-core 2.13.x and 2.14 and the same
code exists there.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)