*/
package org.wamblee.system.core;
+import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;
environment, application }, new ProvidedInterface[0],
new RequiredInterface[0]);
+ Scope scope = container.start();
+ assertTrue(container.isSealed());
+ AssertionUtils.assertEquals(new String[] { "start.environment",
+ "start.application" }, _tracker.getEvents(
+ Thread.currentThread()).toArray(new String[0]));
+ assertEquals(0, scope.getProvidedInterfaces().length);
+
+ assertEquals(environment.getString(), application.getString());
+ assertEquals(environment.getInteger(), application.getInteger());
+
+ }
+
+ public void testEnvironmentApplicationSimpleConstructor() {
+ Environment environment = new Environment(_tracker);
+ Application application = new Application(_tracker);
+ Container container = new Container("root").
+ addComponent(environment).addComponent(application);
+
Scope scope = container.start();
AssertionUtils.assertEquals(new String[] { "start.environment",
"start.application" }, _tracker.getEvents(
assertSame(env.getProvidedInterfaces()[0], application.getRequiredInterfaces()[0].getProvider());
assertSame(env.getProvidedInterfaces()[1], application.getRequiredInterfaces()[1].getProvider());
}
+
+ public void testSealed() {
+ final Container container = new Container("xx");
+ assertFalse(container.isSealed());
+ container.start();
+ assertTrue(container.isSealed());
+
+ AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
+ @Override
+ public void run() throws Exception {
+ container.addComponent(new Application());
+ }
+ }, SystemAssemblyException.class);
+
+ AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
+ @Override
+ public void run() throws Exception {
+ container.addProvidedInterface(new DefaultProvidedInterface("xx", String.class));
+ }
+ }, SystemAssemblyException.class);
+
+ AssertionUtils.assertException(new AssertionUtils.ErroneousCode() {
+ @Override
+ public void run() throws Exception {
+ container.addRequiredInterface(new DefaultRequiredInterface("xx", String.class));
+ }
+ }, SystemAssemblyException.class);
+ }
}