Exemplo n.º 1
0
  private static void checkConstants() {
    // Check FORMAT_*
    if (!CONTROL.FORMAT_DEFAULT.equals(Arrays.asList("java.class", "java.properties"))) {
      error("Wrong Control.FORMAT_DEFAULT");
    }
    checkImmutableList(CONTROL.FORMAT_DEFAULT);
    if (!CONTROL.FORMAT_CLASS.equals(Arrays.asList("java.class"))) {
      error("Wrong Control.FORMAT_CLASS");
    }
    checkImmutableList(CONTROL.FORMAT_CLASS);
    if (!CONTROL.FORMAT_PROPERTIES.equals(Arrays.asList("java.properties"))) {
      error("Wrong Control.FORMAT_PROPERTIES");
    }
    checkImmutableList(CONTROL.FORMAT_PROPERTIES);

    // Check TTL_*
    if (CONTROL.TTL_DONT_CACHE != -1) {
      error("Wrong Control.TTL_DONT_CACHE: %d%n", CONTROL.TTL_DONT_CACHE);
    }
    if (CONTROL.TTL_NO_EXPIRATION_CONTROL != -2) {
      error("Wrong Control.TTL_NO_EXPIRATION_CONTROL: %d%n", CONTROL.TTL_NO_EXPIRATION_CONTROL);
    }
  }
Exemplo n.º 2
0
  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) {
      }
    }
  }