SpringComponent now supports adding properties as beans instead of
[utils] / system / spring / src / test / java / org / wamblee / system / spring / SpringComponentTest.java
index 170297fa2c3f5ec0b3ce297e9920c979f6e5d7b3..3e63c7eaba4ee1b18b5399d9c3a7dca40bda7df4 100644 (file)
@@ -37,6 +37,8 @@ public class SpringComponentTest extends TestCase {
        private static final String HELLO_SERVICE_SPRING_XML = "test.org.wamblee.system.spring.xml";
        private static final String HELLO_SERVICE_SPRING_WITH_REQS_XML = "test.org.wamblee.system.springWithRequirements.xml";
        private static final String HELLO_SERVICE_SPRING_WITH_PROPERTIES_XML = "test.org.wamblee.system.springWithProperties.xml";
+       private static final String HELLO_SERVICE_SPRING_WITH_PROPERTIES_XML2 = "test.org.wamblee.system.springWithProperties2.xml";
+           
        private static final String PROPERTY_FILE = "test.org.wamblee.system.spring.properties";
        
        public static EventTracker<String> EVENT_TRACKER;
@@ -103,6 +105,25 @@ public class SpringComponentTest extends TestCase {
                ProvidedInterface[] services = scope.getProvidedInterfaces();
                assertEquals("Property Value", scope.getInterfaceImplementation(services[0], HelloService.class).say());
        }
+       
+       public void testWithPropertiesAsBean() throws IOException {
+        Map<String, ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
+        provided.put("helloService", new DefaultProvidedInterface("hello",
+                HelloService2.class));
+        SpringComponent system = new SpringComponent("system",
+                new String[] { HELLO_SERVICE_SPRING_WITH_PROPERTIES_XML2 },
+                provided, new HashMap<RequiredInterface, String>());
+        Properties props = new Properties();
+        props.load(new ClassPathResource(PROPERTY_FILE).getInputStream());
+        system.addProperties("properties", props);
+
+        Scope scope = system.start(_externalScope);
+        
+        ProvidedInterface[] services = scope.getProvidedInterfaces();
+        
+        Properties props2 = scope.getInterfaceImplementation(services[0], HelloService2.class).getProperties();
+        assertEquals(props, props2);
+    }
 
        public void testWithMissingRequirement() {
                try {