32 public class LocaleNameProviderTest extends ProviderTest {
33
34 public static void main(String[] s) {
35 new LocaleNameProviderTest();
36 }
37
38 LocaleNameProviderTest() {
39 checkAvailLocValidityTest();
40 variantFallbackTest();
41 }
42
43 void checkAvailLocValidityTest() {
44 com.bar.LocaleNameProviderImpl lnp = new com.bar.LocaleNameProviderImpl();
45 Locale[] availloc = Locale.getAvailableLocales();
46 Locale[] testloc = availloc.clone();
47 List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getLocaleNameProvider().getAvailableLocales());
48 List<Locale> providerloc = Arrays.asList(lnp.getAvailableLocales());
49
50 for (Locale target: availloc) {
51 // pure JRE implementation
52 OpenListResourceBundle rb = LocaleProviderAdapter.forJRE().getLocaleData().getLocaleNames(target);
53 boolean jreSupportsTarget = jreimplloc.contains(target);
54
55 for (Locale test: testloc) {
56 // codes
57 String lang = test.getLanguage();
58 String ctry = test.getCountry();
59 String vrnt = test.getVariant();
60
61 // the localized name
62 String langresult = test.getDisplayLanguage(target);
63 String ctryresult = test.getDisplayCountry(target);
64 String vrntresult = test.getDisplayVariant(target);
65
66 // provider's name (if any)
67 String providerslang = null;
68 String providersctry = null;
69 String providersvrnt = null;
70 if (providerloc.contains(target)) {
71 providerslang = lnp.getDisplayLanguage(lang, target);
72 providersctry = lnp.getDisplayCountry(ctry, target);
|
32 public class LocaleNameProviderTest extends ProviderTest {
33
34 public static void main(String[] s) {
35 new LocaleNameProviderTest();
36 }
37
38 LocaleNameProviderTest() {
39 checkAvailLocValidityTest();
40 variantFallbackTest();
41 }
42
43 void checkAvailLocValidityTest() {
44 com.bar.LocaleNameProviderImpl lnp = new com.bar.LocaleNameProviderImpl();
45 Locale[] availloc = Locale.getAvailableLocales();
46 Locale[] testloc = availloc.clone();
47 List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getLocaleNameProvider().getAvailableLocales());
48 List<Locale> providerloc = Arrays.asList(lnp.getAvailableLocales());
49
50 for (Locale target: availloc) {
51 // pure JRE implementation
52 OpenListResourceBundle rb = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getLocaleNames(target);
53 boolean jreSupportsTarget = jreimplloc.contains(target);
54
55 for (Locale test: testloc) {
56 // codes
57 String lang = test.getLanguage();
58 String ctry = test.getCountry();
59 String vrnt = test.getVariant();
60
61 // the localized name
62 String langresult = test.getDisplayLanguage(target);
63 String ctryresult = test.getDisplayCountry(target);
64 String vrntresult = test.getDisplayVariant(target);
65
66 // provider's name (if any)
67 String providerslang = null;
68 String providersctry = null;
69 String providersvrnt = null;
70 if (providerloc.contains(target)) {
71 providerslang = lnp.getDisplayLanguage(lang, target);
72 providersctry = lnp.getDisplayCountry(ctry, target);
|