rename subsystem to component.
[utils] / trunk / system / spring / src / test / java / org / wamblee / system / spring / SpringSystemTest.java
index 092a5bc11e47907ce74c93387388893ef8e55873..1543b7ab8cd39067b6d9a9aa64450c9a733a8669 100644 (file)
@@ -5,10 +5,14 @@ import java.util.Map;
 
 import junit.framework.TestCase;
 
-import org.wamblee.system.DefaultServiceDescriptor;
+import org.wamblee.system.AbstractInterfaceDescriptor;
+import org.wamblee.system.DefaultProvidedInterfaceDescriptor;
+import org.wamblee.system.DefaultRequiredInterfaceDescriptor;
 import org.wamblee.system.DefaultServiceRegistry;
+import org.wamblee.system.ProvidedInterfaceDescriptor;
+import org.wamblee.system.RequiredInterfaceDescriptor;
 import org.wamblee.system.Service;
-import org.wamblee.system.ServiceDescriptor;
+import org.wamblee.system.InterfaceDescriptor;
 import org.wamblee.system.ServiceRegistry;
 import org.wamblee.system.SystemAssemblyException;
 
@@ -28,8 +32,8 @@ public class SpringSystemTest extends TestCase {
        public void testBlackboxSystem() {
                SpringSystem system = new SpringSystem("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_XML },
-                               new HashMap<String, ServiceDescriptor>(),
-                               new HashMap<ServiceDescriptor, String>());
+                               new HashMap<String, ProvidedInterfaceDescriptor>(),
+                               new HashMap<RequiredInterfaceDescriptor, String>());
                system.start("Hello", new Service[0]);
                Service[] services = system.getRunningServices();
                assertEquals(0, services.length);
@@ -38,13 +42,13 @@ public class SpringSystemTest extends TestCase {
        }
 
        public void testOneProvidedService() {
-               Map<String, ServiceDescriptor> provided = new HashMap<String, ServiceDescriptor>();
-               provided.put("helloService", new DefaultServiceDescriptor(
-                               HelloService.class));
+               Map<String, ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
+               provided.put("helloService", new DefaultProvidedInterfaceDescriptor(
+                               "hello", HelloService.class));
 
                SpringSystem system = new SpringSystem("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_XML }, provided,
-                               new HashMap<ServiceDescriptor, String>());
+                               new HashMap<RequiredInterfaceDescriptor, String>());
                system.start("Hello", new Service[0]);
                Service[] services = system.getRunningServices();
                assertEquals(1, services.length);
@@ -58,8 +62,8 @@ public class SpringSystemTest extends TestCase {
                try {
                        SpringSystem system = new SpringSystem("system", _registry,
                                        new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML },
-                                       new HashMap<String, ServiceDescriptor>(),
-                                       new HashMap<ServiceDescriptor, String>());
+                                       new HashMap<String, ProvidedInterfaceDescriptor>(),
+                                       new HashMap<RequiredInterfaceDescriptor, String>());
                        system.start("Bla", new Service[0]);
                } catch (SystemAssemblyException e) {
                        //e.printStackTrace();
@@ -69,25 +73,25 @@ public class SpringSystemTest extends TestCase {
        }
 
        public void testWithRequirement() {
-               Map<ServiceDescriptor, String> required = new HashMap<ServiceDescriptor, String>();
-               required.put(new DefaultServiceDescriptor(HelloService.class),
+               Map<RequiredInterfaceDescriptor, String> required = new HashMap<RequiredInterfaceDescriptor, String>();
+               required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
                                "helloService");
                SpringSystem system = new SpringSystem("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML },
-                               new HashMap<String, ServiceDescriptor>(), required);
+                               new HashMap<String, ProvidedInterfaceDescriptor>(), required);
                
                HelloService helloObject = new HelloService("ladida"); 
-               Service helloService = _registry.register(new DefaultServiceDescriptor(HelloService.class), helloObject);
+               Service helloService = _registry.register(new DefaultProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
                system.start("Bla", new Service[] { helloService } );
                system.stop();
        }
        
        public void testWithRequirementAndProvidedService() {
-               Map<ServiceDescriptor, String> required = new HashMap<ServiceDescriptor, String>();
-               required.put(new DefaultServiceDescriptor(HelloService.class),
+               Map<RequiredInterfaceDescriptor, String> required = new HashMap<RequiredInterfaceDescriptor, String>();
+               required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
                                "helloService");
-               Map<String,ServiceDescriptor> provided = new HashMap<String, ServiceDescriptor>();
-               provided.put("blaService", new DefaultServiceDescriptor(
+               Map<String,ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
+               provided.put("blaService", new DefaultProvidedInterfaceDescriptor("bla",
                                BlaService.class));
 
                SpringSystem system = new SpringSystem("system", _registry,
@@ -95,7 +99,7 @@ public class SpringSystemTest extends TestCase {
                                provided, required);
                
                HelloService helloObject = new HelloService("ladida"); 
-               Service helloService = _registry.register(new DefaultServiceDescriptor(HelloService.class), helloObject);
+               Service helloService = _registry.register(new DefaultProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
                Service[] services = system.start("Bla", new Service[] { helloService } );
                assertEquals(1, services.length);