summaryrefslogtreecommitdiffstats
path: root/tests/server-side/com
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-06-19 15:36:35 +0300
committerArtur Signell <artur@vaadin.com>2012-06-21 17:11:25 +0300
commit71abc602b00089b17b247c64729588a0d187eafd (patch)
treed656d3e0f31c518d51f92517e2598d82518778a5 /tests/server-side/com
parenta406fd2c798b4e13197d5a8be0752497e8b3c2f4 (diff)
downloadvaadin-framework-71abc602b00089b17b247c64729588a0d187eafd.tar.gz
vaadin-framework-71abc602b00089b17b247c64729588a0d187eafd.zip
Additional test for converters (#8185)
Diffstat (limited to 'tests/server-side/com')
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
index 050ab282a6..7305e022ee 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
@@ -4,6 +4,7 @@ import java.util.Locale;
import junit.framework.TestCase;
+import com.vaadin.Application;
import com.vaadin.data.util.MethodProperty;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.data.util.converter.StringToIntegerConverter;
@@ -159,4 +160,45 @@ public class AbstractFieldValueConversions extends TestCase {
}
+ public static class NumberBean {
+ private Number number;
+
+ public Number getNumber() {
+ return number;
+ }
+
+ public void setNumber(Number number) {
+ this.number = number;
+ }
+
+ }
+
+ public void testNumberDoubleConverterChange() {
+ final Application a = new Application();
+ Application.setCurrentApplication(a);
+ TextField tf = new TextField() {
+ @Override
+ public Application getApplication() {
+ return a;
+ }
+ };
+ NumberBean nb = new NumberBean();
+ nb.setNumber(490);
+
+ tf.setPropertyDataSource(new MethodProperty<Number>(nb, "number"));
+ assertEquals(490, tf.getPropertyDataSource().getValue());
+ assertEquals("490", tf.getValue());
+
+ Converter c1 = tf.getConverter();
+
+ tf.setPropertyDataSource(new MethodProperty<Number>(nb, "number"));
+ Converter c2 = tf.getConverter();
+ assertTrue(
+ "StringToNumber converter is ok for integer types and should stay even though property is changed",
+ c1 == c2);
+ assertEquals(490, tf.getPropertyDataSource().getValue());
+ assertEquals("490", tf.getValue());
+
+ }
+
}