You could use the org.osgi.service.application.ApplicationDescriptor service. Each eclipse application gets a ApplicationDescriptor service registered for it. The ApplicationDescriptor.launch method can then be used to launch a test application. The reason this approach is not used is because the application PDE uses to launch (app id org.eclipse.pde.junit.runtime.coretestapplication) is considered a global singleton application. This prevents the application container from launching any other applications while the coretestapplication is running.
By default applications (defined with a
org.eclipse.core.runtime.applications extension) run on the main thread and
are global singletons. If the application
org.eclipse.pde.junit.runtime.coretestapplication changed its cardinality
to "1" instead of the default "singleton-global" then at least we could run
test applications. But we would still contend with the main thread. You
would only be able to run test applications that specified they can run on
any thread.
In the org.eclipse.osgi.tests project we have session tests that use the
application org.eclipse.pde.junit.runtime.coretestapplicationnonmain to run
a separate session with an app that does not run on the main thread. This
allows us to test the different application types with the application
container. This is overly complex and likely not what you want to do just
to perform some unit tests ;-)
But it would be nice to get the
org.eclipse.pde.junit.runtime.coretestapplication to change its cardinality
to "1" so we could launch non-main threaded applications in our tests.
Tom
From: "Ian Bull" <[email protected]>?
To: [email protected]
Date: 01/19/2009 01:26 PM
Subject: [equinox-dev] Starting an application (testing)
Hi guys,
I was looking at ways of starting an application (programmatically) for
testing purposes.
In p2 I noticed the following pattern:
private void runDirectorApp(String message, final String[] args) throws
Exception {
Application application = new Application();
application.start(new IApplicationContext() {
<.. Dummy IApplicationContext ../>
});
}
Is this the best way to do this, or can we (somehow) get a service and
simply call start with the application name and arguments. (Like the
_startApp Command does).
Cheers,
Ian
--
R. Ian Bull, PhD
Software Developer, EclipseSource
http://www.ianbull.com.
http://blog.ianbull.com._______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev
<<inline: graycol.gif>>
<<inline: ecblank.gif>>
_______________________________________________ equinox-dev mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/equinox-dev
