to real application Test is fast ~0.5s In process -> Easy debug No easy way to inject OSGi services. Have to use ServiceTracker. Needs special runner (can not use surefire) Test in src/main/java
plain OSGi container In process or forked Injection of service Works with surefire Test runs inside OSGi @RunWith(PaxExam.class) public void MyTest { @Configuration public Option configuration() { return composite( … ); } @Inject TaskService taskService; }
start Best if code only needs a few bundles Code and Test can be inside same module In process -> Easy debugging Fast ~0.5s @Configuration public Option configuration() { return composite( mavenBundle(“groupId”, “artifactId”) .versionAsInProject(), bundle("reference:file:target/classes/") … ); }
to be called? Awaitility can retry actions Needs to be installed into OSGi runtime Response response = await() .atMost(10, SECONDS) .ignoreExceptions() .until(()->target.request().get(), notNullValue());
redis = new GenericContainer("redis:3.0.2").withExposedPorts(6379); • Manages docker containers • Nice API for interaction with well known infra • Safely stops containers even if test crashes