(no commit message)
authorErik Brakkee <erik@brakkee.org>
Tue, 27 May 2008 18:00:45 +0000 (18:00 +0000)
committerErik Brakkee <erik@brakkee.org>
Tue, 27 May 2008 18:00:45 +0000 (18:00 +0000)
system/general/src/main/java/org/wamblee/system/container/Container.java
system/general/src/main/java/org/wamblee/system/graph/component/ExternalProvidedInterfaceNode.java
system/general/src/test/java/org/wamblee/system/container/ContainerTest.java

index dc45dd7d0ef7e1f5d70fd7fecf3cc2abbe1dd4fb..a69ac98eb7c41732527350327e3fdf48aa2193f4 100644 (file)
@@ -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.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.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.ConnectRequiredExternallyRequiredEdgeFilter;
 import org.wamblee.system.graph.component.ConnectRequiredProvidedEdgeFilter;
-import org.wamblee.system.graph.component.RequiredProvidedEdgeFactory;
 
 /**
  * Container consisting of multiple components.
 
 /**
  * Container consisting of multiple components.
@@ -111,6 +110,7 @@ public class Container extends AbstractComponent<Scope> {
     public void connectRequiredProvided(String aClientComponent, String aRequiredInterface, 
             String aServerComponent, String aProvidedInterface) {
         checkSealed();
     public void connectRequiredProvided(String aClientComponent, String aRequiredInterface, 
             String aServerComponent, String aProvidedInterface) {
         checkSealed();
+        // TODO validate 
         _edgeFilter.add(new ConnectRequiredProvidedEdgeFilter(aClientComponent, aRequiredInterface, aServerComponent, aProvidedInterface));
     }
     
         _edgeFilter.add(new ConnectRequiredProvidedEdgeFilter(aClientComponent, aRequiredInterface, aServerComponent, aProvidedInterface));
     }
     
@@ -123,14 +123,15 @@ public class Container extends AbstractComponent<Scope> {
     public void connectExternalRequired(String aComponent, String aRequiredInterface, 
             String aExternalRequiredInterface) {
         checkSealed();
     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();
         _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));
     }
 
 
     }
 
 
index 9f91447cd8f2ba54e5688f07829fb09a93c7a30f..c7fd7d0b432c18bd02b41154f0923fa2c82858dd 100644 (file)
@@ -46,4 +46,9 @@ public class ExternalProvidedInterfaceNode implements Node {
     public ProvidedInterface getProvided() {
         return _provided;
     }
     public ProvidedInterface getProvided() {
         return _provided;
     }
+    
+    @Override
+    public String toString() {
+        return _component.getQualifiedName() + ":" + _provided; 
+    }
 }
 }
index 156d4dd6f4222c6748d414287d9a4d71c7d87c1c..cc18db2e50bac0a1c11fe3886fc10583db8e393c 100644 (file)
@@ -567,4 +567,36 @@ public class ContainerTest extends TestCase {
         assertEquals("y-value", app.getString());
         
     }
         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()));
+    }
 }
 }