Is it possible to retrieve the BundleContext without @Inject annotation
when we launch the Pax Exam server as such in a class ?
public class GatewayRestOSGITester extends ParentRunner<TestInfo> {
@Inject
protected BundleContext bundleContext;
...
private void startServer() {
try {
Option[] options = KarafConfiguration.config();
ExamSystem system = DefaultExamSystem.create(options);
testContainer = PaxExamRuntime.createContainer(system);
testContainer.start();
} catch (IOException e) {
e.printStackTrace();
}
}
protected void initWebListener() {
webListener = new WebListenerImpl();
bundleContext.registerService(WebListener.class, webListener,
null); ///////////// BundleContext is NULL
}
On Fri, Feb 26, 2016 at 6:05 PM, Charles Moulliard <[email protected]> wrote:
> Hi,
>
> I'm developing a Test Case where the Junit ParentRunner is used to setup a
> server, load test info, ... before to execute the test case but I'm faced
> to the problem that I don't see how to launch the PAx Exam OSGI Container.
>
> Ideally, my class should be designed as such
>
> @RunWith(PaxExam.class)
> public class GatewayRestOSGITester extends ParentRunner<TestInfo> {
>
> but of course, the OSGI container will not be created
>
> Is there a workaround that I could use to launch the OSGI Karaf container
> even if we don't use @RunWith(PaxExam.class) ?
>
> FYI, I have tried to use the ExamSystem but unfortunately @Inject doesn't
> work in this case
>
> Option[] opts = options.toArray(new Option[options.size()]);
> ExamSystem system = PaxExamRuntime.createServerSystem(opts);
>
> Any ideas are welcome ;-)
>
> Regards,
> --
> Charles Moulliard
> Apache Committer & PMC / Architect @RedHat
> Twitter : @cmoulliard | Blog : http://cmoulliard.github.io
>
>
--
Charles Moulliard
Apache Committer & PMC / Architect @RedHat
Twitter : @cmoulliard | Blog : http://cmoulliard.github.io