X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fspring%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fspring%2FSpringComponentTest.java;h=ff3aeb2429dcc82de2c83ffb215bbff06ea6f7a3;hb=0d8d8f24656e585ee75558cfd6a4c661f8f14985;hp=67ed048df8f19dbaed681191c855686d785486ac;hpb=2d1fd76ec884b5fc7be4078020fdf14d17166e8a;p=utils diff --git a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java index 67ed048d..ff3aeb24 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java @@ -17,6 +17,7 @@ package org.wamblee.system.spring; import java.io.IOException; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Properties; @@ -43,13 +44,13 @@ public class SpringComponentTest extends TestCase { public static EventTracker EVENT_TRACKER; - private Scope _externalScope; + private Scope externalScope; @Override protected void setUp() throws Exception { super.setUp(); EVENT_TRACKER = new EventTracker(); - _externalScope = new DefaultScope(new ProvidedInterface[0]); + externalScope = new DefaultScope(new ProvidedInterface[0]); } public void testBlackboxSystem() { @@ -58,8 +59,8 @@ public class SpringComponentTest extends TestCase { new HashMap(), new HashMap()); - Scope runtime = system.start(_externalScope); - assertEquals(0, _externalScope.getProvidedInterfaces().length); + Scope runtime = system.start(externalScope); + assertEquals(0, externalScope.getProvidedInterfaces().size()); system.stop(runtime); } @@ -72,17 +73,17 @@ public class SpringComponentTest extends TestCase { SpringComponent system = new SpringComponent("system", new String[] { HELLO_SERVICE_SPRING_XML }, provided, new HashMap()); - Scope runtime = system.start(_externalScope); - ProvidedInterface[] services = runtime.getProvidedInterfaces(); + Scope runtime = system.start(externalScope); + List services = runtime.getProvidedInterfaces(); - assertEquals(1, services.length); - Object service = runtime.getInterfaceImplementation(services[0], + assertEquals(1, services.size()); + Object service = runtime.getInterfaceImplementation(services.get(0), Object.class); assertTrue(service instanceof HelloService); // BUG; Provided services should be made available in the external // scope. - Object service2 = _externalScope.getInterfaceImplementation(provided + Object service2 = externalScope.getInterfaceImplementation(provided .get("helloService"), Object.class); assertSame(service, service2); @@ -101,14 +102,14 @@ public class SpringComponentTest extends TestCase { props.load(new ClassPathResource(PROPERTY_FILE).getInputStream()); system.addProperties(props); - Scope scope = system.start(_externalScope); + Scope scope = system.start(externalScope); // BUG: Hello service was constructed multiple times. Once with the // unprocessed property // and another time with the processed property. assertEquals(1, EVENT_TRACKER.getEventCount()); - ProvidedInterface[] services = scope.getProvidedInterfaces(); + List services = scope.getProvidedInterfaces(); assertEquals("Property Value", scope.getInterfaceImplementation( - services[0], HelloService.class).say()); + services.get(0), HelloService.class).say()); } public void testWithPropertiesAsBean() throws IOException { @@ -122,11 +123,11 @@ public class SpringComponentTest extends TestCase { props.load(new ClassPathResource(PROPERTY_FILE).getInputStream()); system.addProperties("properties", props); - Scope scope = system.start(_externalScope); + Scope scope = system.start(externalScope); - ProvidedInterface[] services = scope.getProvidedInterfaces(); + List services = scope.getProvidedInterfaces(); - Properties props2 = scope.getInterfaceImplementation(services[0], + Properties props2 = scope.getInterfaceImplementation(services.get(0), HelloService2.class).getProperties(); assertEquals(props, props2); } @@ -137,7 +138,7 @@ public class SpringComponentTest extends TestCase { new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML }, new HashMap(), new HashMap()); - system.start(_externalScope); + system.start(externalScope); } catch (SystemAssemblyException e) { // e.printStackTrace(); return; @@ -183,7 +184,7 @@ public class SpringComponentTest extends TestCase { scope.publishInterface(helloService, helloObject); system.getRequiredInterfaces().get(0).setProvider(helloService); Scope runtime = system.start(scope); - ProvidedInterface started = runtime.getProvidedInterfaces()[0]; + ProvidedInterface started = runtime.getProvidedInterfaces().get(0); Object impl = runtime.getInterfaceImplementation(started, BlaService.class); @@ -207,21 +208,21 @@ public class SpringComponentTest extends TestCase { new String[] { HELLO_SERVICE_SPRING_XML }, provided, new HashMap()); - Scope runtime = system.start(_externalScope); - ProvidedInterface[] services = runtime.getProvidedInterfaces(); + Scope runtime = system.start(externalScope); + List services = runtime.getProvidedInterfaces(); - assertEquals(2, services.length); - Object service = runtime.getInterfaceImplementation(services[0], + assertEquals(2, services.size()); + Object service = runtime.getInterfaceImplementation(services.get(0), Object.class); assertTrue(service instanceof HelloService); // BUG; Provided services should be made available in the external // scope. - Object service2 = _externalScope.getInterfaceImplementation(provided + Object service2 = externalScope.getInterfaceImplementation(provided .get("helloService"), Object.class); assertSame(service, service2); - Object floatsvc = _externalScope.getInterfaceImplementation(system + Object floatsvc = externalScope.getInterfaceImplementation(system .getProvidedInterfaces().get(1), Object.class); assertTrue(floatsvc instanceof Float); assertTrue((((Float) floatsvc).floatValue() - 100.345f) < 0.00001);