Imagine that I have created a bundle that publishes a HelloService to 
the OSGi service registry. Now I want to test that service, integrated 
with all of the stuff (in other bundles) that it works with. So I write 
a Pax Drone test, adding all of the required bundles.

I run the test...it looks a little something like this:

public class HelloServiceBundleTest extends DroneTestCase {

   @Override
   protected ConnectorConfiguration configure() {
      return ConnectorConfigurationFactory.create(this).setPlatform(
                  Platforms.EQUINOX).addBundle("...")
                  .addBundle("..."); // bundle names left out for 
brevity's sake     
   }

   public void testBundleContextExists() {
      assertNotNull(droneContext.getBundleContext());
   }

   public void testHelloServiceShouldExist() {
      BundleContext bundleContext = droneContext.getBundleContext();
      ServiceReference serviceRef = bundleContext
                  .getServiceReference("com.habuma.hello.HelloService");
      HelloService helloService = (HelloService) bundleContext
                  .getService(serviceRef);
      assertNotNull(helloService);
   }
}

But it doesn't work. The testBundleContextExists() test works. But 
testHelloServiceShouldExist() fails. It tries to find the HelloService, 
but it can't be found. I'm pretty sure that it's because...

    * I'm not adding the hello service bundle to the
      ConnectorConfiguration...and...
    * I'm letting the test case automatically generate the bundle for
      the hello service...and...
    * The generated bundle doesn't know about the activator...therefore...
    * The service isn't be published.

My question: How can I test the index service (in an integration test 
along with all of the stuff that it depends on) using Pax Drone? Like I 
said, it seems that the crux of the problem is that the service is never 
published because the activator is never executed because I don't know 
how to tell Pax Drone about the activator. 

Any clues? The only thing that I can think of is to test the hello 
service in a separate project, including the hello service bundle in the 
set of bundles added to the ConnectorConfiguration and ensure that the 
hello service bundle has been created before I run the integration test. 
But I'd really prefer to test the hello service bundle within the hello 
service bundle project.



_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to