updated coding rules.
[utils] / system / spring / src / test / java / org / wamblee / system / spring / SpringComponentTest.java
index 10e2ca8eb8a277b3319c9b712b48b53f3ac9a2d9..ff3aeb2429dcc82de2c83ffb215bbff06ea6f7a3 100644 (file)
@@ -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<String> EVENT_TRACKER;
 
-    private Scope _externalScope;
+    private Scope externalScope;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
         EVENT_TRACKER = new EventTracker<String>();
-        _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<String, ProvidedInterface>(),
                 new HashMap<RequiredInterface, String>());
 
-        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<RequiredInterface, String>());
-        Scope runtime = system.start(_externalScope);
-        ProvidedInterface[] services = runtime.getProvidedInterfaces();
+        Scope runtime = system.start(externalScope);
+        List<ProvidedInterface> 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<ProvidedInterface> 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<ProvidedInterface> 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<String, ProvidedInterface>(),
                     new HashMap<RequiredInterface, String>());
-            system.start(_externalScope);
+            system.start(externalScope);
         } catch (SystemAssemblyException e) {
             // e.printStackTrace();
             return;
@@ -158,7 +159,7 @@ public class SpringComponentTest extends TestCase {
                 HelloService.class);
         Scope scope = new DefaultScope(new ProvidedInterface[] { helloService });
         scope.publishInterface(helloService, helloObject);
-        system.getRequiredInterfaces()[0].setProvider(helloService);
+        system.getRequiredInterfaces().get(0).setProvider(helloService);
 
         Scope runtime = system.start(scope);
         system.stop(runtime);
@@ -181,9 +182,9 @@ public class SpringComponentTest extends TestCase {
                 HelloService.class);
         Scope scope = new DefaultScope(new ProvidedInterface[] { helloService });
         scope.publishInterface(helloService, helloObject);
-        system.getRequiredInterfaces()[0].setProvider(helloService);
+        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,22 +208,22 @@ public class SpringComponentTest extends TestCase {
                 new String[] { HELLO_SERVICE_SPRING_XML }, provided,
                 new HashMap<RequiredInterface, String>());
 
-        Scope runtime = system.start(_externalScope);
-        ProvidedInterface[] services = runtime.getProvidedInterfaces();
+        Scope runtime = system.start(externalScope);
+        List<ProvidedInterface> 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
-                .getProvidedInterfaces()[1], Object.class);
+        Object floatsvc = externalScope.getInterfaceImplementation(system
+                .getProvidedInterfaces().get(1), Object.class);
         assertTrue(floatsvc instanceof Float);
         assertTrue((((Float) floatsvc).floatValue() - 100.345f) < 0.00001);
 
@@ -251,8 +252,8 @@ public class SpringComponentTest extends TestCase {
         Scope scope = new DefaultScope(new ProvidedInterface[] { helloService });
         scope.publishInterface(helloService, helloObject);
         scope.publishInterface(floatService, 100.234f);
-        system.getRequiredInterfaces()[0].setProvider(helloService);
-        system.getRequiredInterfaces()[1].setProvider(floatService);
+        system.getRequiredInterfaces().get(0).setProvider(helloService);
+        system.getRequiredInterfaces().get(1).setProvider(floatService);
 
         Scope runtime = system.start(scope);
         system.stop(runtime);