Hi Yeah it depends a bit how you want to trigger the route, you can write a file to that folder so the file consumer will pickup the file and route it.
To test your bean, you can also just do a plain unit test without Camel for that and call the bean from your unit test with various inputs and see what it returns. If you want to use Camel as well and test with the route, then you can use advice-with to insert / change / mock your route, so you can eg add a mock endpoint after the bean, where you can then set exceptions on the mock. See the docs about testing at http://camel.apache.org/testing Where you can find links to advice with etc. Also you can check the source code from camel itself as there is a lot of unit tests with camel and spring you can look at. And if you need more in-depth information about testing then some of the Camel books have that. http://camel.apache.org/books And you may find some 3rd party blogs etc about testing with Camel also http://camel.apache.org/articles On Wed, Jul 5, 2017 at 7:14 AM, Zoran Regvart <[email protected]> wrote: > Hi, > checkout the documentation[1] on Spring testing, > > zoran > > [1] https://camel.apache.org/spring-testing.html > > On Tue, Jul 4, 2017 at 8:57 PM, yoav hhh <[email protected]> wrote: >> I would like to use CamelSpringTestSupport in order to test my camel route. >> this is my camelContext : >> >> <camelContext xmlns="http://camel.apache.org/schema/spring"> >> <propertyPlaceholder id="incomingFileHandlerP" >> location="classpath:incomingFileHandler.properties" /> >> <route> >> <from uri="file://{{filesBaseDir}}?recursive=true&move=.done" >> id="incomingFile"/> >> <convertBodyTo type="java.lang.String" /> >> <to uri="bean:incomingFileHandler" id="incomingFileHandlerBean"/> >> >> <log message='${exchangeProperty[incomingFileHandlerError]}' /> >> <choice> >> <when> >> <simple>${exchangeProperty[incomingFileHandlerError]} != 'null' >> </simple> >> <log message="incomingFileHandler error" /> >> <to uri="file://?fileName=C:/tmp/xxx.xml" /> >> </when> >> <otherwise> >> <to uri="file://?fileName=C:/tmp/yyy.xml" /> >> </otherwise> >> </choice> >> </route> >> </camelContext> >> >> I want to be able to test (assert tests) the Exchange paremeters values >> after returning from incomingFileHandlerBean. >> >> So I have this Junit skeleton class: >> >> @RunWith(SpringJUnit4ClassRunner.class) >> public class Tests extends CamelSpringTestSupport { >> >> @Test >> public void test() throws InterruptedException { >> ////// ?? >> } >> >> @Override >> protected AbstractApplicationContext createApplicationContext() { >> return new >> ClassPathXmlApplicationContext("file:src/main/resources/META-INF/spring/applicationContext.xml"); >> } >> } >> >> But I'm not sure how to fill the test method. >> I will be happy for any help. >> >> >> >> -- >> View this message in context: >> http://camel.465427.n5.nabble.com/how-to-use-CamelSpringTestSupport-tp5805805.html >> Sent from the Camel - Users mailing list archive at Nabble.com. > > > > -- > Zoran Regvart -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
