From 1af53dd32864f39e4c085094b7278e157881aa01 Mon Sep 17 00:00:00 2001
From: Nelson Tavares de Sousa <stu103017@mail.uni-kiel.de>
Date: Mon, 5 Oct 2015 15:54:35 +0200
Subject: [PATCH] added test for possible bug

---
 .../teetime/framework/TerminationTest.java    | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/src/test/java/teetime/framework/TerminationTest.java b/src/test/java/teetime/framework/TerminationTest.java
index c139f008..96a21031 100644
--- a/src/test/java/teetime/framework/TerminationTest.java
+++ b/src/test/java/teetime/framework/TerminationTest.java
@@ -19,6 +19,10 @@ import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Ignore;
 import org.junit.Test;
 
 import teetime.stage.InitialElementProducer;
@@ -26,6 +30,12 @@ import teetime.stage.basic.Sink;
 
 public class TerminationTest {
 
+	@Ignore
+	@Test(timeout = 5000)
+	public void terminatesMultiInputPort() {
+		new Execution<Configuration>(new MultiInputConfig()).executeBlocking();
+	}
+
 	@Test(timeout = 1000)
 	public void correctAbort() throws InterruptedException {
 		TerminationConfig configuration = new TerminationConfig(10);
@@ -120,4 +130,44 @@ public class TerminationTest {
 		}
 	}
 
+	private class MultiInputConsumer extends AbstractConsumerStage<Object> {
+
+		public final InputPort<Object> secondInputPort = createInputPort(Object.class);
+
+		private int count = 0;
+
+		@Override
+		protected void execute(final Object element) {
+			Object received = secondInputPort.receive();
+			if (received != null) {
+				count++;
+			}
+			if (count > 3) {
+				this.terminate();
+			}
+		}
+
+	}
+
+	private class MultiInputConfig extends Configuration {
+
+		public MultiInputConfig() {
+			List<Integer> array = new ArrayList<Integer>();
+			for (int i = 0; i < 10000; i++) {
+				array.add(new Integer(0));
+			}
+			InitialElementProducer<Object> firstInit = new InitialElementProducer<Object>(new Object());
+			InitialElementProducer<Integer> secondInit = new InitialElementProducer<Integer>(array);
+			MultiInputConsumer miConsumer = new MultiInputConsumer();
+
+			connectPorts(firstInit.getOutputPort(), miConsumer.getInputPort());
+			connectPorts(secondInit.getOutputPort(), miConsumer.secondInputPort);
+
+			firstInit.declareActive();
+			secondInit.declareActive();
+			miConsumer.declareActive();
+		}
+
+	}
+
 }
-- 
GitLab