1

Suppose I have these two routes

<camelContext> 
    <route>
        <from ref="incoming" />
        <!-- some processors -->
        <inOnly ref="outgoing" />
    </route>

    <route>
        <from ref="outgoing" />
        <!-- some processors -->
        <inOnly ref="finish" />
    </route>
</camelContext>

In the real context they are JMS queues which is fine. But I want to test that the routing is correct so I changed JMS components in the testContext.xml to:

incoming -> direct
outgoing -> mock
finish -> mock

I want those inOnly queues to be mocks so I can test them for the number of messages. The problem is that a mock queue cannot work as an input queue in the second route. How can I fix this?

user219882
  • 15,274
  • 23
  • 93
  • 138

2 Answers2

1

I usually embedd an ActiveMQ broker when doing automated integration JUnit tests with Camel and JMS.

I would also consider a simpler scenario where you have "outgoing" as a seda endpoint. Then you would only have to check the "finish" mock endpoint for messages, and you know the entire route works. For more complicated routing scenarios, it takes a bit of thinking to cover it in JUnit tests, if you should do it at all.

Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84
  • It's not an integration test. I just want to check messages in two places - between the routes and at the end. But using `mock:outgoing` does not work (for some reason it can't be in the ``)... – user219882 Aug 31 '12 at 08:52
  • 1
    Okay, you really want to mock the middle one as well. That is actually described in code and text here: http://camel.apache.org/mock.html#Mock-Mockingexistingendpoints Using the "adviceWith" concept. I think that is describe except for direct instead of JMS queues. – Petter Nordlander Aug 31 '12 at 14:04
0

You can use the stub component instead of JMS etc. Its the seda/vm queues under the hood, so you can send and consume messages from it http://camel.apache.org/stub

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65