geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r452597 - in /geronimo/xbean/trunk/xbean-spring-v1/src: main/java/org/apache/xbean/spring/context/v1/ test/java/org/apache/xbean/spring/context/ test/resources/org/apache/xbean/spring/context/
Date Tue, 03 Oct 2006 19:14:40 GMT
Author: dain
Date: Tue Oct  3 12:14:39 2006
New Revision: 452597

URL: http://svn.apache.org/viewvc?view=rev&rev=452597
Log:
XBEAN-55 Custom Map values aren't parsed properly
If you use the custom map syntax that I wrote, it only supports setting values which are Strings.
This patch fixes that issue.
Thanks Dan Diephouse

Modified:
    geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java
    geronimo/xbean/trunk/xbean-spring-v1/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java
    geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml
    geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml

Modified: geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java?view=diff&rev=452597&r1=452596&r2=452597
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java
Tue Oct  3 12:14:39 2006
@@ -590,7 +590,14 @@
 
                     Object keyValue = getValue(key, null);
 
-                    Object value = getValue(getElementText(childElement), null);
+                    Element valueElement = getFirstChildElement(childElement);
+                    
+                    Object value;
+                    if (valueElement != null) {
+                        value = parsePropertySubElement(valueElement, "");
+                    } else {
+                        value = getElementText(childElement);
+                    }
 
                     map.put(keyValue, value);
                 }
@@ -599,6 +606,17 @@
         return map;
     }
 
+    protected Element getFirstChildElement(Element element)
+    {
+        NodeList nl = element.getChildNodes();
+        for (int i = 0; i < nl.getLength(); i++) {
+            Node node = nl.item(i);
+            if (node instanceof Element) {
+                return (Element) node;
+            }
+        }
+        return null;
+    }
     protected boolean isMap(Class type) {
         return Map.class.isAssignableFrom(type);
     }

Modified: geronimo/xbean/trunk/xbean-spring-v1/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-v1/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java?view=diff&rev=452597&r1=452596&r2=452597
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-v1/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-v1/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java
Tue Oct  3 12:14:39 2006
@@ -16,10 +16,11 @@
  */
 package org.apache.xbean.spring.context;
 
+import java.util.List;
 import java.util.Map;
 
-import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.apache.xbean.spring.example.FavoriteService;
+import org.springframework.context.support.AbstractXmlApplicationContext;
 
 /**
  * @author James Strachan
@@ -33,9 +34,14 @@
   
         Map favorites = fs.getFavorites();
         assertNotNull(favorites);
-        assertEquals(1, favorites.size());
+        assertEquals(2, favorites.size());
         
         assertEquals("Grey Goose", favorites.get("Dan"));
+        Object object = favorites.get("IndecisiveDan");
+        System.out.println(object.getClass());
+        assertTrue(object instanceof List);
+        List l = (List) object;
+        assertEquals(2, l.size());
     }
 
     protected AbstractXmlApplicationContext createApplicationContext() {

Modified: geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml?view=diff&rev=452597&r1=452596&r2=452597
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml
Tue Oct  3 12:14:39 2006
@@ -25,6 +25,12 @@
         <map> 
          <entry key="Dan">
            <value>Grey Goose</value>
+         </entry>
+         <entry key="IndecisiveDan">
+             <list>
+               <value>Malbec</value>
+               <value>Cognac</value>
+             </list>
          </entry>
         </map>
     </property>

Modified: geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml?view=diff&rev=452597&r1=452596&r2=452597
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml
Tue Oct  3 12:14:39 2006
@@ -22,7 +22,13 @@
 
   <b:favorite s:id="favoriteService">
     <b:favorites>
-      <b:favorite-item person="Dan">Grey Goose</b:favorite-item>
+      <b:favorite-item person="Dan">Grey Goose</b:favorite-item>
+      <b:favorite-item person="IndecisiveDan">
+        <list>
+          <value>Malbec</value>
+          <value>Cognac</value>
+        </list>
+      </b:favorite-item>
     </b:favorites>
   </b:favorite>
 



Mime
View raw message