0

I recently joined a project in which lots of autosys jobs are replaced with camel routes. most of the processing flows follow the same pattern:

  • Read a file from a certain folder
  • Apply some deserialization of some sort into a java structure
  • Invoke a stored procedure or another based on some values included in the java structuure
  • Send the processing results to some third party consumer

The easiest way to implement the stored procedure invoke was to use the sql-stored component. Let's just say I have this route:

from("file://d:/temp/in/?include=myFile*.csv")
.process("myHeaderSetter")
.choice()
    .when(header("myheader")).to("sql-stored:proc_1()?dataSource=#dataSource")
    .otherwise().to("sql-stored:proc_2()?dataSource=#dataSource")
.end()
.to("reportGenerator")
.to("file://d:temp/out/?fileName=report.txt");

Each processor is very well unit tested but we want to make sure that the route logic goes as we expect. The stored procedures can take a while to execute and running the real route is not an option part of the unit testing so I need a way to test that the stored procedures are invoked without actually getting them to run.

So what would be a good approach to unit test a route like above.

Thank you in advance for your inputs

Julian
  • 3,678
  • 7
  • 40
  • 72
  • Take a look at advice-with when testing as you can use it to replace parts of your routes with other bits such as routing to mocks instead of the sql – Claus Ibsen Apr 26 '17 at 08:13
  • Thanks for the suggestion. It worked very well. Please post your comment as an answer so I can accept it. – Julian May 04 '17 at 03:11

1 Answers1

-1

Take a look at advice-with (http://camel.apache.org/advicewith.html) when testing as you can use it to replace parts of your routes with other bits such as routing to mocks instead of the sql

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