geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r548538 - in /geronimo/xbean/trunk/xbean-spring/src: main/java/org/apache/xbean/spring/generator/ test/java/org/apache/xbean/spring/context/ test/java/org/apache/xbean/spring/example/ test/resources/org/apache/xbean/spring/context/
Date Tue, 19 Jun 2007 00:44:00 GMT
Author: djencks
Date: Mon Jun 18 17:43:59 2007
New Revision: 548538

URL: http://svn.apache.org/viewvc?view=rev&rev=548538
Log:
XBEAN-89 allow all kinds of collections, not just lists

Modified:
    geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RestaurantUsingSpringTest.java
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RestaurantService.java
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-normal.xml
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-spring-extended.xml
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-mixed.xml
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-root.xml
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-simple.xml
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean.xml

Modified: geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java?view=diff&rev=548538&r1=548537&r2=548538
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
Mon Jun 18 17:43:59 2007
@@ -61,7 +61,7 @@
     private final String defaultNamespace;
     private final File[] srcDirs;
     private final String[] excludedClasses;
-    private Type listType;
+    private Type collectionType;
 
     public QdoxMappingLoader(String defaultNamespace, File[] srcDirs, String[] excludedClasses)
{
         this.defaultNamespace = defaultNamespace;
@@ -97,7 +97,7 @@
             }
         }
 
-        listType = builder.getClassByName("java.util.List").asType();
+        collectionType = builder.getClassByName("java.util.Collection").asType();
         Set namespaces = loadNamespaces(builder);
         return namespaces;
     }
