Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically start an Eclipse IApplication

Tags:

java

eclipse

does anyone know how to programmatically start an Eclipse IApplication?

It is an commandline Application and I want to write unit tests for it.

It should work so:

    org.eclipse.equinox.app.IApplication app = new myApp();
    try {
        app.start(???);
    } catch (Exception e) {
        e.printStackTrace();
    }

The start method requires an IApplicationContext.

Where do I get this?

Thanks a lot for help

like image 452
Revilo Avatar asked Sep 26 '11 14:09

Revilo


2 Answers

You launch such applications using the OSGi ApplicationDescriptor service. In Equinox, each of the org.eclipse.core.runtime.applications is turned into an ApplicationDescriptor instance. You then launch an instance using the ApplicationDescriptor.launch(Map) method. The Eclipse Help provides a very broad if brief description, and be sure to read about the application cardinality on the Eclipsepedia.

like image 125
Brian de Alwis Avatar answered Nov 13 '22 18:11

Brian de Alwis


It does not seem the right way to start the application programmatically for unit testing.

Instead, you could write Eclipse plug-in tests, and they can launch the required OSGi container, where you can initialize your tests. Of course, you have to do some manual initialization, that are related to providing the corresponding test suite - but in that case you could manually call your code instead of relying an external launch process.

Take a look at the following FAQ entry http://wiki.eclipse.org/FAQ_What_is_a_PDE_JUnit_test%3F for details.

like image 1
Zoltán Ujhelyi Avatar answered Nov 13 '22 20:11

Zoltán Ujhelyi