Add a test to exercise RelativeDateTimeFormatter

Bug: 25821045
Change-Id: I75ffe4412d266f377474147aecbd9bffedb7f43a
diff --git a/luni/src/test/java/libcore/icu/RelativeDateTimeFormatterTest.java b/luni/src/test/java/libcore/icu/RelativeDateTimeFormatterTest.java
index 101896f..96b9e3b 100644
--- a/luni/src/test/java/libcore/icu/RelativeDateTimeFormatterTest.java
+++ b/luni/src/test/java/libcore/icu/RelativeDateTimeFormatterTest.java
@@ -16,8 +16,6 @@
 
 package libcore.icu;
 
-import android.icu.util.ULocale;
-
 import java.util.Calendar;
 import java.util.Locale;
 import java.util.TimeZone;
@@ -664,4 +662,26 @@
     assertEquals("December 7", getRelativeTimeSpanString(en_US, tz,
         base - 60 * DAY_IN_MILLIS, base, DAY_IN_MILLIS, FORMAT_NO_YEAR));
   }
+
+  // Check for missing ICU data. http://b/25821045
+  public void test_bug25821045() {
+    final TimeZone tz = TimeZone.getDefault();
+    final long now = System.currentTimeMillis();
+    final long time = now + 1000;
+    final int minResolution = 1000 * 60;
+    final int transitionResolution = minResolution;
+    final int flags = FORMAT_ABBREV_RELATIVE;
+    // Exercise all available locales, forcing the ICU implementation to pre-cache the data. This
+    // highlights data issues. It can take a while.
+    for (Locale locale : Locale.getAvailableLocales()) {
+      // In (e.g.) ICU56 an exception is thrown on the first use for a locale if required data for
+      // the "other" plural is missing. It doesn't matter what is actually formatted.
+      try {
+        RelativeDateTimeFormatter.getRelativeDateTimeString(
+            locale, tz, time, now, minResolution, transitionResolution, flags);
+      } catch (IllegalStateException e) {
+        fail("Failed to format for " + locale);
+      }
+    }
+  }
 }