0

I want to test my OSGI app in Pax Exam, but i have some trouble with starting Application from one of my plug-ins.

I use Equinox and there is some equinox-specific class that extends org.eclipse.equinox.app.IApplication. This class can be then selected in Eclipse Application Launcher and is first class to be run (in my case it controls app lifecycle).

When I run Pax Exam test, all bundles are resolved, but my IApplication is not started.

How can I run this kind of application in Pax Exam?

Additionally how can I pass some app arguments? I see only some frameworkProperty (-F) and systemProperty (-D), but i need some regular app arguments.

wajs
  • 299
  • 3
  • 13

2 Answers2

0

As far as I can tell IApplication is not part of equinox but part of the eclipse plattform. So I think it is not directly supported in pax exam. Pax exam will only start the OSGi framework and load and start the bundles you specify.

So the way to make this work might be to load the eclipse bundles that take care of the start of applications. I am not sure though how this would work in detail.

When using eclipse specific stuff you make your application less portable. So maybe you can achieve the same thing with pure OSGi infrastructure?

Or is the application you want to test an eclipse RCP application? In this case pax exam is probably not the best test facility. Some UI test frameworks would match better in this case. (e.g. https://developers.google.com/java-dev-tools/wintester/html/)

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
0

The IApplication is part of Equinox, and uses the registry to find out what is installed. So as well as including the appropriate jars in PAX, you'll also need to ensure that you start at least declarative services and the extension registry bundles, as otherwise the IApplication stuff won't be found.

Secondly there is no bundle that calls the EclipseStarter class, which is the thing that handles the main arguments, and which passes that through to the runtime. So unless you're doing that yourself, you will find that the application won't run at all.

If you're starting Eclipse specifically you might find some Eclipse-specific arguments to specify these as Java system properties:

http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html

for example, you could specify -Dapplication.id=yourapp

You might also try eclipse.commands as a newline-separated list of arguments.

AlBlue
  • 23,254
  • 14
  • 71
  • 91
  • So how can I use this EclipseStarter to run my app myself? – wajs Sep 24 '14 at 14:17
  • From code, you can call it as a main method. See http://stackoverflow.com/questions/4673406/programatically-start-osgi-equinox and/or my Eclipse book ;-) – AlBlue Sep 24 '14 at 14:19
  • But isn't it opening another osgi container, outside pax-exam? Cause I see, that it returns new bundleContext. – wajs Sep 24 '14 at 14:24
  • Yes, this will open a new OSGi framework. The bundle context is your handle on the system so that you can e.g. start and stop bundles in the containing framework. – AlBlue Sep 24 '14 at 16:27