use of org.apache.flink.runtime.event.task.StringTaskEvent in project flink by apache.
the class TaskEventHandlerTest method testEventNotificationManager.
/**
* Tests the publish/subscribe mechanisms implemented in the {@link TaskEventHandler}.
*/
@Test
public void testEventNotificationManager() {
final TaskEventHandler evm = new TaskEventHandler();
final TestEventListener listener = new TestEventListener();
evm.subscribe(listener, StringTaskEvent.class);
final StringTaskEvent stringTaskEvent1 = new StringTaskEvent("Test 1");
final StringTaskEvent stringTaskEvent2 = new StringTaskEvent("Test 2");
evm.publish(stringTaskEvent1);
evm.publish(new IntegerTaskEvent(5));
assertNotNull(listener.getLastReceivedEvent());
StringTaskEvent receivedStringEvent = (StringTaskEvent) listener.getLastReceivedEvent();
assertEquals(stringTaskEvent1, receivedStringEvent);
evm.unsubscribe(listener, StringTaskEvent.class);
evm.publish(stringTaskEvent2);
assertNotNull(listener.getLastReceivedEvent());
receivedStringEvent = (StringTaskEvent) listener.getLastReceivedEvent();
assertEquals(stringTaskEvent1, receivedStringEvent);
}
Aggregations