You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2011/03/04 12:06:59 UTC
svn commit: r1077874 - in
/poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef:
TestAttachments.java attribute/TestMAPIAttributes.java
attribute/TestTNEFAttributes.java
Author: nick
Date: Fri Mar 4 11:06:59 2011
New Revision: 1077874
URL: http://svn.apache.org/viewvc?rev=1077874&view=rev
Log:
Setting the locale doesn't seem to set the timezone, so do that explicitly to ensure the tests behave for everyone
Modified:
poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java?rev=1077874&r1=1077873&r2=1077874&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/TestAttachments.java Fri Mar 4 11:06:59 2011
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.text.DateFormat;
import java.util.List;
import java.util.Locale;
+import java.util.TimeZone;
import junit.framework.TestCase;
@@ -87,18 +88,18 @@ public final class TestAttachments exten
public void testAttachmentDetails() throws Exception {
List<Attachment> attachments = quick.getAttachments();
- // Pick a predictable date format
- // Note that the 28th April is in summer time in the UK
+ // Pick a predictable date format + timezone
DateFormat fmt = DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK
);
+ fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
// They should all have the same date on them
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(0).getModifiedDate()));
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(1).getModifiedDate()));
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(2).getModifiedDate()));
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(3).getModifiedDate()));
- assertEquals("28-Apr-2010 13:40:56", fmt.format( attachments.get(4).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(0).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(1).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(2).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(3).getModifiedDate()));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format( attachments.get(4).getModifiedDate()));
// They should all have a 3512 byte metafile rendered version
assertEquals(3512, attachments.get(0).getRenderedMetaFile().length);
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java?rev=1077874&r1=1077873&r2=1077874&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestMAPIAttributes.java Fri Mar 4 11:06:59 2011
@@ -20,6 +20,7 @@ package org.apache.poi.hmef.attribute;
import java.io.ByteArrayInputStream;
import java.text.DateFormat;
import java.util.Locale;
+import java.util.TimeZone;
import junit.framework.TestCase;
@@ -151,6 +152,7 @@ public final class TestMAPIAttributes ex
DateFormat fmt = DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK
);
+ fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
assertEquals("15-Dec-2010 14:46:31", fmt.format(date.getDate()));
// RTF
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java?rev=1077874&r1=1077873&r2=1077874&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hmef/attribute/TestTNEFAttributes.java Fri Mar 4 11:06:59 2011
@@ -20,6 +20,7 @@ package org.apache.poi.hmef.attribute;
import java.io.ByteArrayInputStream;
import java.text.DateFormat;
import java.util.Locale;
+import java.util.TimeZone;
import junit.framework.TestCase;
@@ -156,12 +157,13 @@ public final class TestTNEFAttributes ex
assertEquals(3, LittleEndian.getUShort(attr.getData(), 12)); // Weds
// Ask for it as a Java date, and have it converted
- // Pick a predictable format + location. Note location is in summer time!
+ // Pick a predictable format + location + timezone
TNEFDateAttribute date = (TNEFDateAttribute)attr;
DateFormat fmt = DateFormat.getDateTimeInstance(
DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK
);
- assertEquals("28-Apr-2010 13:40:56", fmt.format(date.getDate()));
+ fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
+ assertEquals("28-Apr-2010 12:40:56", fmt.format(date.getDate()));
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org