Announcement Announcement Module

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
Integration Testing Question Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integration Testing Question

    This may be an obvious question, but nevertheless. In recently working with the AbstractConfigurableBundleCreatorTests, I have been a bit confused on the intent. A test bundle is generated with a manifest that imports required bundles from the bootstrapped OSGi context. This allows the exported packages of the imported bundles to be validated in the test class. Clear so far.

    The question is, what if I have a bean in the project containing the integration test that injects an osgi:reference exported by one of the imported bundles? Is it possible to integration test this bean without breaking it out into a separate bundle? For example, take the following simple case where com.myorg.consumer.ExampleService is exported by an imported bundle:


    <bean id="exampleConsumer" 
      	<property name="exampleService" ref="exampleService" />

    <osgi:reference id="exampleService" 
         interface="com.myorg.myService.ExampleService" />
    In the integration test (ServiceTest) in the same project I can do:

    ServiceReference serviceRef = bundleContext
    ExampleService service = 
      (ExampleService) bundleContext.getService(serviceRef);
    System.out.println(service.sayHello("Jacob Orshalick"));
    But I cannot:

    ExampleConsumer consumer = (ExampleConsumer) 
    consumer.printHelloMessage("Jacob Orshalick");
    It seems that the test bundle generation logic allows only one root.dir to apply include patterns to. The default uses /target/test-classes meaning all classes in /target/classes are ignored. If the applicationContext for the integration test includes any beans contained in the same project (in src/main/java) this fails with a ClassNotFoundException as these classes are not included in the test bundle.

    Is the assumption that a project will always have a multi-module build where all modules under test are generated prior to executing the integration test? This would make sense given the current base functionality, but I was curious if this was the intent.

    Thanks for your help and please let me know if any clarification on the points above is required.

  • #2
    Re: Integration Testing Question

    Makes sense now. I misunderstood the following warning in the documentation, 9.2. Integration Testing on the first read:

    "(!) The testing framework is NOT meant to be used as an OSGi bundle (nor will it work for that matter)."

    In re-reading this would seem to indicate that an integration test should always be a completely separate bundle from the bundles under test.


    • #3
      That is correct - I will try to make this point stronger. Basically the integration test should contain just that, the test - all its dependencies should be left outside.
      There is a screencast that covers a basic testing session - try using that for starters (it's a bit outdated in terms of maven dependencies configuration but otherwise it should work just fine).