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

added nested stages test

parent f48162f2
No related branches found
No related tags found
No related merge requests found
......@@ -21,8 +21,7 @@
</action>
<action dev="ntd" type="add" issue="171">
Configurations are now
built within the Configuration class which is passed on to nested
CompositeStages.
built within the Configuration class.
This removes any constraints on CompositeStages and
enables therefore multiple connections and multithreading.
</action>
......
......@@ -48,7 +48,7 @@ public abstract class Stage {
/** The owning thread of this stage if this stage is directly executed by a {@link AbstractRunnableStage}, <code>null</code> otherwise. */
protected Thread owningThread;
protected ConfigurationContext owningContext = EmptyContext.getInstance();
public ConfigurationContext owningContext = EmptyContext.getInstance();
protected Stage() {
this.id = this.createId();
......
......@@ -15,7 +15,62 @@
*/
package teetime.framework;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import teetime.stage.Counter;
import teetime.stage.InitialElementProducer;
import teetime.stage.basic.Sink;
public class AbstractCompositeStageTest {
@Test
public void testNestedStages() {
Execution<NestesConfig> exec = new Execution<NestesConfig>(new NestesConfig());
assertThat(exec.getConfiguration().getContext().getThreadableStages().size(), is(3));
}
private class NestesConfig extends Configuration {
private final InitialElementProducer<Object> init;
private final Sink sink;
private final TestNestingCompositeStage compositeStage;
public NestesConfig() {
init = new InitialElementProducer<Object>(new Object());
sink = new Sink();
compositeStage = new TestNestingCompositeStage();
connectPorts(init.getOutputPort(), compositeStage.firstCompositeStage.firstCounter.getInputPort());
connectPorts(compositeStage.secondCompositeStage.secondCounter.getOutputPort(), sink.getInputPort());
}
}
private class TestCompositeStage extends AbstractCompositeStage {
private final Counter firstCounter = new Counter();
private final Counter secondCounter = new Counter();
public TestCompositeStage() {
addThreadableStage(firstCounter);
connectPorts(firstCounter.getOutputPort(), secondCounter.getInputPort());
}
}
private class TestNestingCompositeStage extends AbstractCompositeStage {
public TestCompositeStage firstCompositeStage;
public TestCompositeStage secondCompositeStage;
public TestNestingCompositeStage() {
firstCompositeStage = new TestCompositeStage();
secondCompositeStage = new TestCompositeStage();
connectPorts(firstCompositeStage.secondCounter.getOutputPort(), secondCompositeStage.firstCounter.getInputPort());
}
}
}
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