diff --git a/src/main/java/teetime/stage/basic/distributor/dynamic/PortActionListener.java b/src/main/java/teetime/stage/basic/distributor/dynamic/PortActionListener.java index 10cd6c4715afdc90d442da21d0af953a414b2cf5..875db7e737f9ce8b76d66eb6621828ac0719fe10 100644 --- a/src/main/java/teetime/stage/basic/distributor/dynamic/PortActionListener.java +++ b/src/main/java/teetime/stage/basic/distributor/dynamic/PortActionListener.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package teetime.stage.basic.distributor.dynamic; import teetime.framework.DynamicOutputPort; diff --git a/src/main/java/teetime/stage/basic/distributor/dynamic/RemovePortAction.java b/src/main/java/teetime/stage/basic/distributor/dynamic/RemovePortAction.java index c9785f48b4b026e2619ea101b710b2a57c4d03f9..461d3fdba022d1609d5fba2e52c25cb50d41ccd1 100644 --- a/src/main/java/teetime/stage/basic/distributor/dynamic/RemovePortAction.java +++ b/src/main/java/teetime/stage/basic/distributor/dynamic/RemovePortAction.java @@ -31,11 +31,6 @@ public class RemovePortAction<T> implements PortAction<DynamicDistributor<T>> { @Override public void execute(final DynamicDistributor<T> dynamicDistributor) { - DynamicOutputPort<T> realOutputPort = outputPort; - if (outputPort instanceof PortContainer) { // BETTER replace test-specific code and abstract appropriately - realOutputPort = ((PortContainer<T>) outputPort).getPort(); - } - - dynamicDistributor.removeDynamicPort(realOutputPort); + dynamicDistributor.removeDynamicPort(outputPort); } } diff --git a/src/main/java/teetime/util/framework/port/PortList.java b/src/main/java/teetime/util/framework/port/PortList.java index 0c0f1fd6d0028010cc4fd0ef0dde29c24aaaa6d8..b5e48bc95ccab7c409b54f97b93b0445121bd704 100644 --- a/src/main/java/teetime/util/framework/port/PortList.java +++ b/src/main/java/teetime/util/framework/port/PortList.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package teetime.util.framework.port; import java.util.ArrayList; diff --git a/src/main/java/teetime/util/framework/port/PortRemovedListener.java b/src/main/java/teetime/util/framework/port/PortRemovedListener.java index e716f4591a8190d54c0c6acbdd2e489ad3c824b2..643b6ebdcb8a4e292503b98824edc7938dfd5e7f 100644 --- a/src/main/java/teetime/util/framework/port/PortRemovedListener.java +++ b/src/main/java/teetime/util/framework/port/PortRemovedListener.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package teetime.util.framework.port; import teetime.framework.AbstractPort; diff --git a/src/test/java/teetime/stage/basic/distributor/dynamic/DynamicDistributorTest.java b/src/test/java/teetime/stage/basic/distributor/dynamic/DynamicDistributorTest.java index a8e569c16a8499665e466b9b4d292f7632db6c0c..5aa708499b21bbae96495ccdacd8d3652b5a8120 100644 --- a/src/test/java/teetime/stage/basic/distributor/dynamic/DynamicDistributorTest.java +++ b/src/test/java/teetime/stage/basic/distributor/dynamic/DynamicDistributorTest.java @@ -87,11 +87,11 @@ public class DynamicDistributorTest { final PortContainer<Integer> portContainer2 = new PortContainer<Integer>(); inputActions[0] = createPortCreateAction(portContainer0); - inputActions[1] = new RemovePortAction<Integer>(portContainer0); + inputActions[1] = new RemovePortActionDelegation<Integer>(portContainer0); inputActions[2] = createPortCreateAction(portContainer1); inputActions[3] = createPortCreateAction(portContainer2); - inputActions[4] = new RemovePortAction<Integer>(portContainer1); - inputActions[5] = new RemovePortAction<Integer>(portContainer2); + inputActions[4] = new RemovePortActionDelegation<Integer>(portContainer1); + inputActions[5] = new RemovePortActionDelegation<Integer>(portContainer2); DynamicDistributorTestConfig<Integer> config = new DynamicDistributorTestConfig<Integer>(inputNumbers, Arrays.asList(inputActions)); Execution<DynamicDistributorTestConfig<Integer>> analysis = new Execution<DynamicDistributorTestConfig<Integer>>(config); diff --git a/src/test/java/teetime/stage/basic/distributor/dynamic/PortContainer.java b/src/test/java/teetime/stage/basic/distributor/dynamic/PortContainer.java index 2bf43f5d8a89b94f384d9a2e6fa40cfa2ddd53f7..114c59ed33c388934ad8239fbf5cb52d0ce21499 100644 --- a/src/test/java/teetime/stage/basic/distributor/dynamic/PortContainer.java +++ b/src/test/java/teetime/stage/basic/distributor/dynamic/PortContainer.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package teetime.stage.basic.distributor.dynamic; import teetime.framework.DynamicOutputPort; @@ -9,18 +24,11 @@ import teetime.framework.DynamicOutputPort; * * @param <T> */ -class PortContainer<T> extends DynamicOutputPort<T> { +final class PortContainer<T> { private DynamicOutputPort<T> port; - PortContainer() { - super(null, null, -1); - } - - @Override - public int getIndex() { - return port.getIndex(); - } + PortContainer() {} public void setPort(final DynamicOutputPort<T> port) { this.port = port; diff --git a/src/test/java/teetime/stage/basic/distributor/dynamic/RemovePortActionDelegation.java b/src/test/java/teetime/stage/basic/distributor/dynamic/RemovePortActionDelegation.java new file mode 100644 index 0000000000000000000000000000000000000000..89cd232975bd6bab22989f731936e4b1626c88ed --- /dev/null +++ b/src/test/java/teetime/stage/basic/distributor/dynamic/RemovePortActionDelegation.java @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package teetime.stage.basic.distributor.dynamic; + +import teetime.framework.DynamicOutputPort; +import teetime.util.framework.port.PortAction; + +/** + * Simulates a {@link RemovePortAction} by means of a {@link PortContainer} instead of an {@link DynamicOutputPort}. + * + * @author Christian Wulf + * + * @param <T> + */ +public class RemovePortActionDelegation<T> implements PortAction<DynamicDistributor<T>> { + + private final PortContainer<T> portContainer; + + public RemovePortActionDelegation(final PortContainer<T> portContainer) { + this.portContainer = portContainer; + } + + @Override + public void execute(final DynamicDistributor<T> dynamicDistributor) { + DynamicOutputPort<?> dynamicOutputPort = portContainer.getPort(); + dynamicDistributor.removeDynamicPort(dynamicOutputPort); + } + +}