summaryrefslogtreecommitdiffstats
path: root/harmony-tests/src/test/java
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2015-06-09 16:19:32 +0100
committerNeil Fuller <nfuller@google.com>2015-06-10 10:41:52 +0100
commit38a0b85afd4231f46fac59e59ee38729bd5154c4 (patch)
tree1372863850d681f12c535d821b09a70df0671a01 /harmony-tests/src/test/java
parent33019c39f1aad75d763cd03f91c7b48cff50e75f (diff)
downloadlibcore-38a0b85afd4231f46fac59e59ee38729bd5154c4.zip
libcore-38a0b85afd4231f46fac59e59ee38729bd5154c4.tar.gz
libcore-38a0b85afd4231f46fac59e59ee38729bd5154c4.tar.bz2
Explicitly set DateFormat.is24Hour value needed by tests
Some tests fail under CTS if the device is set to use the 24 hour clock. The tests that depend on the value of the setting are now being explicit. Bug: 20899571 Bug: 20937589 Bug: 20939139 Bug: 20378566 Bug: 21585934 Bug: https://code.google.com/p/android/issues/detail?id=162384 Change-Id: I0f03f54b76dc5d343a2c842434412ff59908b129
Diffstat (limited to 'harmony-tests/src/test/java')
-rw-r--r--harmony-tests/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java3
-rw-r--r--harmony-tests/src/test/java/org/apache/harmony/tests/java/text/Support_MessageFormat.java5
-rw-r--r--harmony-tests/src/test/java/org/apache/harmony/tests/java/util/DateTest.java21
3 files changed, 20 insertions, 9 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
index 0920714..e666c97 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
@@ -184,6 +184,9 @@ public class MessageFormatTest extends TestCase {
}
public void test_parseLjava_lang_String() throws ParseException {
+ // This test assumes a default DateFormat.is24Hour setting.
+ DateFormat.is24Hour = null;
+
String pattern = "A {3, number, currency} B {2, time} C {0, number, percent} D {4} E {1,choice,0#off|1#on} F {0, date}";
MessageFormat mf = new MessageFormat(pattern);
String sToParse = "A $12,345.00 B 9:56:07 AM C 3,200% D 1/15/70 9:56 AM E on F Jan 1, 1970";
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/Support_MessageFormat.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/Support_MessageFormat.java
index 8003b88..b8b0cee 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/Support_MessageFormat.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/Support_MessageFormat.java
@@ -44,6 +44,8 @@ public class Support_MessageFormat extends Support_Format {
}
public void t_format_with_FieldPosition() {
+ // This test assumes a default DateFormat.is24Hour setting.
+ DateFormat.is24Hour = null;
String pattern = "On {4,date} at {3,time}, he ate {2,number, integer} hamburger{2,choice,1#|1<s} and drank {1, number} liters of coke. That was {0,choice,1#just enough|1<more than enough} food!";
MessageFormat format = new MessageFormat(pattern, Locale.US);
@@ -71,6 +73,9 @@ public class Support_MessageFormat extends Support_Format {
}
public void t_formatToCharacterIterator() {
+ // This test assumes a default DateFormat.is24Hour setting.
+ DateFormat.is24Hour = null;
+
String pattern = "On {4,date} at {3,time}, he ate {2,number, integer} hamburger{2,choice,1#|1<s} and drank {1, number} liters of coke. That was {0,choice,1#just enough|1<more than enough} food!";
MessageFormat format = new MessageFormat(pattern, Locale.US);
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/DateTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/DateTest.java
index 0ce971d..f3ad743 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/DateTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/DateTest.java
@@ -17,6 +17,7 @@
package org.apache.harmony.tests.java.util;
+import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -487,18 +488,20 @@ public class DateTest extends junit.framework.TestCase {
public void test_toLocaleString() {
Locale loc = Locale.getDefault();
Locale.setDefault(Locale.US);
- TimeZone tz = TimeZone.getDefault();
- TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
- try {
+ TimeZone tz = TimeZone.getDefault();
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ // This test assumes a default DateFormat.is24Hour setting.
+ DateFormat.is24Hour = null;
+ try {
assertEquals("Did not convert epoch to GMT string correctly", "Jan 1, 1970 12:00:00 AM",
- new Date(0).toLocaleString());
+ new Date(0).toLocaleString());
assertEquals("Did not convert epoch + 1yr to GMT string correctly",
- "Jan 1, 1971 12:00:00 AM", new Date((long)365 * 24 * 60 * 60 * 1000)
- .toLocaleString());
- } finally {
+ "Jan 1, 1971 12:00:00 AM",
+ new Date((long)365 * 24 * 60 * 60 * 1000).toLocaleString());
+ } finally {
Locale.setDefault(loc);
- TimeZone.setDefault(tz);
- }
+ TimeZone.setDefault(tz);
+ }
}
static TimeZone defaultTimeZone = TimeZone.getDefault();