0

在 pax 考试中,我希望某些东西对所有测试功能都是通用的。为此,我使用了@Before,使用@Before 方法的问题是它会在每个测试方法之前被调用。有没有办法解决这个问题。pax 考试中是否有一些注释可用于解决此问题。

@Before
    public void init() throws Exception{
        featuresService.installFeature("hibernate");
        featuresService.installFeature("hibernate-validator");
        bundleContext.installBundle("wrap:mvn:osgi/osgi/3.0.1").start();
        bundleContext.installBundle("wrap:mvn:javax.xml/xml/3.1.0").start();
        bundleContext.installBundle("wrap:mvn:commons-dbcp/commons-dbcp/1.2.2").start();
        bundleContext.installBundle("wrap:mvn:commons-pool/commons-pool/1.3").start();
        bundleContext.installBundle("wrap:mvn:commons-lang/commons-lang/2.3").start();
    }
4

1 回答 1

2

现在不可能在 PaxExam 运行的测试中出现这种行为,但您的init方法可以很容易地替换Option为容器的配置。

例如 :

features(maven().groupId("org.apache.karaf.assemblies.features")
       .artifactId("enterprise").type("xml").classifier("features")
       .versionAsInProject(), "hibernate", "hibernate-validator")

或者

 wrappedBundle(mavenBundle("commons-dbcp", "commons-dbcp", "1.2.2"))
于 2016-02-16T08:53:54.590 回答