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:
http://stackoverflow.com/questions/4914012/how-to-inject-applicationcontext-itself
Once you have that, you can get the CamelContext like:
CamelContext ctx = applicationContext.getBean("camel-context-name",
CamelContext.class);
-Steve
> -----Original Message-----
> From: biphasic [mailto:[email protected]]
> Sent: Thursday, October 15, 2015 12:01 PM
> To: [email protected]
> 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: http://camel.465427.n5.nabble.com/How-to-
> test-routes-when-using-another-TestRunner-tp5772687.html
> Sent from the Camel - Users mailing list archive at Nabble.com.