camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Huston <>
Subject RE: How to test routes when using another TestRunner
Date Thu, 15 Oct 2015 19:37:04 GMT
I am a relative novice in this area, but I did have some tests running in Cucumber. To get
the applicationcontext, see this stack overflow question:

Once you have that, you can get the CamelContext like:

CamelContext ctx = applicationContext.getBean("camel-context-name", CamelContext.class);


> -----Original Message-----
> From: biphasic []
> Sent: Thursday, October 15, 2015 12:01 PM
> To:
> Subject: How to test routes when using another TestRunner
> Hello,
> I have a few tests to check my Camel routes that when run using the
> SpringJUnit4ClassRunner work just fine. However, I want to test some routes
> of my application with Cucumber (basically something similar to JUnit). This
> requires me to use another TestRunner (Cucumber.class). When trying to call
> my tests from a Cucumber stack, the class that extends
> CamelSpringTestSupport will not set any form of context. It just skips
> createApplicationContext(). I am still able to access beans though.
> What I now did as an ugly fix was to set the context manually.
> this.context = new
> ClassPathXmlApplicationContext("classpath:context.xml").getBean("camelC
> ontext");
> I can now send something to endpoints, can access beans and whatnot. But
> the assertion of expectedMessages at my MockEndpoint still always fails.
> Is there something else that I manually have to recreate when extending
> CamelSpringTestSupport and I cannot use the SpringJUnitClassRunner?
> Thankful for any hints,
> Cheers
> --
> View this message in context:
> test-routes-when-using-another-TestRunner-tp5772687.html
> Sent from the Camel - Users mailing list archive at

View raw message