use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class DisposeClassLinkTest method testMake.
@Test
public void testMake() throws Exception {
IEclipseContext context = EclipseContextFactory.create();
MyTest test = ContextInjectionFactory.make(MyTest.class, context);
assertEquals(0, test.getCount());
context.dispose();
assertEquals(1, test.getCount());
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class DisposeClassLinkTest method testDisposeParent.
@Test
public void testDisposeParent() throws Exception {
IEclipseContext parentContext = EclipseContextFactory.create();
IEclipseContext context = parentContext.createChild();
MyTest test = ContextInjectionFactory.make(MyTest.class, context);
assertEquals(0, test.getCount());
context.dispose();
assertEquals(1, test.getCount());
parentContext.dispose();
assertEquals(1, test.getCount());
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class DisposeClassLinkTest method testInjectedWithContext.
@Test
public void testInjectedWithContext() throws Exception {
IEclipseContext context = EclipseContextFactory.create();
InjectionObject obj = ContextInjectionFactory.make(InjectionObject.class, context);
assertEquals("The object has been injected with the context", context, obj.context);
assertEquals("@PostConstruct should have been called once", 1, obj.postConstruct);
assertEquals("@PreDestroy should not have been called", 0, obj.preDestroy);
context.dispose();
assertNotNull(obj.context);
assertEquals("@PostConstruct should only have been called once", 1, obj.postConstruct);
assertEquals("@PreDestroy should have been called during uninjection", 1, obj.preDestroy);
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class InjectionOrderTest method testSpecialMethodOnFailure.
/**
* Make sure special methods are not getting called in case injection failed
*/
@Test
public void testSpecialMethodOnFailure() {
IEclipseContext appContext = EclipseContextFactory.create();
boolean exception = false;
try {
ContextInjectionFactory.make(InjectUnsatisfied.class, appContext);
} catch (InjectionException e) {
exception = true;
}
assertTrue(exception);
appContext.dispose();
assertEquals(0, InjectUnsatisfied.count);
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class InjectBridgeTest method testInvokation.
@Test
public void testInvokation() {
IEclipseContext context = EclipseContextFactory.create();
context.set(String.class, "Value");
ContextInjectionFactory.invoke(new Concrete(), Execute.class, context);
}
Aggregations