click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bck...@apache.org
Subject svn commit: r986462 - /click/trunk/click/extras/test/org/apache/click/extras/control/DoubleFieldTest.java
Date Tue, 17 Aug 2010 19:36:29 GMT
Author: bckfnn
Date: Tue Aug 17 19:36:29 2010
New Revision: 986462

URL: http://svn.apache.org/viewvc?rev=986462&view=rev
Log:
test for the double->bigdecimal conversion problem that is fixed in OgnlOps.

Modified:
    click/trunk/click/extras/test/org/apache/click/extras/control/DoubleFieldTest.java

Modified: click/trunk/click/extras/test/org/apache/click/extras/control/DoubleFieldTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/test/org/apache/click/extras/control/DoubleFieldTest.java?rev=986462&r1=986461&r2=986462&view=diff
==============================================================================
--- click/trunk/click/extras/test/org/apache/click/extras/control/DoubleFieldTest.java (original)
+++ click/trunk/click/extras/test/org/apache/click/extras/control/DoubleFieldTest.java Tue
Aug 17 19:36:29 2010
@@ -18,21 +18,25 @@
  */
 package org.apache.click.extras.control;
 
+import java.math.BigDecimal;
 import java.util.Locale;
 
 import junit.framework.TestCase;
 import org.apache.click.MockContext;
+import org.apache.click.control.Form;
 import org.apache.click.servlet.MockRequest;
 
 public class DoubleFieldTest extends TestCase {
 
     Locale defaultLocale;
 
+    @Override
     protected void setUp() throws Exception {
         defaultLocale = Locale.getDefault();
         Locale.setDefault(Locale.US);
     }
 
+    @Override
     protected void tearDown() throws Exception {
         Locale.setDefault(defaultLocale);
     }
@@ -168,4 +172,30 @@ public class DoubleFieldTest extends Tes
         assertEquals(new Double(123.4), doubleField.getValueObject());
     }
 
+    /**
+     * Test that the fix for double->BigDecimal conversion work.
+     */
+    public void testFormCopyBigDecimal() {
+        MockContext.initContext(Locale.US);
+        
+        Form form = new Form("form");
+
+        DoubleField field = new DoubleField("numfield");
+        form.add(field);
+        
+        field.setValue("0.1");
+        
+        MyObj obj = new MyObj(); 
+        form.copyTo(obj);
+
+        assertEquals("0.1", obj.numfield.toString());
+    }
+    
+    public static class MyObj {
+        public BigDecimal numfield;
+        
+        public void setNumfield(BigDecimal value) {
+            this.numfield = value;
+        }
+    }
 }



Mime
View raw message