@Test
public void testRunExecuteFinite() throws Exception {

	final int numberOfCalls = this.r.nextInt(50);
	final LinkedList<Tuple1<Integer>> expectedResult = new LinkedList<Tuple1<Integer>>();
	for (int i = numberOfCalls - 1; i >= 0; --i) {
		expectedResult.add(new Tuple1<Integer>(new Integer(i)));
	}
	final StreamingRuntimeContext taskContext = mock(StreamingRuntimeContext.class);
	when(taskContext.getExecutionConfig()).thenReturn(mock(ExecutionConfig.class));
	when(taskContext.getTaskName()).thenReturn("name");
	final FiniteTestSpout spout = new FiniteTestSpout(numberOfCalls);
	final SpoutWrapper<Tuple1<Integer>> spoutWrapper = new SpoutWrapper<Tuple1<Integer>>(
			spout, -1);
	spoutWrapper.setRuntimeContext(taskContext);
	final TestContext collector = new TestContext();
	spoutWrapper.run(collector);
	Assert.assertEquals(expectedResult, collector.result);
}