Home » OSGI
Archiv der Kategorie: OSGI
Eclipse RCP JUnit tests with SWT checks
The basing question:
How to do JUnit tests for RCP classes that create SWT GUI?
Vorgehen/Hinweise:
- The „Run As“ dialog of Eclipse offers a „Run as Plugin“ option which must be used if OSGI features are used in the test.
- If OSGI features are needed (e.g. an OSGI service is part of the game) than OSGI a BundleContext has to be set up. Read OSGI Component Testing (Integration testing / “black-box-testing”) and perhaps OSGI BundleContext.java.
If this is done, then a Bundle can be invoked/setup by FrameworkUtil.getBundle(AnyClassInTheTestPlugin.java)
To read:
OSGI BundleContext.java –> siehe Mindmap unten!
Testing OSGI Based Applications –> PDF Version
Bundle Context
Setting up Eclipse like context for dependency injection:
If the class A has an annotation like
@Inject C c;
Then a class A can be retrieved that has an object of C already injected like that:
IEclipseContext context = EclipseContextFactory.create("test context"); context.set(C.class, new C(...)); A a = ContextInjectionFactory.make(A.class, context);
Problem while running on Linux Jenkins
org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
xxx
In welchem Plugin is meine Eclipse RCP Klasse
Funktioniert nur für von Eclipse bereitgestellte Bundles:
https://download.eclipse.org/ → Da kann man nach einer Klasse suchen
Oder ein listing der Eclipse Bundles: https://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/bundles