... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2007-10-12

Eclipse/OSGI vs. JUnit

It is standard practice to place unit test source code in a directory tree distinct from the "real" source.  In those rare cases when you want to test package-private features, the standard trick is to put the unit test class in the same package as the class under test (albeit in a different directory).  This scheme works well in "raw" Java.

The trick also works in Eclipse using a JUnit Test launch configuration, even if the unit tests are in a separate plug-in (another standard practice).  However, if you use a JUnit Plug-in Test launch configuration instead, you will get an IllegalAccessException.  Apparently, OSGI prevents one plug-in from contributing classes to a package defined in another plug-in.  Thus, under OSGI, packages are effectively sealed as seen from other plug-ins.


Blog Archive