return;
}
fail();
-
}
public void testDuplicateComponent() {
fail();
}
+
public void testInconsistentHierarchy() {
try {
Component comp = new Application();
Thread.currentThread()).toArray(new String[0]));
}
-
- public void testNonUniqueRequiredInterface() {
+
+ public void testNonUniqueRequiredInterface() {
final Container container = new Container("top");
- container.addRequiredInterface(new DefaultRequiredInterface("i", Integer.class));
- container.addRequiredInterface(new DefaultRequiredInterface("x", String.class));
- container.addRequiredInterface(new DefaultRequiredInterface("y", String.class));
-
+ container.addRequiredInterface(new DefaultRequiredInterface("i",
+ Integer.class));
+ container.addRequiredInterface(new DefaultRequiredInterface("x",
+ String.class));
+ container.addRequiredInterface(new DefaultRequiredInterface("y",
+ String.class));
+
Application app = new Application("1");
container.addComponent(app);
-
- AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
+ AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
@Override
public void run() throws Exception {
- container.start();
+ container.start();
}
}, SystemAssemblyException.class);
-
- container.connectExternalRequired("1", app.getRequiredInterfaces()[0].getName(),
- "y");
-
+
+ container.connectExternalRequired("1", app.getRequiredInterfaces()[0]
+ .getName(), "y");
+
ProvidedInterface i = new DefaultProvidedInterface("i", Integer.class);
ProvidedInterface x = new DefaultProvidedInterface("x", String.class);
ProvidedInterface y = new DefaultProvidedInterface("y", String.class);
-
+
Scope externalScope = new DefaultScope(new ProvidedInterface[0]);
-
+
externalScope.publishInterface(i, 100);
externalScope.publishInterface(x, "x-value");
externalScope.publishInterface(y, "y-value");
-
+
container.getRequiredInterfaces()[0].setProvider(i);
container.getRequiredInterfaces()[1].setProvider(x);
container.getRequiredInterfaces()[2].setProvider(y);
-
+
Scope runtime = container.start(externalScope);
-
+
assertEquals("y-value", app.getString());
-
+
}
-
- public void testNonUniqueProvidedInterface() {
-
- final Container container = new Container("top").addProvidedInterface(new DefaultProvidedInterface("external", String.class));
+
+ 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(env1);
container.addComponent(env2);
-
- AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
+
+ AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
@Override
public void run() throws Exception {
- container.start();
+ container.start();
}
}, SystemAssemblyException.class);
-
+
// now choose env2
-
- container.connectExternalProvided(container.getProvidedInterfaces()[0].getName(),
- env2.getName(), env2.getProvidedInterfaces()[0].getName());
-
+
+ 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);
+
+ String value = scope.getInterfaceImplementation(container
+ .getProvidedInterfaces()[0], String.class);
assertNotNull(value);
assertEquals(value, env2.getString());
assertFalse(value.equals(env1.getString()));