Oh, CamelSpringTestSupport doesn't support @Autowired annotation.
That annotation is part of Spring test framework, you need to extends your test with the Spring test one.

On 5/10/11 4:25 PM, Xavier Coulon wrote:
Hello,

I'm running into a NullPointerException in my test case below:

public class MyActivityMonitorTestCase
extends CamelSpringTestSupport {

@Autowired
private MyActivityMonitor activityMonitor;

@EndpointInject(uri = "mock:mock")
private MockEndpoint mockEndpoint;

@Override
protected AbstractApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext(new String[] {
"classpath*:/META-INF/spring/applicationContext-xyz1.xml",
"classpath:/META-INF/spring/applicationContext-xyz2.xml" });
}

}

The bean named 'activityMonitor' is created within the Spring Application
context, but it is not injected in the test case, because I'm extending the
CamelSpringTestSupport class, not the AbstractJUnit4SupportTestCase.
I did not find any documentation about such a feature (injecting beans), but
would it be something doable or is there a mistake/somthing missing in my
code ?
In the mean time, I can manually retrieve the bean from the
applicationContext, but using annotation would be nicer ;-)

Thank you in advance
Regards,


--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com

Reply via email to