From: erik Date: Tue, 27 May 2008 18:00:45 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.2~1^2~95 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=72a3282da475e8b9e7a6c7395412ca7936c7ee8e;p=utils --- 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())); + } }