@Test
public void testGetNextBufferOrEvent() throws IOException, InterruptedException {

	final TestSingleInputGate inputGate = new TestSingleInputGate(1)
			.readBuffer().readBuffer().readEvent()
			.readBuffer().readBuffer().readEvent()
			.readBuffer().readEndOfPartitionEvent();
	final BufferReader reader = new BufferReader(inputGate.getInputGate());
	// Task event listener to be notified...
	final EventListener<TaskEvent> listener = mock(EventListener.class);
	reader.registerTaskEventListener(listener, TestTaskEvent.class);
	int numReadBuffers = 0;
	while ((reader.getNextBuffer()) != null) {
		numReadBuffers++;
	}
	assertEquals(5, numReadBuffers);
	verify(listener, times(2)).onEvent(any(TaskEvent.class));
}