Commits

Anonymous committed 85f6a35

Adding tests for generics

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@917e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (2)

tiger/src/test/com/opensymphony/xwork/GenericsBean.java

+package com.opensymphony.xwork;
+
+import java.util.List;
+
+/**
+ * <code>GenericsBean</code>
+ *
+ * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
+ * @version $Id$
+ */
+public class GenericsBean {
+
+    private List<Double> doubles;
+
+    /**
+     * @return Returns the doubles.
+     */
+    public List<Double> getDoubles() {
+        return doubles;
+    }
+
+    /**
+     * @param doubles The doubles to set.
+     */
+    public void setDoubles(List<Double> doubles) {
+        this.doubles = doubles;
+    }
+}

tiger/src/test/com/opensymphony/xwork/util/AnnotationXWorkConverterTest.java

  */
 package com.opensymphony.xwork.util;
 
-import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.TestBean;
-import com.opensymphony.xwork.ModelDrivenAnnotationAction;
-import com.opensymphony.xwork.SimpleAnnotationAction;
+import com.opensymphony.xwork.*;
 import com.opensymphony.xwork.test.ModelDrivenAnnotationAction2;
 import com.opensymphony.xwork.test.AnnotationUser;
 import com.opensymphony.xwork.config.ConfigurationManager;
     }
 
     // TODO: Fixme... This test does not work with GenericsObjectDeterminer!
-    public void no_testStringToCollectionConversion() {
+    public void testStringToCollectionConversion() {
         OgnlValueStack stack = new OgnlValueStack();
         Map stackContext = stack.getContext();
         stackContext.put(InstantiatingNullHandler.CREATE_NULL_OBJECTS, Boolean.TRUE);
         AnnotationUser user = new AnnotationUser();
         stack.push(user);
 
-        // This is not working... user.getList() returns null!
         stack.setValue("list", "asdf");
         assertNotNull(user.getList());
         assertEquals(1, user.getList().size());
         assertNotNull(bar);
     }
 
+    public void testGenericProperties() {
+        GenericsBean gb = new GenericsBean();
+        OgnlValueStack stack = new OgnlValueStack();
+        stack.push(gb);
+
+        String[] value = new String[] {"123.12", "123.45"};
+        stack.setValue("doubles", value);
+        assertEquals(2, gb.getDoubles().size());
+        assertEquals(Double.class, gb.getDoubles().get(0).getClass());
+        assertEquals(new Double(123.12), gb.getDoubles().get(0));
+        assertEquals(new Double(123.45), gb.getDoubles().get(1));
+    }
+
     public static class Foo1 {
         public Bar1 getBar() {
             return new Bar1Impl();