geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r765817 - in /geronimo/sandbox/blueprint/org.apache.felix.blueprint/src: main/java/org/apache/felix/blueprint/context/ test/java/org/apache/felix/blueprint/ test/java/org/apache/felix/blueprint/pojos/ test/resources/
Date Fri, 17 Apr 2009 00:43:34 GMT
Author: gawor
Date: Fri Apr 17 00:43:34 2009
New Revision: 765817

URL: http://svn.apache.org/viewvc?rev=765817&view=rev
Log:
some tests for type conversion

Modified:
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Instanciator.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/WiringTest.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/pojos/PojoA.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/resources/test-wiring.xml

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Instanciator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Instanciator.java?rev=765817&r1=765816&r2=765817&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Instanciator.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/Instanciator.java
Fri Apr 17 00:43:34 2009
@@ -177,7 +177,7 @@
         }
     }
     
-    private Object convert(Object source, Class type) throws Exception {
+    protected Object convert(Object source, Class type) throws Exception {
         return moduleContext.getConversionService().convert(source, type);
     }
     

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/WiringTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/WiringTest.java?rev=765817&r1=765816&r2=765817&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/WiringTest.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/WiringTest.java
Fri Apr 17 00:43:34 2009
@@ -18,12 +18,15 @@
  */
 package org.apache.felix.blueprint;
 
+import java.math.BigInteger;
+import java.net.URI;
 import java.util.Arrays;
 
 import junit.framework.TestCase;
 
 import org.apache.felix.blueprint.context.Instanciator;
 import org.apache.felix.blueprint.context.Parser;
+import org.apache.felix.blueprint.convert.ConversionServiceImpl;
 import org.apache.felix.blueprint.pojos.PojoA;
 import org.apache.felix.blueprint.pojos.PojoB;
 import org.apache.xbean.recipe.ObjectGraph;
@@ -34,7 +37,7 @@
     public void testWiring() throws Exception {
         Parser parser = parse("/test-wiring.xml");
 
-        Instanciator i = new Instanciator(null);
+        Instanciator i = new TestInstanciator();
         Repository repository = i.createRepository(parser.getRegistry());
         ObjectGraph graph = new ObjectGraph(repository);
         
@@ -54,6 +57,8 @@
         assertNotNull(pojoa.getList());
         assertEquals("list value", pojoa.getList().get(0));
         assertEquals(pojob, pojoa.getList().get(1));
+        assertEquals(new Integer(55), pojoa.getList().get(2));
+        assertEquals(URI.create("http://geronimo.apache.org"), pojoa.getList().get(3));
         
         assertNotNull(pojoa.getSet());
         assertTrue(pojoa.getSet().contains("set value"));
@@ -61,7 +66,10 @@
         
         assertNotNull(pojoa.getMap());
         assertEquals("val", pojoa.getMap().get("key"));
-        assertEquals(pojob, pojoa.getMap().get(pojob));        
+        assertEquals(pojob, pojoa.getMap().get(pojob));      
+        
+        assertNotNull(pojoa.getNumber());
+        assertEquals(new BigInteger("10"), pojoa.getNumber());
     }
 
     protected Parser parse(String name) throws Exception {
@@ -70,4 +78,17 @@
         return parser;
     }
 
+    private static class TestInstanciator extends Instanciator {
+        ConversionServiceImpl conversionService = new ConversionServiceImpl();
+        
+        public TestInstanciator() {
+            super(null);
+        }
+        
+        @Override
+        public Object convert(Object source, Class type) throws Exception {
+            return conversionService.convert(source, type);
+        }
+        
+    }
 }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/pojos/PojoA.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/pojos/PojoA.java?rev=765817&r1=765816&r2=765817&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/pojos/PojoA.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/java/org/apache/felix/blueprint/pojos/PojoA.java
Fri Apr 17 00:43:34 2009
@@ -28,6 +28,7 @@
     private List list;
     private Set set;
     private Map map;
+    private Number number;
 
     public PojoA() {
     }
@@ -68,6 +69,14 @@
         this.pojob = pojob;
     }
 
+    public void setNumber(Number number) {
+        this.number = number;
+    }
+    
+    public Number getNumber() {
+        return number;
+    }
+    
     public void start() {
         System.out.println("Starting component " + this);
     }

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/resources/test-wiring.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/resources/test-wiring.xml?rev=765817&r1=765816&r2=765817&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/resources/test-wiring.xml
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/test/resources/test-wiring.xml
Fri Apr 17 00:43:34 2009
@@ -26,8 +26,13 @@
             <list>
                 <value>list value</value>
                 <ref component="pojoB" />
+                <value type="java.lang.Integer">55</value>
+                <value type="java.net.URI">http://geronimo.apache.org</value>
             </list>
         </property>
+        <property name="number">
+            <value type="java.math.BigInteger">10</value>
+        </property>
     </component>
 
 </components>
\ No newline at end of file



Mime
View raw message