tags:

views:

279

answers:

2

I have checked a few testing solution for OSGI including PAX and had a quick look at the abstract TestCase within Spring DM but they both appear to require one to jar up and bundle associated bundles. I was hoping to find something that works without this intermediate step.

Imagine the ability to package up packages on your classpath so that packages x and y made up bundle XY and packages x and z made up bundle XZ. Bundle XZ would not "see" package "y" but could import a service from XY living in package x. Any comments if this is possible or if a equivalent test case / library exists ?

+2  A: 

I think that using Tiny Bundles from OPS4J with Pax Exam is what you are looking for.

http://wiki.ops4j.org/display/paxexam/ExamAndTinybundles

Alin Dreghiciu
Pax Exam and Tiny Bundles still seem very much focused on creating bundles in some form (even if its in memory). I need to take a better look but they appear to till require the class files to be fed from some classpath like source unlike regular tests. Many blogs seem to indicate that running pax exam tests are quite slow and not instanteous like one expects from regular junit test cases.
mP
@AlinI believe your from PAX :) thans for the libs, could i also suggest that you have a single download everything you need rather than requiring users to grab one by one.
mP
+1  A: 

If you really want to enforce runtime visibility rules than you probably have to run your tests inside OSGi environment and pay some performance overhead.

However it might be sufficient for you to enforce compile time visibility by separating your classes into distinct compilation units (e.g. separate Maven modules X,Y,Z) with proper dependencies and then running a standard testing framework (e.g. JUnit) without OSGi.

Pavol Juhos
Yup but one still does not know for sure that all the correct pkgs and classes have been imported/exported...
mP