When unit (integration) testing a transacted route, such as (pseudo):

<route>
  <from uri="activemq:some queue"/>
  <transacted/>
  <camel:process ref="someBeanProcessor"/>
</route>

Where "someBeanProcessor" does some DB work and participates in a JTA
transaction with the JMS message on this route

The problem is, what is a reliable way to apply an assertion on the work
that "someBeanProcessor" has done in the DB?  I've tried both of the
following:

1. Add <to: uri="log:some.logger.success?level=DEBUG"/>, get a MockEndpoint
ref and use an expected message count of 1, and wait on
mock.assertIsSatisified()

2. Use a NotifyBuilder on the route and use whenComplete(1), and wait on
builder.matchesMockWaitTime()

Both have the same result, where my test code is told about the success
before the JTA transaction has finished comitting, so when the test thread
performs a SQL select, it is doing so too early since the JTA tx of the
route hasn't actually completed.

This scenario works OK if the end result is something like <to
uri="activemq:out queue"/> and I use a MockEndpoint on the JMS output URI,
which makes sense since it'd be waiting on the TX to commit here; but what
about routes where this isn't an option?

Do I just need to suck it up and use Thread.sleep(..) on the test thread?

Thanks,

-- 
Alexander Sherwin

Reply via email to