aboutsummaryrefslogtreecommitdiffstats
path: root/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java')
-rw-r--r--server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java b/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java
new file mode 100644
index 0000000000..acea0a84c7
--- /dev/null
+++ b/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java
@@ -0,0 +1,63 @@
+package com.vaadin.ui;
+
+import java.text.NumberFormat;
+import java.util.Locale;
+
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.data.util.converter.StringToIntegerConverter;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinSession;
+
+public class AbsFieldDataSourceLocaleChange {
+
+ private VaadinSession vaadinSession;
+ private UI ui;
+
+ @Before
+ public void setup() {
+ vaadinSession = new VaadinSession(null);
+ VaadinSession.setCurrent(vaadinSession);
+ ui = new UI() {
+
+ @Override
+ protected void init(VaadinRequest request) {
+
+ }
+ };
+ ui.setSession(vaadinSession);
+ UI.setCurrent(ui);
+ }
+
+ @Test
+ public void localeChangesOnAttach() {
+ TextField tf = new TextField();
+
+ ;
+ tf.setConverter(new StringToIntegerConverter() {
+ @Override
+ protected NumberFormat getFormat(Locale locale) {
+ if (locale == null) {
+ NumberFormat format = super.getFormat(locale);
+ format.setGroupingUsed(false);
+ format.setMinimumIntegerDigits(10);
+ return format;
+ }
+ return super.getFormat(locale);
+ }
+ });
+ tf.setImmediate(true);
+ tf.setConvertedValue(10000);
+ Assert.assertEquals("0000010000", tf.getValue());
+
+ VerticalLayout vl = new VerticalLayout();
+ ui.setContent(vl);
+ ui.setLocale(new Locale("en", "US"));
+
+ vl.addComponent(tf);
+ Assert.assertEquals("10,000", tf.getValue());
+ }
+}