|
26 | 26 | import javax.money.format.MonetaryAmountFormat; |
27 | 27 | import javax.money.format.MonetaryFormats; |
28 | 28 | import java.text.DecimalFormat; |
| 29 | +import java.util.Arrays; |
29 | 30 | import java.util.HashSet; |
30 | 31 | import java.util.Locale; |
31 | 32 | import java.util.Set; |
|
36 | 37 | @SpecVersion(spec = "JSR 354", version = "1.1.0") |
37 | 38 | public class FormattingMonetaryAmountsTest { |
38 | 39 |
|
| 40 | + /** Some languages don't accept foreign currencies like USD in the JDK, so we have to skip them for now */ |
| 41 | + private static final Set<String> SKIPPED_LANGUAGES = new HashSet<>( |
| 42 | + Arrays.asList(new String[] {"as", "ar", "bn", "ckb", "dz", "fa", "hi", "ig", "ks", "lrc", |
| 43 | + "mr", "my", "mzn", "ne", "pa", "ps", "sd", "th", "ur", "uz"})); |
| 44 | + |
39 | 45 | /** |
40 | 46 | * Format several amounts, created using the default factory, |
41 | 47 | * but |
@@ -104,6 +110,9 @@ public void testFormattingIsIndependentOfImplementation() { |
104 | 110 | "Locale.") |
105 | 111 | public void testParseIsIndependentOfImplementation() { |
106 | 112 | for (Locale locale : MonetaryFormats.getAvailableLocales()) { |
| 113 | + if (SKIPPED_LANGUAGES.contains(locale.getLanguage())) { |
| 114 | + continue; |
| 115 | + } |
107 | 116 | MonetaryAmountFormat format = MonetaryFormats.getAmountFormat(locale); |
108 | 117 | for (MonetaryAmountFactory fact : Monetary.getAmountFactories()) { |
109 | 118 | if (fact.getAmountType().equals(TestAmount.class)) { |
@@ -138,6 +147,9 @@ public void testParseIsIndependentOfImplementation() { |
138 | 147 | "using different format queries.") |
139 | 148 | public void testParseDifferentStyles() { |
140 | 149 | for (Locale locale : MonetaryFormats.getAvailableLocales()) { |
| 150 | + if (SKIPPED_LANGUAGES.contains(locale.getLanguage())) { |
| 151 | + continue; |
| 152 | + } |
141 | 153 | for (Class clazz : Monetary.getAmountTypes()) { |
142 | 154 | if (clazz.equals(TestAmount.class)) { |
143 | 155 | continue; |
@@ -180,6 +192,9 @@ public void testParseDifferentStyles() { |
180 | 192 | " checks results for different currencies") |
181 | 193 | public void testParseWithDifferentCurrencies() { |
182 | 194 | for (Locale locale : MonetaryFormats.getAvailableLocales()) { |
| 195 | + if (SKIPPED_LANGUAGES.contains(locale.getLanguage())) { |
| 196 | + continue; |
| 197 | + } |
183 | 198 | MonetaryAmountFormat format = MonetaryFormats.getAmountFormat(locale); |
184 | 199 | for (MonetaryAmountFactory fact : Monetary.getAmountFactories()) { |
185 | 200 | if (fact.getAmountType().equals(TestAmount.class)) { |
@@ -208,7 +223,6 @@ public void testParseWithDifferentCurrencies() { |
208 | 223 | } |
209 | 224 | } |
210 | 225 |
|
211 | | - |
212 | 226 | /** |
213 | 227 | * AccessingMonetaryAmountFormat using |
214 | 228 | * MonetaryFormats.getAmountFormat(Locale locale), all locales |
|
0 commit comments