@@ -497,7 +497,7 @@
         try {
             if (type.isArray()) {
                 return org.apache.xbean.spring.generator.Type.newArrayType(type.getValue(),
type.getDimensions());
-            } else if (type.isA(listType)) {
+            } else if (type.isA(collectionType)) {
                 if (nestedType == null) nestedType = "java.lang.Object";
                 return org.apache.xbean.spring.generator.Type.newCollectionType(type.getValue(),
                         org.apache.xbean.spring.generator.Type.newSimpleType(nestedType));

Modified: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RestaurantUsingSpringTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RestaurantUsingSpringTest.java?view=diff&rev=548538&r1=548537&r2=548538
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RestaurantUsingSpringTest.java
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RestaurantUsingSpringTest.java
Mon Jun 18 17:43:59 2007
@@ -16,14 +16,15 @@
  */
 package org.apache.xbean.spring.context;
 
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.apache.xbean.spring.example.PizzaService;
-import org.apache.xbean.spring.example.RestaurantService;
-
 import java.util.List;
+import java.util.Set;
 
 import javax.xml.namespace.QName;
 
+import org.apache.xbean.spring.example.PizzaService;
+import org.apache.xbean.spring.example.RestaurantService;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
 /**
  * @author James Strachan
  * @version $Id$
@@ -36,7 +37,7 @@
 
         QName service = restaurant.getServiceName();
         assertEquals(new QName("http://acme.com", "xyz"), service);
-        
+
         // dinners (1-many using list)
         List dinners = restaurant.getDinnerMenu();
         assertNotNull("dinners is null!", dinners);
@@ -46,12 +47,28 @@
         assertEquals("topping", "Ham", pizza.getTopping());
         assertEquals("cheese", "Mozzarella", pizza.getCheese());
         assertEquals("size", 15, pizza.getSize());
-        
-         pizza = (PizzaService) dinners.get(1);
+
+        pizza = (PizzaService) dinners.get(1);
         assertEquals("topping", "Eggs", pizza.getTopping());
         assertEquals("cheese", "Mozzarella", pizza.getCheese());
         assertEquals("size", 16, pizza.getSize());
 
+        // dinners (1-many using Set)
+        Set<PizzaService> snacks = restaurant.getSnackMenu();
+        assertNotNull("dinners is null!", snacks);
+        assertEquals("dinners size: " + snacks, 2, snacks.size());
+        for (PizzaService snack : snacks) {
+            String topping = snack.getTopping();
+            if ("Tofu".equals(topping)) {
+                assertEquals("cheese", "Parmesan", snack.getCheese());
+                assertEquals("size", 6, snack.getSize());
+            } else if ("Prosciutto".equals(topping)) {
+                assertEquals("cheese", "Blue", snack.getCheese());
+                assertEquals("size", 8, snack.getSize());
+            } else {
+                fail("wrong topping: " + snack);
+            }
+        }
         // lunches (1-many using array)
         PizzaService[] lunches = restaurant.getLunchMenu();
         assertNotNull("lunches is null!", lunches);
@@ -61,7 +78,6 @@
         assertEquals("topping", "Chicken", pizza.getTopping());
         assertEquals("cheese", "Brie", pizza.getCheese());
         assertEquals("size", 17, pizza.getSize());
-
 
         // favourite (1-1)
         pizza = restaurant.getFavourite();

Modified: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RestaurantService.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RestaurantService.java?view=diff&rev=548538&r1=548537&r2=548538
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RestaurantService.java
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/RestaurantService.java
Mon Jun 18 17:43:59 2007
@@ -20,6 +20,7 @@
 
 import java.net.URI;
 import java.util.List;
+import java.util.Set;
 
 /**
  * An owner POJO used for testing out nested properties
@@ -36,6 +37,7 @@
     private PizzaService favourite;
     private List dinnerMenu;
     private PizzaService[] lunchMenu;
+    private Set<PizzaService> snackMenu;
     private QName serviceName;
     private URI uri;
 
@@ -56,6 +58,14 @@
 
     public void setLunchMenu(PizzaService[] lunchMenu) {
         this.lunchMenu = lunchMenu;
+    }
+
+    public Set<PizzaService> getSnackMenu() {
+        return snackMenu;
+    }
+
+    public void setSnackMenu(Set<PizzaService> snackMenu) {
+        this.snackMenu = snackMenu;
     }
 
     public PizzaService getFavourite() {

Modified: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-normal.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-normal.xml?view=diff&rev=548538&r1=548537&r2=548538
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-normal.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-normal.xml
Mon Jun 18 17:43:59 2007
@@ -51,6 +51,20 @@
         </bean>
       </list>
     </property>
+    <property name="snackMenu">
+      <set>
+        <bean class="org.apache.xbean.spring.example.PizzaService">
+          <property name="topping" value="Tofu" />
+          <property name="cheese" value="Parmesan" />
+          <property name="size" value="6" />
+        </bean>
+        <bean class="org.apache.xbean.spring.example.PizzaService">
+          <property name="topping" value="Prosciutto" />
+          <property name="cheese" value="Blue" />
+          <property name="size" value="8" />
+        </bean>
+      </set>
+    </property>
     <property name="lunchMenu">
       <list>
         <bean class="org.apache.xbean.spring.example.PizzaService">

Modified: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-spring-extended.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-spring-extended.xml?view=diff&rev=548538&r1=548537&r2=548538
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-spring-extended.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-spring-extended.xml
Mon Jun 18 17:43:59 2007
@@ -45,6 +45,20 @@
         </bean>
       </list>
     </property>
+    <property name="snackMenu">
+      <set>
+        <bean class="org.apache.xbean.spring.example.PizzaService">
+          <property name="topping" value="Tofu" />
+          <property name="cheese" value="Parmesan" />
+          <property name="size" value="6" />
+        </bean>
+        <bean class="org.apache.xbean.spring.example.PizzaService">
+          <property name="topping" value="Prosciutto" />
+          <property name="cheese" value="Blue" />
+          <property name="size" value="8" />
+        </bean>
+      </set>
+    </property>
     <property name="lunchMenu">
       <list>
         <bean class="org.apache.xbean.spring.example.PizzaService">

Modified: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-mixed.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-mixed.xml?view=diff&rev=548538&r1=548537&r2=548538
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-mixed.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-mixed.xml
Mon Jun 18 17:43:59 2007
@@ -31,6 +31,11 @@
       </bean>
     </dinnerMenu>
 
+    <snackMenu>
+      <pizza myTopping="Tofu" cheese="Parmesan" size="6"/>
+      <pizza myTopping="Prosciutto" cheese="Blue" size="8"/>
+    </snackMenu>
+
     <lunchMenu>
       <bean xmlns="" class="org.apache.xbean.spring.example.PizzaService">
         <property name="topping" value="Chicken"/>

Modified: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-root.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-root.xml?view=diff&rev=548538&r1=548537&r2=548538
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-root.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-root.xml
Mon Jun 18 17:43:59 2007
@@ -24,6 +24,11 @@
       <pizza myTopping="Eggs" cheese="Mozzarella" size="16"/>
     </dinnerMenu>
 
+    <snackMenu>
+      <pizza myTopping="Tofu" cheese="Parmesan" size="6"/>
+      <pizza myTopping="Prosciutto" cheese="Blue" size="8"/>
+    </snackMenu>
+
     <lunchMenu>
       <pizza myTopping="Chicken" cheese="Brie" size="17"/>
     </lunchMenu>

Modified: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-simple.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-simple.xml?view=diff&rev=548538&r1=548537&r2=548538
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-simple.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean-simple.xml
Mon Jun 18 17:43:59 2007
@@ -26,6 +26,11 @@
       <pizza myTopping="Eggs" cheese="Mozzarella" size="16"/>
     </dinnerMenu>
 
+    <snackMenu>
+      <pizza myTopping="Tofu" cheese="Parmesan" size="6"/>
+      <pizza myTopping="Prosciutto" cheese="Blue" size="8"/>
+    </snackMenu>
+
     <lunchMenu>
       <pizza myTopping="Chicken" cheese="Brie" size="17"/>
     </lunchMenu>

Modified: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean.xml?view=diff&rev=548538&r1=548537&r2=548538
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/restaurant-xbean.xml
Mon Jun 18 17:43:59 2007
@@ -18,11 +18,11 @@
 
 -->
 <!-- START SNIPPET: xml -->
-<beans xmlns="http://xbean.apache.org/schemas/pizza" 
+<beans xmlns="http://xbean.apache.org/schemas/pizza" 
        xmlns:foo="http://acme.com">
 
-  <restaurant id="restaurant" 
-              serviceName="foo:xyz" 
+  <restaurant id="restaurant" 
+              serviceName="foo:xyz" 
               uri="http://cheese.com">
     <dinnerMenu>
       <pizza myTopping="Ham" cheese="Mozzarella" size="15"/>
@@ -32,6 +32,11 @@
     <lunchMenu>
       <pizza myTopping="Chicken" cheese="Brie" size="17"/>
     </lunchMenu>
+
+    <snackMenu>
+      <pizza myTopping="Tofu" cheese="Parmesan" size="6"/>
+      <pizza myTopping="Prosciutto" cheese="Blue" size="8"/>
+    </snackMenu>
 
     <favourite>
       <pizza myTopping="Salami" cheese="Edam" size="17"/>



Mime
View raw message