author | nishjain |
Thu, 22 Feb 2018 11:52:01 +0530 | |
changeset 48929 | 28d8fc8cd3cd |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
36511 | 2 |
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
/* |
|
24 |
* @test |
|
25 |
* @bug 4290801 4692419 4693631 5101540 5104960 6296410 6336600 6371531 |
|
42930
b878b7b2788e
8167143: CLDR timezone parsing does not work for all locales
rgoel
parents:
42338
diff
changeset
|
26 |
* 6488442 7036905 8008577 8039317 8074350 8074351 8150324 8167143 |
2 | 27 |
* @summary Basic tests for Currency class. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37305
diff
changeset
|
28 |
* @modules java.base/java.util:open |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37305
diff
changeset
|
29 |
* jdk.localedata |
2 | 30 |
*/ |
31 |
||
32 |
import java.io.ByteArrayInputStream; |
|
33 |
import java.io.ByteArrayOutputStream; |
|
34 |
import java.io.ObjectInputStream; |
|
35 |
import java.io.ObjectOutputStream; |
|
37305
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
36 |
import java.time.LocalDate; |
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
37 |
import java.time.LocalTime; |
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
38 |
import java.time.ZoneId; |
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
39 |
import java.time.ZonedDateTime; |
2 | 40 |
import java.util.Currency; |
41 |
import java.util.Locale; |
|
42 |
||
43 |
||
44 |
public class CurrencyTest { |
|
45 |
||
46 |
public static void main(String[] args) throws Exception { |
|
47 |
CheckDataVersion.check(); |
|
48 |
testCurrencyCodeValidation(); |
|
49 |
testLocaleMapping(); |
|
50 |
testSymbols(); |
|
51 |
testFractionDigits(); |
|
52 |
testSerialization(); |
|
53 |
testDisplayNames(); |
|
29524
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
54 |
testFundsCodes(); |
2 | 55 |
} |
56 |
||
57 |
static void testCurrencyCodeValidation() { |
|
58 |
// test creation of some valid currencies |
|
59 |
testValidCurrency("USD"); |
|
60 |
testValidCurrency("EUR"); |
|
61 |
testValidCurrency("GBP"); |
|
62 |
testValidCurrency("JPY"); |
|
63 |
testValidCurrency("CNY"); |
|
64 |
testValidCurrency("CHF"); |
|
65 |
||
66 |
// test creation of some fictitious currencies |
|
67 |
testInvalidCurrency("AQD"); |
|
68 |
testInvalidCurrency("US$"); |
|
69 |
testInvalidCurrency("\u20AC"); |
|
70 |
} |
|
71 |
||
72 |
static void testValidCurrency(String currencyCode) { |
|
73 |
Currency currency1 = Currency.getInstance(currencyCode); |
|
74 |
Currency currency2 = Currency.getInstance(currencyCode); |
|
75 |
if (currency1 != currency2) { |
|
76 |
throw new RuntimeException("Didn't get same instance for same currency code"); |
|
77 |
} |
|
78 |
if (!currency1.getCurrencyCode().equals(currencyCode)) { |
|
79 |
throw new RuntimeException("Currency code changed"); |
|
80 |
} |
|
81 |
} |
|
82 |
||
83 |
static void testInvalidCurrency(String currencyCode) { |
|
84 |
boolean gotException = false; |
|
85 |
try { |
|
86 |
Currency currency = Currency.getInstance(currencyCode); |
|
87 |
} catch (IllegalArgumentException e) { |
|
88 |
gotException = true; |
|
89 |
} |
|
90 |
if (!gotException) { |
|
91 |
throw new RuntimeException("didn't get specified exception"); |
|
92 |
} |
|
93 |
} |
|
94 |
||
95 |
static void testLocaleMapping() { |
|
96 |
// very basic test: most countries have their own currency, and then |
|
97 |
// their currency code is an extension of their country code. |
|
98 |
Locale[] locales = Locale.getAvailableLocales(); |
|
99 |
int goodCountries = 0; |
|
100 |
int ownCurrencies = 0; |
|
101 |
for (int i = 0; i < locales.length; i++) { |
|
102 |
Locale locale = locales[i]; |
|
31263 | 103 |
String ctryCode = locale.getCountry(); |
104 |
int ctryLength = ctryCode.length(); |
|
105 |
if (ctryLength == 0 || |
|
106 |
ctryLength == 3 || // UN M.49 code |
|
107 |
ctryCode.matches("AA|Q[M-Z]|X[A-Z]|ZZ" + // user defined codes |
|
108 |
"AC|CP|DG|EA|EU|FX|IC|SU|TA|UK")) { // exceptional reservation codes |
|
2 | 109 |
boolean gotException = false; |
110 |
try { |
|
111 |
Currency.getInstance(locale); |
|
112 |
} catch (IllegalArgumentException e) { |
|
113 |
gotException = true; |
|
114 |
} |
|
115 |
if (!gotException) { |
|
116 |
throw new RuntimeException("didn't get specified exception"); |
|
117 |
} |
|
118 |
} else { |
|
119 |
goodCountries++; |
|
120 |
Currency currency = Currency.getInstance(locale); |
|
121 |
if (currency.getCurrencyCode().indexOf(locale.getCountry()) == 0) { |
|
122 |
ownCurrencies++; |
|
123 |
} |
|
124 |
} |
|
125 |
} |
|
126 |
System.out.println("Countries tested: " + goodCountries + |
|
127 |
", own currencies: " + ownCurrencies); |
|
128 |
if (ownCurrencies < (goodCountries / 2 + 1)) { |
|
129 |
throw new RuntimeException("suspicious: not enough countries have their own currency."); |
|
130 |
} |
|
131 |
||
132 |
// check a few countries that don't change their currencies too often |
|
133 |
String[] country1 = {"US", "CA", "JP", "CN", "SG", "CH"}; |
|
134 |
String[] currency1 = {"USD", "CAD", "JPY", "CNY", "SGD", "CHF"}; |
|
135 |
for (int i = 0; i < country1.length; i++) { |
|
136 |
checkCountryCurrency(country1[i], currency1[i]); |
|
137 |
} |
|
138 |
||
10835
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
139 |
/* |
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
140 |
* check currency changes |
37305
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
141 |
* In current implementation, there is no data of old currency and transition date at jdk/make/data/currency/CurrencyData.properties. |
10835
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
142 |
* So, all the switch data arrays are empty. In the future, if data of old currency and transition date are necessary for any country, the |
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
143 |
* arrays here can be updated so that the program can check the currency switch. |
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
144 |
*/ |
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
145 |
String[] switchOverCtry = {}; |
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
146 |
String[] switchOverOld = {}; |
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
147 |
String[] switchOverNew = {}; |
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
148 |
String[] switchOverTZ = {}; |
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
149 |
int[] switchOverYear = {}; |
37305
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
150 |
int[] switchOverMonth = {}; // java.time APIs accept month starting from 1 i.e. 01 for January |
10835
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
151 |
int[] switchOverDay = {}; |
bff1afbf602a
7077119: remove past transition dates from CurrencyData.properties file
yhuang
parents:
9148
diff
changeset
|
152 |
|
2 | 153 |
for (int i = 0; i < switchOverCtry.length; i++) { |
37305
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
154 |
ZoneId zoneId = ZoneId.of(switchOverTZ[i]); |
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
155 |
ZonedDateTime zonedDateAndTime = ZonedDateTime.of(LocalDate.of(switchOverYear[i], switchOverMonth[i], switchOverDay[i]), |
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
156 |
LocalTime.MIDNIGHT, zoneId); |
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
157 |
ZonedDateTime currentZonedDateAndTime = ZonedDateTime.now(zoneId); |
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
158 |
checkCountryCurrency(switchOverCtry[i], (currentZonedDateAndTime.isAfter(zonedDateAndTime) || |
bd7a1dd863f8
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
peytoia
parents:
36511
diff
changeset
|
159 |
currentZonedDateAndTime.isEqual(zonedDateAndTime)) ? switchOverNew[i] : switchOverOld[i]); |
2 | 160 |
} |
161 |
||
162 |
// check a country code which doesn't have a currency |
|
163 |
checkCountryCurrency("AQ", null); |
|
164 |
||
165 |
// check an invalid country code |
|
166 |
boolean gotException = false; |
|
167 |
try { |
|
168 |
Currency.getInstance(new Locale("", "EU")); |
|
169 |
} catch (IllegalArgumentException e) { |
|
170 |
gotException = true; |
|
171 |
} |
|
172 |
if (!gotException) { |
|
173 |
throw new RuntimeException("didn't get specified exception."); |
|
174 |
} |
|
175 |
} |
|
176 |
||
177 |
static void checkCountryCurrency(String countryCode, String expected) { |
|
178 |
Locale locale = new Locale("", countryCode); |
|
179 |
Currency currency = Currency.getInstance(locale); |
|
180 |
String code = (currency != null) ? currency.getCurrencyCode() : null; |
|
181 |
if (!(expected == null ? code == null : expected.equals(code))) { |
|
182 |
throw new RuntimeException("Wrong currency for " + |
|
183 |
locale.getDisplayCountry() + |
|
184 |
": expected " + expected + ", got " + code); |
|
185 |
} |
|
186 |
} |
|
187 |
||
188 |
static void testSymbols() { |
|
189 |
testSymbol("USD", Locale.US, "$"); |
|
190 |
testSymbol("EUR", Locale.GERMANY, "\u20AC"); |
|
42930
b878b7b2788e
8167143: CLDR timezone parsing does not work for all locales
rgoel
parents:
42338
diff
changeset
|
191 |
testSymbol("USD", Locale.PRC, "US$"); |
2 | 192 |
} |
193 |
||
194 |
static void testSymbol(String currencyCode, Locale locale, String expectedSymbol) { |
|
195 |
String symbol = Currency.getInstance(currencyCode).getSymbol(locale); |
|
196 |
if (!symbol.equals(expectedSymbol)) { |
|
197 |
throw new RuntimeException("Wrong symbol for currency " + |
|
198 |
currencyCode +": expected " + expectedSymbol + |
|
199 |
", got " + symbol); |
|
200 |
} |
|
201 |
} |
|
202 |
||
203 |
static void testFractionDigits() { |
|
204 |
testFractionDigits("USD", 2); |
|
205 |
testFractionDigits("EUR", 2); |
|
206 |
testFractionDigits("JPY", 0); |
|
207 |
testFractionDigits("XDR", -1); |
|
208 |
||
209 |
testFractionDigits("BHD", 3); |
|
210 |
testFractionDigits("IQD", 3); |
|
211 |
testFractionDigits("JOD", 3); |
|
212 |
testFractionDigits("KWD", 3); |
|
213 |
testFractionDigits("LYD", 3); |
|
214 |
testFractionDigits("OMR", 3); |
|
215 |
testFractionDigits("TND", 3); |
|
216 |
||
217 |
// Turkish Lira |
|
218 |
testFractionDigits("TRL", 0); |
|
219 |
testFractionDigits("TRY", 2); |
|
220 |
} |
|
221 |
||
222 |
static void testFractionDigits(String currencyCode, int expectedFractionDigits) { |
|
223 |
int digits = Currency.getInstance(currencyCode).getDefaultFractionDigits(); |
|
224 |
if (digits != expectedFractionDigits) { |
|
225 |
throw new RuntimeException("Wrong number of fraction digits for currency " + |
|
226 |
currencyCode +": expected " + expectedFractionDigits + |
|
227 |
", got " + digits); |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
static void testSerialization() throws Exception { |
|
232 |
Currency currency1 = Currency.getInstance("DEM"); |
|
233 |
||
234 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|
235 |
ObjectOutputStream oStream = new ObjectOutputStream(baos); |
|
236 |
oStream.writeObject(currency1); |
|
237 |
oStream.flush(); |
|
238 |
byte[] bytes = baos.toByteArray(); |
|
239 |
||
240 |
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
|
241 |
ObjectInputStream iStream = new ObjectInputStream(bais); |
|
242 |
Currency currency2 = (Currency) iStream.readObject(); |
|
243 |
||
244 |
if (currency1 != currency2) { |
|
245 |
throw new RuntimeException("serialization breaks class invariant"); |
|
246 |
} |
|
247 |
} |
|
248 |
||
249 |
static void testDisplayNames() { |
|
250 |
// null argument test |
|
251 |
try { |
|
252 |
testDisplayName("USD", null, ""); |
|
253 |
throw new RuntimeException("getDisplayName(NULL) did not throw an NPE."); |
|
254 |
} catch (NullPointerException npe) {} |
|
255 |
||
256 |
testDisplayName("USD", Locale.ENGLISH, "US Dollar"); |
|
257 |
testDisplayName("FRF", Locale.FRENCH, "franc fran\u00e7ais"); |
|
258 |
testDisplayName("DEM", Locale.GERMAN, "Deutsche Mark"); |
|
259 |
testDisplayName("ESP", new Locale("es"), "peseta espa\u00f1ola"); |
|
31263 | 260 |
testDisplayName("ITL", new Locale("it"), "lira italiana"); |
2 | 261 |
testDisplayName("JPY", Locale.JAPANESE, "\u65e5\u672c\u5186"); |
262 |
testDisplayName("KRW", Locale.KOREAN, "\ub300\ud55c\ubbfc\uad6d \uc6d0"); |
|
9148
8837e7172929
7036905: [de] dem - the german mark display name is incorrect
yhuang
parents:
5506
diff
changeset
|
263 |
testDisplayName("SEK", new Locale("sv"), "svensk krona"); |
2 | 264 |
testDisplayName("CNY", Locale.SIMPLIFIED_CHINESE, "\u4eba\u6c11\u5e01"); |
42930
b878b7b2788e
8167143: CLDR timezone parsing does not work for all locales
rgoel
parents:
42338
diff
changeset
|
265 |
testDisplayName("TWD", Locale.TRADITIONAL_CHINESE, "\u65b0\u53f0\u5e63"); |
2 | 266 |
} |
267 |
||
268 |
static void testDisplayName(String currencyCode, Locale locale, String expectedName) { |
|
269 |
String name = Currency.getInstance(currencyCode).getDisplayName(locale); |
|
270 |
if (!name.equals(expectedName)) { |
|
271 |
throw new RuntimeException("Wrong display name for currency " + |
|
272 |
currencyCode +": expected '" + expectedName + |
|
273 |
"', got '" + name + "'"); |
|
274 |
} |
|
275 |
} |
|
29524
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
276 |
static void testFundsCodes() { |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
277 |
testValidCurrency("BOV"); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
278 |
testValidCurrency("CHE"); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
279 |
testValidCurrency("CHW"); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
280 |
testValidCurrency("CLF"); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
281 |
testValidCurrency("COU"); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
282 |
testValidCurrency("MXV"); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
283 |
testValidCurrency("USN"); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
284 |
testValidCurrency("UYI"); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
285 |
|
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
286 |
testFractionDigits("BOV", 2); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
287 |
testFractionDigits("CHE", 2); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
288 |
testFractionDigits("CHW", 2); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
289 |
testFractionDigits("CLF", 4); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
290 |
testFractionDigits("COU", 2); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
291 |
testFractionDigits("MXV", 2); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
292 |
testFractionDigits("USN", 2); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
293 |
testFractionDigits("UYI", 0); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
294 |
|
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
295 |
testNumericCode("BOV", 984); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
296 |
testNumericCode("CHE", 947); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
297 |
testNumericCode("CHW", 948); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
298 |
testNumericCode("CLF", 990); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
299 |
testNumericCode("COU", 970); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
300 |
testNumericCode("MXV", 979); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
301 |
testNumericCode("USN", 997); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
302 |
testNumericCode("UYI", 940); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
303 |
} |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
304 |
|
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
305 |
static void testNumericCode(String currencyCode, int expectedNumeric) { |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
306 |
int numeric = Currency.getInstance(currencyCode).getNumericCode(); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
307 |
if (numeric != expectedNumeric) { |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
308 |
throw new RuntimeException("Wrong numeric code for currency " + |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
309 |
currencyCode +": expected " + expectedNumeric + |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
310 |
", got " + numeric); |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
311 |
} |
2dbceeab4b8b
8074350: Support ISO 4217 "Current funds codes" table (A.2)
naoto
parents:
25174
diff
changeset
|
312 |
} |
2 | 313 |
} |