Search in sources :

Example 6 with IInjector

use of org.eclipse.e4.core.di.IInjector in project eclipse.platform.runtime by eclipse.

the class InjectionEventTest method testEventInjectionUnsubscribe.

// NOTE: this test relies on GC being actually done on the test object.
// Java does not guarantee that to happen, so, if this test starts to fail
// intermittently, feel free to comment it
@Test
public void testEventInjectionUnsubscribe() throws InvocationTargetException, InstantiationException {
    IInjector injector = InjectorFactory.getDefault();
    injector.addBinding(MyBinding.class);
    // do it in a separate method to ease GC
    wrapSetup();
    System.gc();
    System.runFinalization();
    System.gc();
    helper.sendEvent("e4/test/event1", "wrong");
    // target would have asserted if it is still subscribed
    assertFalse(testFailed);
}
Also used : IInjector(org.eclipse.e4.core.di.IInjector) Test(org.junit.Test)

Aggregations

IInjector (org.eclipse.e4.core.di.IInjector)6 Test (org.junit.Test)4 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 Car (org.atinject.tck.auto.Car)1 Engine (org.atinject.tck.auto.Engine)1 V8Engine (org.atinject.tck.auto.V8Engine)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 ExtendedObjectSupplier (org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1 ServiceReference (org.osgi.framework.ServiceReference)1