Skip to content
Snippets Groups Projects
Commit 4d532e05 authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

test still not working correctly

parent 11bdd165
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ abstract class AbstractRunnableStage implements Runnable { ...@@ -48,7 +48,7 @@ abstract class AbstractRunnableStage implements Runnable {
try { try {
do { do {
executeStage(); executeStage();
} while (!stage.shouldBeTerminated()); } while (!Thread.currentThread().isInterrupted());
} catch (TerminateException e) { } catch (TerminateException e) {
this.stage.terminate(); this.stage.terminate();
stage.owningContext.abortConfigurationRun(); stage.owningContext.abortConfigurationRun();
......
...@@ -8,9 +8,9 @@ public class TerminationTest { ...@@ -8,9 +8,9 @@ public class TerminationTest {
@Test(timeout = 2000) @Test(timeout = 2000)
public void doesNotGetStuckInAdd() throws InterruptedException { public void doesNotGetStuckInAdd() throws InterruptedException {
Execution<TerminationConfig> execution = new Execution<TerminationConfig>(new TerminationConfig()); Execution<TerminationConfig> execution = new Execution<TerminationConfig>(new TerminationConfig(1));
execution.executeNonBlocking(); execution.executeNonBlocking();
Thread.sleep(1000); Thread.sleep(500);
execution.abortEventually(); execution.abortEventually();
} }
...@@ -18,8 +18,8 @@ public class TerminationTest { ...@@ -18,8 +18,8 @@ public class TerminationTest {
InitialElementProducer<Integer> init = new InitialElementProducer<Integer>(1, 2, 3, 4, 5, 6); InitialElementProducer<Integer> init = new InitialElementProducer<Integer>(1, 2, 3, 4, 5, 6);
DoesNotRetrieveElements sinkStage = new DoesNotRetrieveElements(); DoesNotRetrieveElements sinkStage = new DoesNotRetrieveElements();
public TerminationConfig() { public TerminationConfig(final int capacity) {
connectPorts(init.getOutputPort(), sinkStage.getInputPort(), 1); connectPorts(init.getOutputPort(), sinkStage.getInputPort(), capacity);
addThreadableStage(sinkStage); addThreadableStage(sinkStage);
} }
...@@ -29,19 +29,23 @@ public class TerminationTest { ...@@ -29,19 +29,23 @@ public class TerminationTest {
@Override @Override
protected void execute(final Integer element) { protected void execute(final Integer element) {
try { int i = 0;
Thread.sleep(10000); while (true) {
} catch (InterruptedException e) { i++;
// Will happen in this test if (i > 1) {
Thread.currentThread().interrupt();
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
} }
} }
@Override @Override
protected void terminate() { protected void terminate() {}
Thread.currentThread().interrupt();
System.out.println("TADA " + this.shouldBeTerminated());
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment