OSGiIntegrationTestSupport shows you a good example to run the OSGi Unit test with the help of PaxExam.

If you just want to test the services within karaf, you can write some utils class to deploy the bundle into karaf and run the unit test which access the services outside of karaf.

Willem

On 7/27/11 4:21 PM, Younes Ouadi wrote:
Dears,

I have wrapped CamelTestSupport in a service to allow testing Camel Routes
from GUI. The service works fine in a standalone application (unit tests) as
well as in a JEE application. When I tried the same service within an OSGI
environment (Karaf), I got the following error:

java.lang.RuntimeException: javax.naming.NoInitialContextException: We could
not find a provider for the InitialContextFactory
org.apache.camel.util.jndi.CamelInitialContextFactory

After some research, I have found that Camel 'itests' class
OSGiIntegrationTestSupport extends also the CamelTestSupport class and
override 'createCamelContext()' where 'CamelContextFactory' is used to
instantiate the context instead of using an instance of
'DefaultCamelContext'.

My issue with 'CamelContextFactory' is that it requires a dependency to the
'BundleContext' and makes my service coupled to OSGI API.

My questions are:
* Is my diagnostic is correct?
* Is this the only way to use CamelTestSupport from within an OSGI
environment?

Some information about my environment:
* Camel: 2.8.0
* Karaf: 2.2.1
* Aries: 0.3.1
* JDK: 1.6

Warm regards

Younes Ouadi



--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-CamelTestSupport-within-OSGI-Environment-tp4637949p4637949.html
Sent from the Camel - Users mailing list archive at Nabble.com.



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

Reply via email to