use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class InjectionErrorReportingTest method testConstructorCastError.
/**
* Shows the error message for an exception in the injected constructor
*/
@Test(expected = InjectionException.class)
public void testConstructorCastError() {
IEclipseContext context = EclipseContextFactory.create();
TestData methodValue = new TestData();
context.set("testing", methodValue);
ContextInjectionFactory.make(InjectedConstructorCast.class, context);
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class ContextPerformanceTest method testSetValueRunAndTrack.
/**
* Tests setting a value in a context that a RAT is listening to. This test mimics what occurs
* when handlers change in e4. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=305038
*/
public void testSetValueRunAndTrack() {
context.set("somefunction", new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
// make sure this function has a large number of dependencies
for (int i = 0; i < 1000; i++) {
context.get("NonExistentValue-" + i);
}
return context.get("something");
}
});
context.runAndTrack(new RunAndTrack() {
@Override
public boolean changed(IEclipseContext context) {
context.get("somefunction");
return true;
}
});
new PerformanceTestRunner() {
int i = 0;
@Override
protected void test() {
context.set("something", "value-" + i++);
}
}.run(this, 10, 400);
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class ContextPerformanceTest method testSetContextFunction.
public void testSetContextFunction() {
context.set("somefunction", new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
return context.get("something");
}
});
new PerformanceTestRunner() {
int i = 0;
@Override
protected void test() {
context.set("something", "value-" + i++);
}
}.run(this, 10, 600000);
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class ContextPerformanceTest method testLookupContextFunction.
public void testLookupContextFunction() {
context.set("somefunction", new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
return "result";
}
});
new PerformanceTestRunner() {
@Override
protected void test() {
context.get("somefunction");
}
}.run(this, 10, 5000000);
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class DisposeClassLinkTest method testBug430041.
@Test
public void testBug430041() {
IEclipseContext context = EclipseContextFactory.create();
TestBug430041 obj = ContextInjectionFactory.make(TestBug430041.class, context);
context.dispose();
assertEquals(1, obj.preDestroy);
}
Aggregations