private static void testToBundleName() {
    final String name = "J2SE";
    Map<Locale, String> bundleNames = new HashMap<Locale, String>();
    bundleNames.put(new Locale("ja", "JP", "YOK"), name + "_" + "ja" + "_" + "JP" + "_" + "YOK");
    bundleNames.put(new Locale("ja", "JP"), name + "_" + "ja" + "_" + "JP");
    bundleNames.put(new Locale("ja"), name + "_" + "ja");
    bundleNames.put(new Locale("ja", "", "YOK"), name + "_" + "ja" + "_" + "" + "_" + "YOK");
    bundleNames.put(new Locale("", "JP", "YOK"), name + "_" + "" + "_" + "JP" + "_" + "YOK");
    bundleNames.put(new Locale("", "", "YOK"), name + "_" + "" + "_" + "" + "_" + "YOK");
    bundleNames.put(new Locale("", "JP"), name + "_" + "" + "_" + "JP");
    bundleNames.put(new Locale(""), name);

    for (Locale locale : bundleNames.keySet()) {
      String bn = CONTROL.toBundleName(name, locale);
      String expected = bundleNames.get(locale);
      if (!bn.equals(expected)) {
        error("toBundleName: got %s, expected %s%n", bn, expected);
      }
    }

    final int NARGS = 2;
    for (int mask = 0; mask < (1 << NARGS) - 1; mask++) {
      Object[] data = getNpeArgs(NARGS, mask);
      try {
        String s = CONTROL.toBundleName((String) data[0], (Locale) data[1]);
        error("toBundleName(%s, %s) doesn't throw NPE.%n", data[0], data[1]);
      } catch (NullPointerException e) {
      }
    }
  }
  private static void testGetCandidateLocales() {
    Map<Locale, Locale[]> candidateData = new HashMap<Locale, Locale[]>();
    candidateData.put(
        new Locale("ja", "JP", "YOK"),
        new Locale[] {
          new Locale("ja", "JP", "YOK"), new Locale("ja", "JP"), new Locale("ja"), new Locale("")
        });
    candidateData.put(
        new Locale("ja", "JP"),
        new Locale[] {new Locale("ja", "JP"), new Locale("ja"), new Locale("")});
    candidateData.put(new Locale("ja"), new Locale[] {new Locale("ja"), new Locale("")});

    candidateData.put(
        new Locale("ja", "", "YOK"),
        new Locale[] {new Locale("ja", "", "YOK"), new Locale("ja"), new Locale("")});
    candidateData.put(
        new Locale("", "JP", "YOK"),
        new Locale[] {new Locale("", "JP", "YOK"), new Locale("", "JP"), new Locale("")});
    candidateData.put(
        new Locale("", "", "YOK"), new Locale[] {new Locale("", "", "YOK"), new Locale("")});
    candidateData.put(new Locale("", "JP"), new Locale[] {new Locale("", "JP"), new Locale("")});
    candidateData.put(new Locale(""), new Locale[] {new Locale("")});

    for (Locale locale : candidateData.keySet()) {
      List<Locale> candidates = CONTROL.getCandidateLocales("any", locale);
      List<Locale> expected = Arrays.asList(candidateData.get(locale));
      if (!candidates.equals(expected)) {
        error(
            "Wrong candidates for %s: got %s, expected %s%n",
            toString(locale), candidates, expected);
      }
    }
    final int NARGS = 2;
    for (int mask = 0; mask < (1 << NARGS) - 1; mask++) {
      Object[] data = getNpeArgs(NARGS, mask);
      try {
        List<Locale> candidates = CONTROL.getCandidateLocales((String) data[0], (Locale) data[1]);
        error(
            "getCandidateLocales(%s, %s) doesn't throw NPE.%n",
            data[0], toString((Locale) data[1]));
      } catch (NullPointerException e) {
      }
    }
  }