我有几个OSGi包,它们是在Eclipse中使用普通的清单管理依赖关系构建的,以及使用Maven Tycho构建的外部构建。
在Equinox上运行Eclipse内部的包很好。和Tycho一起建造它们很好。
现在,我想使用Tycho运行集成测试,并为此创建了一个包含一些基本测试的简单测试包。测试中的捆绑包依赖于OSGi容器中存在的其他捆绑包,以及一些小的启动级别调整,以便正确运行--正如我所说,在Equinox上正常运行这些包时,它们自己启动的非常好。
因此,为了模拟Tycho,我在测试包的pom.xml中指定了以下内容:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>0.21.0</version>
<configuration>
<bundleStartLevel>
<bundle>
<id>org.hibernate.osgi</id>
<level>6</level>
<autoStart>true</autoStart>
</bundle>
<!-- plus a few more bundles in the real pom.xml -->
</bundleStartLevel>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>org.hibernate.entitymanager</id>
<versionRange>4.2.12.Final</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.hibernate.osgi</id>
<versionRange>4.2.12.Final</versionRange>
</requirement>
<!-- plus a few more bundles in the real pom.xml -->
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
</build>有趣的是,测试失败了。经过一些研究,我发现了如何在失败的测试运行期间/之后访问OSGi控制台,以进一步调查问题(OSGi console after running tycho tests)。
我的发现是,虽然所有必需的捆绑包(所有传递派生的包和手动指定的包)都存在于OSGi容器中,但只有那些具有独特<bundleStartLevel>的包已经启动(当然还有OSGi包)。
因此,鉴于上述示例,我的发现是,虽然org.hibernate.osgi和org.hibernate.entitymanager都已被解决,但只有第一个处于“活动”状态。这显然扰乱了整个启动过程,我的猜测是,如果包按预期启动,测试将运行良好。
当我查看“正常”Eclipse启动配置时,有一个参数“默认自动启动”在默认情况下设置为true。我在Tycho文档中没有找到类似的东西,但是是否有可能为某些包设置一个特定的启动级别,以某种方式覆盖其他包的自动启动?至少我不认为Tycho在默认情况下不会自动启动任何包.
我希望有任何关于如何进一步调查这个问题的提示,或者任何关于如何让Tycho启动我的包的线索,而不必为每个包指定一个不同的启动级别。
发布于 2016-01-08 11:31:40
如果还有人发现这一点:
由于Tycho 0.23包自动启动是可配置的。
<configuration>
<defaultStartLevel>
<level>7</level>
<autoStart>true</autoStart>
</defaultStartLevel>
</configuration>https://stackoverflow.com/questions/27173632
复制相似问题