You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2013/06/13 21:13:23 UTC

[5/5] git commit: restore default timezone after test

restore default timezone after test


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/d8789519
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/d8789519
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/d8789519

Branch: refs/heads/master
Commit: d8789519deb9b386ff8703bee056005522a51389
Parents: 690cca0
Author: svenmeier <sv...@meiers.net>
Authored: Thu Jun 13 21:12:20 2013 +0200
Committer: svenmeier <sv...@meiers.net>
Committed: Thu Jun 13 21:12:20 2013 +0200

----------------------------------------------------------------------
 .../yui/calendar/DateTimeFieldTest.java         | 39 +++++++++++++-------
 1 file changed, 25 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/d8789519/wicket-datetime/src/test/java/org/apache/wicket/extensions/yui/calendar/DateTimeFieldTest.java
----------------------------------------------------------------------
diff --git a/wicket-datetime/src/test/java/org/apache/wicket/extensions/yui/calendar/DateTimeFieldTest.java b/wicket-datetime/src/test/java/org/apache/wicket/extensions/yui/calendar/DateTimeFieldTest.java
index 37dde0d..ea9333e 100644
--- a/wicket-datetime/src/test/java/org/apache/wicket/extensions/yui/calendar/DateTimeFieldTest.java
+++ b/wicket-datetime/src/test/java/org/apache/wicket/extensions/yui/calendar/DateTimeFieldTest.java
@@ -28,7 +28,7 @@ import org.junit.Test;
 /**
  * Tests for DateTimeField
  */
-public class DateTimeFieldTest  extends WicketTestCase
+public class DateTimeFieldTest extends WicketTestCase
 {
 	/**
 	 * https://issues.apache.org/jira/browse/WICKET-5204
@@ -36,25 +36,36 @@ public class DateTimeFieldTest  extends WicketTestCase
 	@Test
 	public void testTimeZones()
 	{
-		//The server is using UTC as it's default timezone
-		DateTimeZone.setDefault(DateTimeZone.forID("UTC"));
+		DateTimeZone defaultTimeZone = DateTimeZone.getDefault();
 
-		final String clientTimezone = "America/Toronto";
+		try
+		{
+			// The server is using UTC as it's default timezone
+			DateTimeZone.setDefault(DateTimeZone.forID("UTC"));
 
-		DateTime jan01_10am = new DateTime(2013, 01, 01, 10, 0, 0 , DateTimeZone.forID(clientTimezone));
+			final String clientTimezone = "America/Toronto";
 
-		DateTimeField dateTimeField = new DateTimeField("foo", Model.of(jan01_10am.toDate()))
-		{
-			@Override
-			protected TimeZone getClientTimeZone()
+			DateTime jan01_10am = new DateTime(2013, 01, 01, 10, 0, 0,
+				DateTimeZone.forID(clientTimezone));
+
+			DateTimeField dateTimeField = new DateTimeField("foo", Model.of(jan01_10am.toDate()))
 			{
-				return TimeZone.getTimeZone(clientTimezone);
-			}
-		};
+				@Override
+				protected TimeZone getClientTimeZone()
+				{
+					return TimeZone.getTimeZone(clientTimezone);
+				}
+			};
 
-		tester.startComponentInPage(dateTimeField);
+			tester.startComponentInPage(dateTimeField);
 
-		Assert.assertEquals("The hour of day is incorrect!", jan01_10am.getHourOfDay(), dateTimeField.getHours().intValue());
+			Assert.assertEquals("The hour of day is incorrect!", jan01_10am.getHourOfDay(),
+				dateTimeField.getHours().intValue());
+		}
+		finally
+		{
+			DateTimeZone.setDefault(defaultTimeZone);
+		}
 	}
 
 }