use of org.eclipse.e4.core.di.extensions.EventTopic in project eclipse.platform.runtime by eclipse.
the class InjectionEventTest method testInjectType.
@Test
public void testInjectType() {
IEclipseContext context = EclipseContextFactory.create();
InjectTargetEvent target = ContextInjectionFactory.make(InjectTargetEvent.class, context);
// initial state
assertEquals(0, target.counter1);
assertNull(target.event);
// send event
String eventTopic = "e4/test/eventInjection";
Dictionary<String, Object> d = new Hashtable<>();
d.put(EventConstants.EVENT_TOPIC, eventTopic);
d.put("data1", Integer.valueOf(5));
d.put("data2", "sample");
Event event = new Event(eventTopic, d);
helper.sendEvent(event);
assertEquals(1, target.counter1);
assertEquals(event, target.event);
assertEquals(Integer.valueOf(5), target.event.getProperty("data1"));
assertEquals("sample", target.event.getProperty("data2"));
}
use of org.eclipse.e4.core.di.extensions.EventTopic in project eclipse.platform.runtime by eclipse.
the class InjectionEventTest method testInjectWildCard.
@Test
public void testInjectWildCard() {
IEclipseContext context = EclipseContextFactory.create();
InjectStarEvent target = ContextInjectionFactory.make(InjectStarEvent.class, context);
// initial state
assertEquals(0, target.counter1);
assertNull(target.event);
// send event
String eventTopic = "e4/test/eventInjection";
Dictionary<String, Object> d = new Hashtable<>();
d.put(EventConstants.EVENT_TOPIC, eventTopic);
d.put("data1", Integer.valueOf(5));
d.put("data2", "sample");
Event event = new Event(eventTopic, d);
helper.sendEvent(event);
assertEquals(1, target.counter1);
assertEquals(event, target.event);
assertEquals(Integer.valueOf(5), target.event.getProperty("data1"));
assertEquals("sample", target.event.getProperty("data2"));
}
Aggregations