From 9edb5809a67730abf512ed68ecd8d3cf47ceb0b1 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Tue, 27 May 2008 18:00:45 +0000 Subject: [PATCH 1/1] --- .../wamblee/system/container/Container.java | 9 +++--- .../ExternalProvidedInterfaceNode.java | 5 +++ .../system/container/ContainerTest.java | 32 +++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/system/general/src/main/java/org/wamblee/system/container/Container.java b/system/general/src/main/java/org/wamblee/system/container/Container.java index dc45dd7d..a69ac98e 100644 --- a/system/general/src/main/java/org/wamblee/system/container/Container.java +++ b/system/general/src/main/java/org/wamblee/system/container/Container.java @@ -31,11 +31,10 @@ import org.wamblee.system.core.RequiredInterface; import org.wamblee.system.core.Scope; import org.wamblee.system.core.SystemAssemblyException; import org.wamblee.system.graph.CompositeEdgeFilter; -import org.wamblee.system.graph.EdgeFilter; import org.wamblee.system.graph.component.ComponentGraph; +import org.wamblee.system.graph.component.ConnectExternalProvidedProvidedFilter; import org.wamblee.system.graph.component.ConnectRequiredExternallyRequiredEdgeFilter; import org.wamblee.system.graph.component.ConnectRequiredProvidedEdgeFilter; -import org.wamblee.system.graph.component.RequiredProvidedEdgeFactory; /** * Container consisting of multiple components. @@ -111,6 +110,7 @@ public class Container extends AbstractComponent { public void connectRequiredProvided(String aClientComponent, String aRequiredInterface, String aServerComponent, String aProvidedInterface) { checkSealed(); + // TODO validate _edgeFilter.add(new ConnectRequiredProvidedEdgeFilter(aClientComponent, aRequiredInterface, aServerComponent, aProvidedInterface)); } @@ -123,14 +123,15 @@ public class Container extends AbstractComponent { public void connectExternalRequired(String aComponent, String aRequiredInterface, String aExternalRequiredInterface) { checkSealed(); + // TODO validate _edgeFilter.add(new ConnectRequiredExternallyRequiredEdgeFilter( aComponent, aRequiredInterface, aExternalRequiredInterface)); } public void connectExternalProvided(String aExternalProvided, String aComponent, String aProvidedInterface) { checkSealed(); - // TODO implement. - throw new RuntimeException("not implemented"); + // TODO validate + _edgeFilter.add(new ConnectExternalProvidedProvidedFilter(aExternalProvided, aComponent, aProvidedInterface)); } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/ExternalProvidedInterfaceNode.java b/system/general/src/main/java/org/wamblee/system/graph/component/ExternalProvidedInterfaceNode.java index 9f91447c..c7fd7d0b 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/ExternalProvidedInterfaceNode.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/ExternalProvidedInterfaceNode.java @@ -46,4 +46,9 @@ public class ExternalProvidedInterfaceNode implements Node { public ProvidedInterface getProvided() { return _provided; } + + @Override + public String toString() { + return _component.getQualifiedName() + ":" + _provided; + } } diff --git a/system/general/src/test/java/org/wamblee/system/container/ContainerTest.java b/system/general/src/test/java/org/wamblee/system/container/ContainerTest.java index 156d4dd6..cc18db2e 100644 --- a/system/general/src/test/java/org/wamblee/system/container/ContainerTest.java +++ b/system/general/src/test/java/org/wamblee/system/container/ContainerTest.java @@ -567,4 +567,36 @@ public class ContainerTest extends TestCase { assertEquals("y-value", app.getString()); } + + public void testNonUniqueProvidedInterface() { + + final Container container = new Container("top").addProvidedInterface(new DefaultProvidedInterface("external", String.class)); + Environment env1 = new Environment("env1"); + Environment env2 = new Environment("env2"); + + + container.addComponent(env1); + container.addComponent(env2); + + AssertionUtils.assertException(new AssertionUtils.ErroneousCode() { + @Override + public void run() throws Exception { + container.start(); + } + }, SystemAssemblyException.class); + + // now choose env2 + + container.connectExternalProvided(container.getProvidedInterfaces()[0].getName(), + env2.getName(), env2.getProvidedInterfaces()[0].getName()); + + Scope scope = container.start(); + + // check the value of the provided interface of the container + + String value = scope.getInterfaceImplementation(container.getProvidedInterfaces()[0], String.class); + assertNotNull(value); + assertEquals(value, env2.getString()); + assertFalse(value.equals(env1.getString())); + } } -- 2.31.1