diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2015-07-15 12:59:35 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2015-07-15 12:59:35 +0300 |
commit | 20f6053dc199d5dd7dde071dfdd9b37ea8f85e36 (patch) | |
tree | cef44905e38c849057f102cd26cd6b89251bc7e2 /server/tests/src/com | |
parent | 80058d9429940c376c63c086b1cf79848fe1a699 (diff) | |
parent | 9734bc5dfa5d919e3214dc17581d3da3ad1a3ebd (diff) | |
download | vaadin-framework-20f6053dc199d5dd7dde071dfdd9b37ea8f85e36.tar.gz vaadin-framework-20f6053dc199d5dd7dde071dfdd9b37ea8f85e36.zip |
Merge branch 'master' into grid-unbuffered-editor7.6.0.alpha3
Conflicts:
uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java
Change-Id: I5ed68bc73d38be4e1f6816108a5246d0c98a258f
Diffstat (limited to 'server/tests/src/com')
-rw-r--r-- | server/tests/src/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java b/server/tests/src/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java index f734d76633..6e81af97a3 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java @@ -4,9 +4,25 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.StringToBooleanConverter; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + public class StringToBooleanConverterTest extends TestCase { StringToBooleanConverter converter = new StringToBooleanConverter(); + StringToBooleanConverter yesNoConverter = new StringToBooleanConverter("yes","no"); + StringToBooleanConverter localeConverter = new StringToBooleanConverter() { + @Override + public String getFalseString(Locale locale) { + return SimpleDateFormat.getDateInstance(SimpleDateFormat.LONG,locale).format(new Date(3000000000000L)); + } + + @Override + public String getTrueString(Locale locale) { + return SimpleDateFormat.getDateInstance(SimpleDateFormat.LONG,locale).format(new Date(2000000000000L)); + } + }; public void testNullConversion() { assertEquals(null, converter.convertToModel(null, Boolean.class, null)); @@ -20,4 +36,22 @@ public class StringToBooleanConverterTest extends TestCase { assertTrue(converter.convertToModel("true", Boolean.class, null)); assertFalse(converter.convertToModel("false", Boolean.class, null)); } + + public void testYesNoValueConversion() { + assertTrue(yesNoConverter.convertToModel("yes", Boolean.class, null)); + assertFalse(yesNoConverter.convertToModel("no", Boolean.class, null)); + + assertEquals("yes", yesNoConverter.convertToPresentation(true, String.class, null)); + assertEquals("no", yesNoConverter.convertToPresentation(false, String.class, null)); + } + + + public void testLocale() { + assertEquals("May 18, 2033", localeConverter.convertToPresentation(true, String.class, Locale.US)); + assertEquals("January 24, 2065", localeConverter.convertToPresentation(false, String.class, Locale.US)); + + assertEquals("18. Mai 2033", localeConverter.convertToPresentation(true, String.class, Locale.GERMANY)); + assertEquals("24. Januar 2065", localeConverter.convertToPresentation(false, String.class, Locale.GERMANY)); + } + } |