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.
public void connectRequiredProvided(String aClientComponent, String aRequiredInterface,
String aServerComponent, String aProvidedInterface) {
checkSealed();
+ // TODO validate
_edgeFilter.add(new ConnectRequiredProvidedEdgeFilter(aClientComponent, aRequiredInterface, aServerComponent, aProvidedInterface));
}
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));
}
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()));
+ }
}