开发者

OSGi unit testing without step that packages bundles

开发者 https://www.devze.com 2022-12-13 09:50 出处:网络
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 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 c开发者_如何学JAVAould import a service from XY living in package x. Any comments if this is possible or if a equivalent test case / library exists ?


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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消