Commits

Anonymous committed 17f881f

Checking in type conversion field error tests

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

Comments (0)

Files changed (2)

src/test/com/opensymphony/xwork/util/Bar.java

  */
 package com.opensymphony.xwork.util;
 
+import com.opensymphony.xwork.ActionSupport;
+
 
 /**
  *
  * @author $Author$
  * @version $Revision$
  */
-public class Bar {
+public class Bar extends ActionSupport {
     //~ Instance fields ////////////////////////////////////////////////////////
 
     Long id;

src/test/com/opensymphony/xwork/util/SetPropertiesTest.java

  *
  */
 public class SetPropertiesTest extends TestCase {
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    /**
-     *
-     */
-    public SetPropertiesTest(String a) {
-        super(a);
-    }
-
     //~ Methods ////////////////////////////////////////////////////////////////
 
     public void testOgnlUtilEmptyStringAsLong() {
         Bar bar = new Bar();
-        bar.setId(null);
-
         Map context = Ognl.createDefaultContext(bar);
+        context.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
+        bar.setId(null);
 
         HashMap props = new HashMap();
         props.put("id", "");
 
         OgnlUtil.setProperties(props, bar, context);
         assertNull(bar.getId());
+        assertEquals(0, bar.getFieldErrors().size());
 
         props.put("id", new String[] {""});
 
         bar.setId(null);
         OgnlUtil.setProperties(props, bar, context);
         assertNull(bar.getId());
+        assertEquals(0, bar.getFieldErrors().size());
     }
 
     public void testValueStackSetValueEmptyStringAsLong() {
         Bar bar = new Bar();
-
         OgnlValueStack vs = new OgnlValueStack();
+        vs.getContext().put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
         vs.push(bar);
 
         vs.setValue("id", "");
         assertNull(bar.getId());
+        assertEquals(0, bar.getFieldErrors().size());
 
         bar.setId(null);
 
         vs.setValue("id", new String[] {""});
         assertNull(bar.getId());
+        assertEquals(0, bar.getFieldErrors().size());
     }
 }