diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java index 9338d74f05..698e9bcee4 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java @@ -15,6 +15,33 @@ import com.vaadin.ui.TextField; public class DefaultConverterFactory extends TestCase { + public static class FloatBean { + float f1; + Float f2; + + public FloatBean(float f1, Float f2) { + this.f1 = f1; + this.f2 = f2; + } + + public float getF1() { + return f1; + } + + public void setF1(float f1) { + this.f1 = f1; + } + + public Float getF2() { + return f2; + } + + public void setF2(Float f2) { + this.f2 = f2; + } + + } + Person paulaBean = new Person("Paula", "Brilliant", "paula@brilliant.com", 34, Sex.FEMALE, new Address("Paula street 1", 12345, "P-town", Country.FINLAND)); @@ -25,6 +52,21 @@ public class DefaultConverterFactory extends TestCase { paulaBean.setRent(rent); } + public void testFloatConversion() { + VaadinSession sess = new VaadinSession(null); + VaadinSession.setCurrent(sess); + + TextField tf = new TextField(); + tf.setLocale(new Locale("en", "US")); + tf.setPropertyDataSource(new MethodProperty<Integer>(new FloatBean(12f, + 23f), "f2")); + assertEquals("23", tf.getValue()); + tf.setValue("24"); + assertEquals("24", tf.getValue()); + assertEquals(24f, tf.getConvertedValue()); + assertEquals(24f, tf.getPropertyDataSource().getValue()); + } + public void testDefaultNumberConversion() { VaadinSession app = new VaadinSession(null); VaadinSession.setCurrent(app); |