You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by ivorydrops <iv...@yahoo.com> on 2014/05/27 19:21:07 UTC
JavaConfig and JUnit
I have having a heck of a time getting JUnit to work with Camel. Can someone
help me here?
I have an annotated configuration class CamelConfig with component scanning.
The class also extends CamelConfiguration (ie not using
SingleRouteCamelConfiguration). Within the scanned packages, I have a
CamelRoute class that extends RouteBuilder (spring annotated with
@Component).
With this setup, I need Spring to load first then CamelRoute (so the
annotated resources get loaded with CamelRoute) within the context of camel.
No problems with my app, but struggling with JUnit context.
I started coding a JUnit class as follows:
@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {AppConfig.class, CamelConfig.class, CamelRoute.class},
loader = CamelSpringDelegatingTestContextLoader.class)
@MockEndpoints
public class CamelTest extends AbstractJUnit4SpringContextTests {
@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;
@Produce(uri = "direct:start")
protected ProducerTemplate template;
@DirtiesContext
@Test
public void testSendMatchingMessage() throws Exception {
String expectedBody = "foo";
resultEndpoint.expectedBodiesReceived(expectedBody);
template.sendBody(expectedBody, "foo");
resultEndpoint.assertIsSatisfied();
}
}
I get a Null Pointer exception from CamelSpringDelegatingTestContextLoader
and I don't know why. I am sure there is wrong with my context
configuration class setup.
--
View this message in context: http://camel.465427.n5.nabble.com/JavaConfig-and-JUnit-tp5751629.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: JavaConfig and JUnit
Posted by ivorydrops <iv...@yahoo.com>.
Nevermind. I got it working. I removed the "extends
AbstractJUnit4SpringContextTests".
--
View this message in context: http://camel.465427.n5.nabble.com/JavaConfig-and-JUnit-tp5751629p5751631.html
Sent from the Camel Development mailing list archive at Nabble.com.