Hi, The logic is similar with the following differences:
1) The maven plug finds the dependencies and use them as the list of jars (bundles) to be installed to the Equinox runtime. We also package the main and test code into a bundle so that all the classes (main/test and tuscany/3rd-party) are loaded by OSGi. Typically the current project will have dependencies on the SCA API/annotations or Tuscany API, the maven surefire plugin will create a URL classloader and it makes the main/test classes get the SCA/Tuscany API classes from JSE instead of OSGi. 2) I assume most of our Junit test cases start/stop Node using the Tuscany Node APIs. The plugin approach makes it possible to run the test cases under both JSE and OSGi without changing the code. Thanks, Raymond From: Simon Laws Sent: Monday, January 19, 2009 7:59 AM To: [email protected] Subject: Re: Run junit test cases in maven with OSGi Hi Raymond Some questions inline. Why can't we use the launcher in the Junit test to fire up the runtime rather that turning the test itself into a bundle. Are you tring to ensure that the junit test doesn't have to reach from the JSE world into the OSGi world? The launcher would be able to get the dependencies from the classpath but wouldn't be able to get at the bundelized 3rd party jars currently in PDE target. You seem to have some code for doing this on the fly so could this also be incorporated into the launcher. Simon On Fri, Jan 16, 2009 at 9:23 PM, Raymond Feng <[email protected]> wrote: Hi, I have prototyped a maven plugin that can run junit test cases with the Equinox OSGi runtime. It works as follows: 1) Generate a bundle for the current project with the target/classes Does this create an activator in the bundle to run the test? 2) Generate a bundle fragment that attaches to the bundle from step 1 What is this fragment for? 3) Find all the maven dependencies and use them as the set of initial bundles (the plain jars are converted into a bundle on the fly too) 4) Bootstrap the Equinox runtime 5) Find all test cases and run them with the JUNIT runner How are the test cases identified? 6) Report the results of the test case To configure a maven project, use the following XML in the pom.xml (See an example at [2]): <plugin> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-maven-osgi-junit</artifactId> <version>2.0-SNAPSHOT</version> <executions> <execution> <id>osgi-test</id> <phase>test</phase> <goals> <goal>test</goal> </goals> </execution> <configuration></configuration> </executions> </plugin> The ideal approach is to plug in the same logic into the existing maven-surefire-plugin. But it doesn't seem that the surefire plugin has such plug points. Please let me know if you have better ideas. Thanks, Raymond [1] https://svn.apache.org/repos/asf/tuscany/java/sca/tools/maven/maven-osgi-junit [2] https://svn.apache.org/repos/asf/tuscany/java/sca/samples/calculator-osgi/pom.xml
