I've found out how to register implementations of a service, but these don't
appear to be available when the camelcontext is created. My camel-context is
defined in blueprint similar to the following:

<reference id="cameraManager"
interface="org.myCompany.cameramanager.CameraManager">

<camelContext xmlns="http://camel.apache.org/schema/blueprint";>
    <route id="test-route">
      <from uri="direct:start"/>
        <bean ref="cameraManager" method="getAllCameras" />
      <to uri="mock:a"/>
    </route>
</camelContext>

I've created a second blueprint file, for the purpose of the test, which
exposes an implementation of CameraManager as a service, the contents of
which is as follows:

<bean id="cameraManagerImpl"
class="org.myCompany.cameramanagerimpl.CameraManagerImpl" />
<service
ref="cameraManagerImpl"interface="org.myCompany.cameramanager.CameraManager"
/>

My getBlueprintDescriptor() method in the test returns both blueprint
descriptor files (the service implementing file first). The test fails as
the camel context isn't able to resolve dependencies for
org.myCompany.cameramanager.CameraManager.

However, if I remove my CamelContext descriptor from the
getBlueprintDescriptor() implementation in my test, when running a test I
can access the implementation of CameraManager, e.g:

import org.myCompany.cameramanager.CameraManager;

@testCameraManagerImpl(){
CameraManager cameraManager =
(CameraManager)getOsgiService(CameraManager.class);
    ArrayList<Camera> cameras = cameraManager.getAllCameras();
    for (Camera camera : cameras){
      System.out.println(String.format("Camera id: %s", camera.getId()));
    }
}

The above works, so why is the service not available to my CamelContext
during start up? Having a brief look at the CamelBlueprintHelper class in
the camel-test-blueprint component I note that a "TinyBundle" is created
containing both descriptors prior to the PojoServiceRegistry being created.
I'm not familiar with how these should be used, but is the bundle containing
both descriptors effectively starting prior to the creation of the
PojoServiceRegistry? If so, I could understand that the CameraManager
implementation isn't available.

In short is this a bug, or am I not using this correctly?

Please note, the test also logs all ServiceReferences, and I note that
org.myCompany.CameraManager is listed - I'm assuming that this is somehow
picked up from the Maven Dependency I have within my project?

Any help on this would be very much appreciated!

Cheers

Matt



--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-test-blueprint-tp5720280p5720355.html
Sent from the Camel Development mailing list archive at Nabble.com.

Reply via email to