Added getStatus() method and now also testing for the correct status.
[utils] / system / general / src / test / java / org / wamblee / system / SystemAssemblerTest.java
index 885cff39739a748fbd1e015c4f45f66b461128db..ab8bae6902debd4b49c16554c57345166f9f19fd 100644 (file)
@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
 
+import org.wamblee.system.Component.Status;
 import org.wamblee.test.AssertionUtils;
 
 import junit.framework.TestCase;
@@ -98,21 +99,32 @@ public class SystemAssemblerTest extends TestCase {
        public void testComposite() {
                Component environment = new Environment(_registry);
                Component application = new Application(_registry);
-               CompositeSystem system = new CompositeSystem("all", _registry,
+               assertEquals(Status.NOT_STARTED, environment.getStatus());
+               assertEquals(Status.NOT_STARTED, application.getStatus());
+               CompositeComponent system = new CompositeComponent("all", _registry,
                                new Component[] { environment, application },
                                new InterfaceDescriptor[0], new InterfaceDescriptor[0]);
+               assertEquals(Status.NOT_STARTED, system.getStatus());
                system.start("root", new Service[0]);
                InterfaceDescriptor[] required = system.getRequiredServices();
                assertEquals(0, required.length);
                InterfaceDescriptor[] provided = system.getProvidedServices();
                assertEquals(0, provided.length);
+               assertEquals(Status.RUNNING, environment.getStatus());
+               assertEquals(Status.RUNNING, application.getStatus());
+               assertEquals(Status.RUNNING, system.getStatus());
+               
+               system.stop();
+               assertEquals(Status.STOPPED, environment.getStatus());
+               assertEquals(Status.STOPPED, application.getStatus());
+               assertEquals(Status.STOPPED, system.getStatus());
        }
 
        public void testCompositeWithWrongProvidedInfo() {
                try {
                        Component environment = new Environment(_registry);
                        Component application = new Application(_registry);
-                       CompositeSystem system = new CompositeSystem(
+                       CompositeComponent system = new CompositeComponent(
                                        "all",
                                        _registry,
                                        new Component[] { environment, application },
@@ -128,7 +140,7 @@ public class SystemAssemblerTest extends TestCase {
        public void testCompositeWithSuperfluousRequiredInfo() {
                Component environment = new Environment(_registry);
                Component application = new Application(_registry);
-               CompositeSystem system = new CompositeSystem("all", _registry,
+               CompositeComponent system = new CompositeComponent("all", _registry,
                                new Component[] { environment, application },
                                new InterfaceDescriptor[0],
                                new InterfaceDescriptor[] { new DefaultRequiredInterfaceDescriptor(
@@ -144,7 +156,7 @@ public class SystemAssemblerTest extends TestCase {
                try {
                        Component environment = new Environment(_registry);
                        Component application = new Application(_registry);
-                       CompositeSystem system = new CompositeSystem("all", _registry,
+                       CompositeComponent system = new CompositeComponent("all", _registry,
                                        new Component[] { application }, new InterfaceDescriptor[0],
                                        application.getRequiredServices());
                        system.start("root", new Service[0]);
@@ -159,7 +171,7 @@ public class SystemAssemblerTest extends TestCase {
 
                Component environment = new Environment(_registry);
                Component application = new Application(_registry);
-               CompositeSystem system = new CompositeSystem("all", _registry,
+               CompositeComponent system = new CompositeComponent("all", _registry,
                                new Component[] { application }, new InterfaceDescriptor[0],
                                application.getRequiredServices());
                Service[] envServices = environment.start("env", new Service[0]);