Fix all the harmony java.util.Formatter tests.
ICU thinks that German short weekday names should be "So." et seq rather than
"So". This brings us into line with frameworks/base, which I'm depressed to find
has its own copy of the CLDR data in XML form (and its own date/time
formatters).
Also fix TestEnvironment to not clobber "user.name", which we need in order to
set our expectations in cases where being root affects what we can/can't do.
(This also fixes a few other harmony tests.)
diff --git a/libcore/luni/src/test/java/tests/api/java/util/CalendarTest.java b/libcore/luni/src/test/java/tests/api/java/util/CalendarTest.java
index cc0f91a..4ffe2c6 100644
--- a/libcore/luni/src/test/java/tests/api/java/util/CalendarTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/util/CalendarTest.java
@@ -983,11 +983,12 @@
// locale dependent test, bug 1943269
return;
}
+ Locale.setDefault(Locale.US);
Calendar cal = Calendar.getInstance();
- assertTrue(cal.getMinimalDaysInFirstWeek()==1);
+ assertEquals(1, cal.getMinimalDaysInFirstWeek());
Locale.setDefault(Locale.FRANCE);
cal = Calendar.getInstance();
- assertTrue(cal.getMinimalDaysInFirstWeek()==4);
+ assertEquals(4, cal.getMinimalDaysInFirstWeek());
Locale.setDefault(Locale.US);
}
diff --git a/libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java b/libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java
index fb03a34..1b16c93 100644
--- a/libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java
+++ b/libcore/luni/src/test/java/tests/api/java/util/FormatterTest.java
@@ -2101,25 +2101,25 @@
china.set(Calendar.MILLISECOND, 609);
final Object[][] lowerCaseGermanTriple = {
- {0L, 'a', "Do"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'a', "So"}, //$NON-NLS-2$
- {-1000L, 'a', "Do"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'a', "Do"}, //$NON-NLS-2$
- {paris, 'a', "Mo"}, //$NON-NLS-2$
- {china, 'a', "Mo"}, //$NON-NLS-2$
+ {0L, 'a', "Do."}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'a', "So."}, //$NON-NLS-2$
+ {-1000L, 'a', "Do."}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'a', "Do."}, //$NON-NLS-2$
+ {paris, 'a', "Mo."}, //$NON-NLS-2$
+ {china, 'a', "Mo."}, //$NON-NLS-2$
{0L, 'b', "Jan"}, //$NON-NLS-2$
{Long.MAX_VALUE, 'b', "Aug"}, //$NON-NLS-2$
{-1000L, 'b', "Jan"}, //$NON-NLS-2$
{new Date(1147327147578L), 'b', "Mai"}, //$NON-NLS-2$
{paris, 'b', "Mai"}, //$NON-NLS-2$
{china, 'b', "Mai"}, //$NON-NLS-2$
- {0L, 'c', "Do Jan 01 08:00:00 GMT+08:00 1970"}, //$NON-NLS-2$
- // {Long.MAX_VALUE, 'c', "So Aug 17 15:12:55 GMT+08:00 292278994"}, //$NON-NLS-2$
- {Long.MAX_VALUE, 'c', "So Aug 17 15:18:47 GMT+08:00 292278994"}, //$NON-NLS-2$
- {-1000L, 'c', "Do Jan 01 07:59:59 GMT+08:00 1970"}, //$NON-NLS-2$
- {new Date(1147327147578L), 'c', "Do Mai 11 13:59:07 GMT+08:00 2006"}, //$NON-NLS-2$
- {paris, 'c', "Mo Mai 08 12:00:00 MESZ 2006"}, //$NON-NLS-2$
- {china, 'c', "Mo Mai 08 12:00:00 GMT-08:00 2006"}, //$NON-NLS-2$
+ {0L, 'c', "Do. Jan 01 08:00:00 GMT+08:00 1970"}, //$NON-NLS-2$
+ // {Long.MAX_VALUE, 'c', "So. Aug 17 15:12:55 GMT+08:00 292278994"}, //$NON-NLS-2$
+ {Long.MAX_VALUE, 'c', "So. Aug 17 15:18:47 GMT+08:00 292278994"}, //$NON-NLS-2$
+ {-1000L, 'c', "Do. Jan 01 07:59:59 GMT+08:00 1970"}, //$NON-NLS-2$
+ {new Date(1147327147578L), 'c', "Do. Mai 11 13:59:07 GMT+08:00 2006"}, //$NON-NLS-2$
+ {paris, 'c', "Mo. Mai 08 12:00:00 MESZ 2006"}, //$NON-NLS-2$
+ {china, 'c', "Mo. Mai 08 12:00:00 GMT-08:00 2006"}, //$NON-NLS-2$
{0L, 'd', "01"}, //$NON-NLS-2$
{Long.MAX_VALUE, 'd', "17"}, //$NON-NLS-2$
{-1000L, 'd', "01"}, //$NON-NLS-2$
diff --git a/libcore/support/src/test/java/tests/util/TestEnvironment.java b/libcore/support/src/test/java/tests/util/TestEnvironment.java
index 69a87c2..088e624 100644
--- a/libcore/support/src/test/java/tests/util/TestEnvironment.java
+++ b/libcore/support/src/test/java/tests/util/TestEnvironment.java
@@ -73,12 +73,21 @@
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
}
- private static void resetSystemProperties() {
- String tmpDir = System.getProperty("java.io.tmpdir");
- if (tmpDir == null) {
- throw new IllegalStateException("Test execution requires the"
- + " system property java.io.tmpdir to be set.");
+ private static String getExistingSystemProperty(String name) {
+ String result = System.getProperty(name);
+ if (result == null) {
+ throw new AssertionError("Tests require the '" + name + "' system property");
}
+ return result;
+ }
+
+ private static void resetSystemProperties() {
+ // There are two system properties we can't live without.
+ // 1. We need somewhere writable to stash our stuff.
+ String tmpDir = getExistingSystemProperty("java.io.tmpdir");
+ // 2. We need to know who we are, specifically "am I root?" because that affects what
+ // the OS lets us do, and that affects test expectations.
+ String userName = getExistingSystemProperty("user.name");
Properties p = new Properties();
@@ -129,7 +138,7 @@
p.put("line.separator", "\n");
p.put("path.separator", ":");
p.put("user.language", "en");
- p.put("user.name", "");
+ p.put("user.name", userName);
p.put("user.region", "US");
System.setProperties(p);