+
+ 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()));
+ }