camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Turnbull <>
Subject Using AdviceWith not intercepting when I send real Files through
Date Fri, 04 Apr 2014 19:09:18 GMT

I'm attempting to use AdviceWith for testing a route The route looks like:


I've written a test that attempts to confirm that files get unmarshalled to
csv correctly and are sent to my mocked direct:csvRecords endpoint. As
such, my test looks like what is recommended from the Camel mock page The main difference is I'm sending
through real files, but treating direct:csvRecords as a mock to confirm
correct behavior.

public void mockAllEndpoints() throws Exception {
AdviceWithRouteBuilder mockDirect = new AdviceWithRouteBuilder() {

public void configure() throws Exception {
// mock the for testing
.adviceWith(context, mockDirect);

Then in my test I have:

public void testReadCsvFileWhenDoneFile() throws Exception {
MockEndpoint mockDirectCsv = getMockEndpoint("mock:direct:csvRecords");
File testCsv = new File("test.csv");
FileUtils.copyFile(testCsv, new File("inbox/test.csv"));
FileUtils.touch(new File("inbox/done"));
// Confirm nothing's been processed

The "assertIsSatisfied" fails because the expectation isn't met. I can
confirm that CSV deserialization and processing is happening because if I
add a .process() and to a println, I see all three csv records in that file
come out fine. I'd just like to be able to build tests around expected
behavior for my routes.

As far as I can tell the mock endpoint isn't getting hit with messages. If
I put a breakpoint in the mock endpoint code where the message counter is
incremented, it is never hit. So the assertIsSatisfied fails due to not
enough messages being brought through.

(I'm running Camel 2.12.3 on Windows 7. Java 7)


Doug Turnbull
Search & Big Data Architect
OpenSource Connections <>

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message