OSGi 单元测试无需打包步骤
我检查了一些 OSGI 测试解决方案,包括 PAX,并快速浏览了 Spring DM 中的抽象 TestCase,但它们似乎都需要一个来打包和捆绑相关的包。我希望找到不需要这个中间步骤的东西。
想象一下在类路径上打包包的能力,以便包 x 和 y 组成捆绑包 XY,包 x 和 z 组成捆绑包 XZ。捆绑包 XZ 不会“看到”包“y”,但可以从包 x 中的 XY 导入服务。如果可能或者是否存在等效的测试用例/库,有什么评论吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为将 OPS4J 的 Tiny Bundles 与 Pax Exam 结合使用正是您所寻找的。
http://wiki.ops4j.org/display/paxexam/ExamAndTinybundles
I think that using Tiny Bundles from OPS4J with Pax Exam is what you are looking for.
http://wiki.ops4j.org/display/paxexam/ExamAndTinybundles
如果您确实想强制执行运行时可见性规则,那么您可能必须在 OSGi 环境中运行测试并付出一些性能开销。
然而,通过将类分成具有适当依赖关系的不同编译单元(例如单独的 Maven 模块 X、Y、Z),然后在没有 OSGi 的情况下运行标准测试框架(例如 JUnit),来强制编译时可见性可能就足够了。
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.