On Sat, Feb 4, 2012 at 6:49 AM, Babak Vahdat
<[email protected]> wrote:
> Of course the best way to verify it, is to use Camel test toolkit [1] and
> check if it does functionally what you expect it to do.
Thanks - that's a great idea - I've got a unit test for it, but how
can I simulate onCompletion from it? I'm extending CamelTestSupport -
my test method is below.
I'm using mockito, so main is just set to mock(Main.class) in the
setup - and I'm getting a verification failure on the last line of the
test.
I added a log message to the shutdown processor that calls main.stop()
- and I see that in the output, so it's getting called, but I'm
thinking it's getting called *after* the verify() call...actually, I
just tested this with a Thread.sleep(100) before the verify() call,
and that makes it pass.
Is there a more clever way to do this?
---
@Test
public void shouldCopyFromSourceToDestination() throws Exception {
// setup test
MockEndpoint mockEndpoint = getMockEndpoint(MOCK_TEST);
mockEndpoint.expectedMessageCount(1);
// run test
Map<String, Object> map = new HashMap<String, Object>();
map.put("CamelFileNameOnly", "100000000.JPG");
map.put("CamelFileLength", "100");
template.sendBodyAndHeaders(DIRECT_TEST, "test", map);
// verify behavior
assertMockEndpointsSatisfied();
Thread.sleep(100); // <<< fails w/o this
verify(main).stop();
}
---
Larry