diff options
author | Marco Collovati <mcollovati@gmail.com> | 2016-05-20 20:08:16 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-05-26 06:59:14 +0000 |
commit | 1e7893d743cde357f0ecca41779ebe45762d86ba (patch) | |
tree | f39e8faa368be06231464b0790a6d022a8bb58ad /server | |
parent | 25e824aea4c0cf65dbea784446ec2b7a521b7a08 (diff) | |
download | vaadin-framework-1e7893d743cde357f0ecca41779ebe45762d86ba.tar.gz vaadin-framework-1e7893d743cde357f0ecca41779ebe45762d86ba.zip |
Make tests pass in any timezone (#19813)
Change-Id: I78411b92a5b3c2f04ed8a15ebd2c183aa1af4ab9
Diffstat (limited to 'server')
-rw-r--r-- | server/src/test/java/com/vaadin/tests/design/DesignFormatterTest.java | 3 | ||||
-rw-r--r-- | server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java | 21 |
2 files changed, 15 insertions, 9 deletions
diff --git a/server/src/test/java/com/vaadin/tests/design/DesignFormatterTest.java b/server/src/test/java/com/vaadin/tests/design/DesignFormatterTest.java index e62d5c17c8..2086e2ffeb 100644 --- a/server/src/test/java/com/vaadin/tests/design/DesignFormatterTest.java +++ b/server/src/test/java/com/vaadin/tests/design/DesignFormatterTest.java @@ -193,7 +193,8 @@ public class DesignFormatterTest { Date result = formatter.parse(formatted, Date.class); // writing will always give full date string - assertEquals("2012-02-17 00:00:00+0200", formatted); + String timeZone = new SimpleDateFormat("Z").format(date); + assertEquals("2012-02-17 00:00:00" + timeZone, formatted); assertEquals(date, result); // try short date as well diff --git a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java index 54ac9a3a4b..dc6db3bfe6 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java @@ -15,6 +15,7 @@ */ package com.vaadin.tests.server.component.datefield; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; @@ -26,9 +27,9 @@ import com.vaadin.ui.DateField; /** * Tests the declarative support for implementations of {@link DateField}. - * - * @since 7.4 + * * @author Vaadin Ltd + * @since 7.4 */ public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> { @@ -44,7 +45,8 @@ public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> { } private String getTimezoneDesign() { - return "<vaadin-date-field range-start=\"2014-05-05 00:00:00+0300\" range-end=\"2014-06-05 00:00:00+0300\" date-out-of-range-message=\"Please select a sensible date\" date-format=\"yyyy-MM-dd\" lenient show-iso-week-numbers parse-error-message=\"You are doing it wrong\" time-zone=\"GMT+05:00\" value=\"2014-05-15 00:00:00+0300\"/>"; + String timeZone = new SimpleDateFormat("Z").format(new Date()); + return String.format("<vaadin-date-field range-start=\"2014-05-05 00:00:00%1$s\" range-end=\"2014-06-05 00:00:00%1$s\" date-out-of-range-message=\"Please select a sensible date\" date-format=\"yyyy-MM-dd\" lenient show-iso-week-numbers parse-error-message=\"You are doing it wrong\" time-zone=\"GMT+05:00\" value=\"2014-05-15 00:00:00%1$s\"/>" ,timeZone); } private DateField getTimezoneExpected() { @@ -82,18 +84,21 @@ public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> { @Test public void writeYearResolution() { // Writing is always done in full resolution.. + String timeZone = new SimpleDateFormat("Z").format(new Date(2020 - 1900, 1 - 1, 1)); testWrite( - getYearResolutionDesign().replace("2020", - "2020-01-01 00:00:00+0200"), - getYearResolutionExpected()); + getYearResolutionDesign().replace("2020", + "2020-01-01 00:00:00" + timeZone), + getYearResolutionExpected()); } @Test public void testReadOnlyValue() { - String design = "<vaadin-date-field readonly resolution='year' value='2020-01-01 00:00:00+0200'/>"; + Date date = new Date(2020 - 1900, 1 - 1, 1); + String timeZone = new SimpleDateFormat("Z").format(date); + String design = "<vaadin-date-field readonly resolution='year' value='2020-01-01 00:00:00" + timeZone + "'/>"; DateField df = new DateField(); df.setResolution(Resolution.YEAR); - df.setValue(new Date(2020 - 1900, 1 - 1, 1)); + df.setValue(date); df.setReadOnly(true); testRead(design, df); |