osgi
OSGiアプリケーションの統合テストにPax試験を使用する
サーチ…
前書き
Pax Examでは、OSGiコンテナ(AEM、Apache Karafなど)内のバンドルのテストが可能です。 Pax Examは通常、JUnitと組み合わせて使用されます。
入門
Pax Examを使ったテストの例を次に示します。
package com.example.project.test;
import static org.junit.Assert.*;
import static org.ops4j.pax.exam.CoreOptions.*;
import javax.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.regression.pde.HelloService;
import org.ops4j.pax.exam.spi.reactors.*;
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
public class SampleTest {
@Inject
private HelloService helloService;
@Configuration
public Option[] config() {
return options(
mavenBundle("com.example.myproject", "myproject-api", "1.0.0-SNAPSHOT"),
bundle("http://www.example.com/repository/foo-1.2.3.jar"),
junitBundles()
);
}
@Test
public void getHelloService() {
assertNotNull(helloService);
assertEquals("Hello Pax!", helloService.getMessage());
}
}
コードはPax試験4ページからのものです
Modified text is an extract of the original Stack Overflow Documentation
ライセンスを受けた CC BY-SA 3.0
所属していない Stack Overflow