Removed InterfaceRestriction. Now introduced a friendlier API in
[utils] / system / general / src / test / java / org / wamblee / system / container / ContainerTest.java
index 95d7e312f0d77ced6cc3c9eceba0d41885d7bee7..c4f64ba88eee53a6651bb1b7b0ee46c2cfa31e65 100644 (file)
@@ -398,15 +398,12 @@ public class ContainerTest extends TestCase {
                 .getProvidedInterfaces()[0]);
         container.getRequiredInterfaces()[1].setProvider(env
                 .getProvidedInterfaces()[1]);
-        container.start();
-        assertSame(env.getProvidedInterfaces()[0], container
-                .getRequiredInterfaces()[0].getProvider());
-        assertSame(env.getProvidedInterfaces()[1], container
-                .getRequiredInterfaces()[1].getProvider());
-        assertSame(env.getProvidedInterfaces()[0], application
-                .getRequiredInterfaces()[0].getProvider());
-        assertSame(env.getProvidedInterfaces()[1], application
-                .getRequiredInterfaces()[1].getProvider());
+        try {
+            container.start();
+        } catch (SystemAssemblyException e) {
+            return;
+        }
+        fail();
     }
 
     public void testSealed() {
@@ -425,14 +422,19 @@ public class ContainerTest extends TestCase {
         AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
             @Override
             public void run() throws Exception {
-                container.addRestriction(new InterfaceRestriction() {
-                    @Override
-                    public boolean isViolated(Component aClient,
-                            RequiredInterface aRequired, Component aServer,
-                            ProvidedInterface aProvided) {
-                        return false;
-                    }
-                });
+                container.connectRequiredProvided("x", "y", "a", "b");
+            }
+        }, SystemAssemblyException.class);
+        AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
+            @Override
+            public void run() throws Exception {
+                container.connectExternalRequired("x", "y", "a");
+            }
+        }, SystemAssemblyException.class);
+        AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
+            @Override
+            public void run() throws Exception {
+                container.connectExternalProvided("x", "y", "z");
             }
         }, SystemAssemblyException.class);
         AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
@@ -458,8 +460,7 @@ public class ContainerTest extends TestCase {
         Application app = new Application("app");
         Container container = new Container("top").addComponent(env1)
                 .addComponent(env2).addComponent(app);
-        container.addRestriction(new DefaultInterfaceRestriction("app", null,
-                "env1", null));
+        container.connectRequiredProvided("app", null, "env1", null);
         container.start();
         assertEquals(env1.getString(), app.getString());
         assertFalse(env2.getString().equals(app.getString()));
@@ -521,9 +522,9 @@ public class ContainerTest extends TestCase {
         top.addComponent(envcontainer).addComponent(appcontainer);
 
         top.start();
-        AssertionUtils.assertEquals(new String[] { "start.environment", "start.application" },
-                _tracker.getEvents(Thread.currentThread()).toArray(
-                        new String[0]));
+        AssertionUtils.assertEquals(new String[] { "start.environment",
+                "start.application" }, _tracker.getEvents(
+                Thread.currentThread()).toArray(new String[0]));
 
     }
 }