diff options
author | Henri Sara <henri.sara@gmail.com> | 2017-01-12 10:46:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-12 10:46:22 +0200 |
commit | cd73480c602326c4bbb2872e0839d14626199551 (patch) | |
tree | 8a1c3c84be21e64cbb2157f09a307a2710b4e6fc | |
parent | 9896ca3cc725f0e3783dd2db80ed445ff7f5b504 (diff) | |
download | vaadin-framework-cd73480c602326c4bbb2872e0839d14626199551.tar.gz vaadin-framework-cd73480c602326c4bbb2872e0839d14626199551.zip |
Make server tests use fixed locale where needed (#8226)
4 files changed, 13 insertions, 5 deletions
diff --git a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java index 7d2e6bd304..59ca890740 100644 --- a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java +++ b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java @@ -17,6 +17,7 @@ package com.vaadin.data; import java.time.LocalDate; import java.util.List; +import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -139,6 +140,10 @@ public class BinderBookOfVaadinTest { field = new TextField(); phoneField = new TextField(); emailField = new TextField(); + // make sure the test is not locale dependent + field.setLocale(Locale.US); + phoneField.setLocale(Locale.US); + emailField.setLocale(Locale.US); } @Test @@ -245,6 +250,7 @@ public class BinderBookOfVaadinTest { @Test public void converterBookOfVaadinExample1() { TextField yearOfBirthField = new TextField(); + yearOfBirthField.setLocale(Locale.US); // Slider for integers between 1 and 10 Slider salaryLevelField = new Slider("Salary level", 1, 10); diff --git a/server/src/test/java/com/vaadin/data/BinderTestBase.java b/server/src/test/java/com/vaadin/data/BinderTestBase.java index 8cad82d570..f3f04982d3 100644 --- a/server/src/test/java/com/vaadin/data/BinderTestBase.java +++ b/server/src/test/java/com/vaadin/data/BinderTestBase.java @@ -15,6 +15,8 @@ */ package com.vaadin.data; +import java.util.Locale; + import org.junit.Before; import com.vaadin.ui.TextField; @@ -51,6 +53,8 @@ public abstract class BinderTestBase<BINDER extends Binder<ITEM>, ITEM> { @Before public void setUpBase() { nameField = new TextField(); + nameField.setLocale(Locale.US); ageField = new TextField(); + ageField.setLocale(Locale.US); } } diff --git a/server/src/test/java/com/vaadin/data/validator/BeanValidatorTest.java b/server/src/test/java/com/vaadin/data/validator/BeanValidatorTest.java index 97f767bbc7..f595be14bc 100644 --- a/server/src/test/java/com/vaadin/data/validator/BeanValidatorTest.java +++ b/server/src/test/java/com/vaadin/data/validator/BeanValidatorTest.java @@ -8,7 +8,6 @@ import org.junit.Test; import com.vaadin.tests.data.bean.Address; import com.vaadin.tests.data.bean.BeanToValidate; -import com.vaadin.tests.util.MockUI; import com.vaadin.ui.UI; public class BeanValidatorTest extends ValidatorTestBase { @@ -59,9 +58,7 @@ public class BeanValidatorTest extends ValidatorTestBase { @Test public void testInvalidDecimalsFailsInFrench() { - MockUI ui = new MockUI(); - ui.setLocale(Locale.FRENCH); - UI.setCurrent(ui); + setLocale(Locale.FRENCH); BeanValidator v = validator("decimals"); assertFails("1234.567", "Valeur numérique hors limite " + "(<3 chiffres>.<2 chiffres> attendus)", v); diff --git a/server/src/test/java/com/vaadin/data/validator/ValidatorTestBase.java b/server/src/test/java/com/vaadin/data/validator/ValidatorTestBase.java index 599d7440db..a0bdd2964b 100644 --- a/server/src/test/java/com/vaadin/data/validator/ValidatorTestBase.java +++ b/server/src/test/java/com/vaadin/data/validator/ValidatorTestBase.java @@ -17,6 +17,7 @@ public class ValidatorTestBase { @Before public void setUp() { localeContext = new Label(); + setLocale(Locale.US); } protected <T> void assertPasses(T value, Validator<? super T> validator) { @@ -42,4 +43,4 @@ public class ValidatorTestBase { protected void setLocale(Locale locale) { localeContext.setLocale(locale); } -}
\ No newline at end of file +} |