-
1. Re: NullPointerException on unit test advice due to wrong blueprint context.
njiang Jul 18, 2012 11:30 PM (in response to murray.hughes)Hi,
Did you try to add the filter parameter by override the createCamelcontext() method of CamelBuleprintTestSupport.
I'm not sure if there are other bundles which have blueprint configuration files can cause the trouble that you have.
BTW, it could be more easy for us to trace the issue if you can provide a simple test case.
Willem
-
2. Re: NullPointerException on unit test advice due to wrong blueprint context.
murray.hughes Jul 19, 2012 7:04 PM (in response to njiang)I did try this in mu unit test:
@Override
protected CamelContext createCamelContext() throws Exception {
return this.getOsgiService(CamelContext.class, "(Bundle-SymbolicName=MyTest)");
}
It causes a different problem: it does not find my context. I'm unsure if MyTest(the unit test class name) is correct.
Yes there are other bundles which have blueprint configuration files in my dependencies. It is one of those which is getting picked. I included those to get access to the pojo classes being passed via jms.
I suspect its caused by this code in CamelBlueprintTestSupport:
@Override
protected CamelContext createCamelContext() throws Exception {
return CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class);
}
Furthermore, I find the problem is intermittant. Sometimes the test passes, sometime its gets the NPE described here, with no change to code. I suspect its a race.
It'll be a fair bit of work to create a test case because I'll have to reproduce the timing(which I don't understand). I'll see what can be done.
-
3. Re: NullPointerException on unit test advice due to wrong blueprint context.
murray.hughes Jul 19, 2012 8:01 PM (in response to murray.hughes)Both bundles have the same package. maybe that's contributing to the problem.
-
4. Re: NullPointerException on unit test advice due to wrong blueprint context.
ffang Jul 19, 2012 8:42 PM (in response to murray.hughes)Hi,
Yeah, same packages across bundles is a so called "split package" issue in OSGi world, you definitely should avoid it.
Freeman
-
5. Re: NullPointerException on unit test advice due to wrong blueprint context.
murray.hughes Jul 19, 2012 11:27 PM (in response to ffang)Since applying the solution for another problem: http://fusesource.com/forums/message.jspa?messageID=14911#14911
this problem has stopped happening.