void test1() {
    Locale[] available = Locale.getAvailableLocales();
    List<Locale> jreimplloc =
        Arrays.asList(
            LocaleProviderAdapter.forJRE().getTimeZoneNameProvider().getAvailableLocales());
    List<Locale> providerLocales = Arrays.asList(tznp.getAvailableLocales());
    String[] ids = TimeZone.getAvailableIDs();

    for (Locale target : available) {
      // pure JRE implementation
      OpenListResourceBundle rb =
          ((ResourceBundleBasedAdapter) LocaleProviderAdapter.forJRE())
              .getLocaleData()
              .getTimeZoneNames(target);
      boolean jreSupportsTarget = jreimplloc.contains(target);

      for (String id : ids) {
        // the time zone
        TimeZone tz = TimeZone.getTimeZone(id);

        // JRE string array for the id
        String[] jrearray = null;
        if (jreSupportsTarget) {
          try {
            jrearray = rb.getStringArray(id);
          } catch (MissingResourceException mre) {
          }
        }

        for (int i = 1; i <= (tz.useDaylightTime() ? 4 : 2); i++) {
          // the localized name
          String name = tz.getDisplayName(i >= 3, i % 2, target);

          // provider's name (if any)
          String providersname = null;
          if (providerLocales.contains(target)) {
            providersname = tznp.getDisplayName(id, i >= 3, i % 2, target);
          }

          // JRE's name
          String jresname = null;
          if (jrearray != null) {
            jresname = jrearray[i];
          }

          checkValidity(
              target, jresname, providersname, name, jreSupportsTarget && jresname != null);
        }
      }
    }
  }
  void test2() {
    Locale defaultLocale = Locale.getDefault();
    TimeZone reservedTimeZone = TimeZone.getDefault();
    Date d = new Date(2005 - 1900, Calendar.DECEMBER, 22);
    String formatted;

    TimeZone tz;
    SimpleDateFormat df;

    try {
      for (int i = 0; i < TIMEZONES.length; i++) {
        tz = TimeZone.getTimeZone(TIMEZONES[i]);
        TimeZone.setDefault(tz);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance(OSAKA));
        Locale.setDefault(defaultLocale);
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_OSAKA[i])) {
          throw new RuntimeException(
              "TimeZone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_OSAKA[i]);
        }

        df.parse(DISPLAY_NAMES_OSAKA[i]);

        Locale.setDefault(KYOTO);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance());
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_KYOTO[i])) {
          throw new RuntimeException(
              "Timezone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_KYOTO[i]);
        }
        df.parse(DISPLAY_NAMES_KYOTO[i]);
      }
    } catch (ParseException pe) {
      throw new RuntimeException("parse error occured" + pe);
    } finally {
      // restore the reserved locale and time zone
      Locale.setDefault(defaultLocale);
      TimeZone.setDefault(reservedTimeZone);
    }
  }
 void test3() {
   final String[] TZNAMES = {
     LATIME, PST, PST8PDT, US_PACIFIC, TOKYOTIME, JST, JAPAN,
   };
   for (String tzname : TZNAMES) {
     TimeZone tz = TimeZone.getTimeZone(tzname);
     for (int style : new int[] {TimeZone.LONG, TimeZone.SHORT}) {
       String osakaStd = tz.getDisplayName(false, style, OSAKA);
       if (osakaStd != null) {
         // No API for getting generic time zone names
         String generic = TimeZoneNameUtility.retrieveGenericDisplayName(tzname, style, GENERIC);
         String expected = "Generic " + osakaStd;
         if (!expected.equals(generic)) {
           throw new RuntimeException(
               "Wrong generic name: got=\"" + generic + "\", expected=\"" + expected + "\"");
         }
       }
     }
   }
 }
  void aliasTest() {
    // Check that provider's name for a standard id (America/Los_Angeles) is
    // propagated to its aliases
    String latime = TimeZone.getTimeZone(LATIME).getDisplayName(OSAKA);
    if (!LATIME_IN_OSAKA.equals(latime)) {
      throw new RuntimeException(
          "Could not get provider's localized name.  result: "
              + latime
              + " expected: "
              + LATIME_IN_OSAKA);
    }

    String pst = TimeZone.getTimeZone(PST).getDisplayName(OSAKA);
    if (!LATIME_IN_OSAKA.equals(pst)) {
      throw new RuntimeException(
          "Provider's localized name is not available for an alias ID: "
              + PST
              + ".  result: "
              + pst
              + " expected: "
              + LATIME_IN_OSAKA);
    }

    String us_pacific = TimeZone.getTimeZone(US_PACIFIC).getDisplayName(OSAKA);
    if (!LATIME_IN_OSAKA.equals(us_pacific)) {
      throw new RuntimeException(
          "Provider's localized name is not available for an alias ID: "
              + US_PACIFIC
              + ".  result: "
              + us_pacific
              + " expected: "
              + LATIME_IN_OSAKA);
    }

    // Check that provider's name for an alias id (JST) is
    // propagated to its standard id and alias ids.
    String jstime = TimeZone.getTimeZone(JST).getDisplayName(OSAKA);
    if (!JST_IN_OSAKA.equals(jstime)) {
      throw new RuntimeException(
          "Could not get provider's localized name.  result: "
              + jstime
              + " expected: "
              + JST_IN_OSAKA);
    }

    String tokyotime = TimeZone.getTimeZone(TOKYOTIME).getDisplayName(OSAKA);
    if (!JST_IN_OSAKA.equals(tokyotime)) {
      throw new RuntimeException(
          "Provider's localized name is not available for a standard ID: "
              + TOKYOTIME
              + ".  result: "
              + tokyotime
              + " expected: "
              + JST_IN_OSAKA);
    }

    String japan = TimeZone.getTimeZone(JAPAN).getDisplayName(OSAKA);
    if (!JST_IN_OSAKA.equals(japan)) {
      throw new RuntimeException(
          "Provider's localized name is not available for an alias ID: "
              + JAPAN
              + ".  result: "
              + japan
              + " expected: "
              + JST_IN_OSAKA);
    }
  }