Integrate change cherry-picked for ticket #12986 into android_icu4j.
am: a6da7bf0be

Change-Id: I82eb858dfe6c402600ee8ec00ea78adcd5d980b2
diff --git a/android_icu4j/src/main/tests/android/icu/dev/test/translit/TransliteratorInstantiateAllTest.java b/android_icu4j/src/main/tests/android/icu/dev/test/translit/TransliteratorInstantiateAllTest.java
new file mode 100644
index 0000000..f9abebb
--- /dev/null
+++ b/android_icu4j/src/main/tests/android/icu/dev/test/translit/TransliteratorInstantiateAllTest.java
@@ -0,0 +1,69 @@
+/* GENERATED SOURCE. DO NOT MODIFY. */
+// © 2017 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html#License
+package android.icu.dev.test.translit;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import android.icu.dev.test.TestFmwk;
+import android.icu.text.Transliterator;
+import android.icu.testsharding.MainTestShard;
+
+/***********************************************************************
+
+This test class uses JUnit parametrization to iterate over all
+transliterators and to execute a sample operation.
+
+***********************************************************************/
+
+@MainTestShard
+@RunWith(Parameterized.class)
+public class TransliteratorInstantiateAllTest extends TestFmwk {
+    private String testTransliteratorID;
+
+    public TransliteratorInstantiateAllTest /*InstantiationTest*/(String t) {
+        this.testTransliteratorID = t;
+    }
+
+    @Parameterized.Parameters
+    public static Collection testData() {
+        ArrayList<String> allTranslitIDs = new ArrayList<String>();
+
+        for (Enumeration e = Transliterator.getAvailableIDs(); e.hasMoreElements(); ) {
+            allTranslitIDs.add((String) e.nextElement());
+        }
+
+        return allTranslitIDs;
+    }
+
+    @Test
+    public void TestInstantiation() {
+        Transliterator t = null;
+
+        try {
+            t = Transliterator.getInstance(testTransliteratorID);
+        } catch (IllegalArgumentException ex) {
+            errln("FAIL: " + testTransliteratorID);
+            throw ex;
+        }
+
+        if (t != null) {
+            // Test toRules
+            String rules = null;
+            try {
+                rules = t.toRules(true);
+                Transliterator.createFromRules("x", rules, Transliterator.FORWARD);
+            } catch (IllegalArgumentException ex2) {
+                errln("FAIL: " + "ID" + ".toRules() => bad rules: " +
+                      rules);
+                throw ex2;
+            }
+        }
+    }
+}
diff --git a/android_icu4j/src/main/tests/android/icu/dev/test/translit/TransliteratorTest.java b/android_icu4j/src/main/tests/android/icu/dev/test/translit/TransliteratorTest.java
index fdb0468..c1df1d4 100644
--- a/android_icu4j/src/main/tests/android/icu/dev/test/translit/TransliteratorTest.java
+++ b/android_icu4j/src/main/tests/android/icu/dev/test/translit/TransliteratorTest.java
@@ -166,64 +166,15 @@
         }
     }
 
-    // Android-changed: increase timeout.
-    @Test(timeout = 3000000L)
-    public void TestInstantiation() {
-        long ms = System.currentTimeMillis();
-        String ID;
-        for (Enumeration e = Transliterator.getAvailableIDs(); e.hasMoreElements(); ) {
-            ID = (String) e.nextElement();
-            if (ID.equals("Latin-Han/definition")) {
-                System.out.println("\nTODO: disabling Latin-Han/definition check for now: fix later");
-                continue;
-            }
-            Transliterator t = null;
-            try {
-                t = Transliterator.getInstance(ID);
-                // This is only true for some subclasses
-                //                // We should get a new instance if we try again
-                //                Transliterator t2 = Transliterator.getInstance(ID);
-                //                if (t != t2) {
-                //                    logln("OK: " + Transliterator.getDisplayName(ID) + " (" + ID + "): " + t);
-                //                } else {
-                //                    errln("FAIL: " + ID + " returned identical instances");
-                //                    t = null;
-                //                }
-            } catch (IllegalArgumentException ex) {
-                errln("FAIL: " + ID);
-                throw ex;
-            }
-
-            //            if (t.getFilter() != null) {
-            //                errln("Fail: Should never have filter on transliterator unless we started with one: " + ID + ", " + t.getFilter());
-            //            }
-
-            if (t != null) {
-                // Now test toRules
-                String rules = null;
-                try {
-                    rules = t.toRules(true);
-
-                    Transliterator.createFromRules("x", rules, Transliterator.FORWARD);
-                } catch (IllegalArgumentException ex2) {
-                    errln("FAIL: " + ID + ".toRules() => bad rules: " +
-                            rules);
-                    throw ex2;
-                }
-            }
-        }
-
-        // Now test the failure path
+    @Test
+    public void TestInstantiationError() {
         try {
-            ID = "<Not a valid Transliterator ID>";
+            String ID = "<Not a valid Transliterator ID>";
             Transliterator t = Transliterator.getInstance(ID);
             errln("FAIL: " + ID + " returned " + t);
         } catch (IllegalArgumentException ex) {
             logln("OK: Bogus ID handled properly");
         }
-
-        ms = System.currentTimeMillis() - ms;
-        logln("Elapsed time: " + ms + " ms");
     }
 
     @Test