X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;ds=inline;f=trunk%2Fsystem%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcore%2FContainerTest.java;h=ee5b4e50b8112d14600d698ec6c56056625d81ea;hb=b5071279e5091156de7c15cd45697a66b2694495;hp=dfd8ed58fc87484130ba82cb307589701a3c6d52;hpb=f5160588d34e7bbeb9c27414c44c9108fa4cea78;p=utils diff --git a/trunk/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java b/trunk/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java index dfd8ed58..ee5b4e50 100644 --- a/trunk/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java +++ b/trunk/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java @@ -86,8 +86,8 @@ public class ContainerTest extends TestCase { } public void testEnvironmentApplication() { - Component environment = new Environment(_tracker); - Component application = new Application(_tracker); + Environment environment = new Environment(_tracker); + Application application = new Application(_tracker); Container container = new Container("root", new Component[] { environment, application }, new ProvidedInterface[0], new RequiredInterface[0]); @@ -100,6 +100,9 @@ public class ContainerTest extends TestCase { assertEquals(2, envServices.length); ProvidedInterface[] appServices = application.getRunningInterfaces(); assertEquals(0, appServices.length); + + assertEquals(environment.getString(), application.getString()); + assertEquals(environment.getInteger(), application.getInteger()); } @@ -161,7 +164,7 @@ public class ContainerTest extends TestCase { Container system = new Container("all", new Component[] { environment, application }, new ProvidedInterface[] { new DefaultProvidedInterface( - "string", String.class) }, + "float", Float.class) }, new DefaultRequiredInterface[0]); } catch (SystemAssemblyException e) { return; @@ -190,9 +193,9 @@ public class ContainerTest extends TestCase { Container system = new Container("all", new Component[] { environment, application }, new ProvidedInterface[0], new RequiredInterface[] { new DefaultRequiredInterface( - "string", String.class) }); + "float", Float.class) }); system.getRequiredInterfaces()[0] - .setProvider(new DefaultProvidedInterface("hallo", String.class)); + .setProvider(new DefaultProvidedInterface("hallo", Float.class)); system.start(); RequiredInterface[] required = system.getRequiredInterfaces(); assertEquals(1, required.length); @@ -290,6 +293,8 @@ public class ContainerTest extends TestCase { Thread.currentThread()).toArray(new String[0])); ProvidedInterface[] envServices = environment.getRunningInterfaces(); assertEquals(0, envServices.length); + assertNull(environment.getProvidedInterfaces()[0].getImplementation()); + assertNull(environment.getProvidedInterfaces()[0].getImplementation()); return; } fail(); @@ -330,8 +335,56 @@ public class ContainerTest extends TestCase { Thread.currentThread()).toArray(new String[0])); ProvidedInterface[] envServices = environment.getRunningInterfaces(); assertEquals(0, envServices.length); + assertNull(environment.getProvidedInterfaces()[0].getImplementation()); + assertNull(environment.getProvidedInterfaces()[0].getImplementation()); return; } fail(); } + + public void testOptionalRequiredInterfaceProvidedOptionalInternal() { + Application application = new Application(true); + Container container = new Container("top", new Component[] { application }, + new ProvidedInterface[0], Application.required(true)); + Environment env = new Environment(); + container.getRequiredInterfaces()[0].setProvider( + env.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()); + } + + public void testOptionalRequiredInterfaceNotProvidedOptionalInternal() { + Application application = new Application(true); + Container container = new Container("top", new Component[] { application }, + new ProvidedInterface[0], Application.required(true)); + Environment env = new Environment(); + container.getRequiredInterfaces()[0].setProvider( + env.getProvidedInterfaces()[0]); + container.start(); + assertSame(env.getProvidedInterfaces()[0], container.getRequiredInterfaces()[0].getProvider()); + assertNull(container.getRequiredInterfaces()[1].getProvider()); + assertSame(env.getProvidedInterfaces()[0], application.getRequiredInterfaces()[0].getProvider()); + assertNull(application.getRequiredInterfaces()[1].getProvider()); + } + + public void testOptionalRequiredInterfaceProvidedMandatoryInternal() { + Application application = new Application(); + Container container = new Container("top", new Component[] { application }, + new ProvidedInterface[0], Application.required(true)); + Environment env = new Environment(); + container.getRequiredInterfaces()[0].setProvider( + env.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()); + } }