test/java/util/Currency/ValidateISO4217.java

Print this page


   1 /*
   2  * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
   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  *
  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.
  22  */
  23 /*
  24  * @test
  25  * @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203
  26  * @summary Validate ISO 4217 data for Currency class.
  27  */
  28 
  29 /*
  30  * ############################################################################
  31  *
  32  *  ValidateISO4217 is a tool to detect differences between the latest ISO 4217
  33  *  data and and Java's currency data which is based on ISO 4217.
  34  *  If there is a difference, the following file which includes currency data
  35  *  may need to be updated.
  36  *      src/share/classes/java/util/CurrencyData.properties
  37  *
  38  * ############################################################################
  39  *
  40  * 1) Make a golden-data file.
  41  *      From BSi's ISO4217 data (TABLE A1.doc), extract four (or eight, if currency is changing)
  42  *      fields and save as ./tablea1.txt.
  43  *        <Country code>\t<Currency code>\t<Numeric code>\t<Minor unit>[\t<Cutover Date>\t<new Currency code>\t<new Numeric code>\t<new Minor unit>]
  44  *      The Cutover Date is given in SimpleDateFormat's 'yyyy-MM-dd-HH-mm-ss' format in the GMT time zone.
  45  *


  75          * Defined in ISO 4217 list, but don't have code and minor unit info in
  76          * it. On the othe hand, both code and minor unit are defined in
  77          * .properties file. I don't know why, though.
  78          */
  79         {"GS", "GBP", "826", "2"},      // South Georgia And The South Sandwich Islands
  80 
  81         /* Not defined in ISO 4217 list, but defined in .properties file. */
  82         {"AX", "EUR", "978", "2"},      // \u00c5LAND ISLANDS
  83         {"PS", "ILS", "376", "2"},      // Palestinian Territory, Occupied
  84 
  85         /* Not defined in ISO 4217 list, but added in ISO 3166 country code list */
  86         {"JE", "GBP", "826", "2"},      // Jersey
  87         {"GG", "GBP", "826", "2"},      // Guernsey
  88         {"IM", "GBP", "826", "2"},      // Isle of Man
  89         {"BL", "EUR", "978", "2"},      // Saint Barthelemy
  90         {"MF", "EUR", "978", "2"},      // Saint Martin
  91     };
  92 
  93     /* Codes that are obsolete, do not have related country */
  94     static final String otherCodes =
  95         "ADP-AFA-ATS-AYM-BEF-BGL-BOV-BYB-CLF-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-NLG-PTE-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-USN-USS-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZWD-ZWN-ZWR";
  96 
  97     static boolean err = false;
  98 
  99     static Set<Currency> testCurrencies = new HashSet<Currency>();
 100 
 101     public static void main(String[] args) throws Exception {
 102         CheckDataVersion.check();
 103         test1();
 104         test2();
 105         getAvailableCurrenciesTest();
 106 
 107         if (err) {
 108             throw new RuntimeException("Failed: Validation ISO 4217 data");
 109         }
 110     }
 111 
 112     static void test1() throws Exception {
 113 
 114         try (FileReader fr = new FileReader(new File(System.getProperty("test.src", "."), datafile));
 115              BufferedReader in = new BufferedReader(fr))


   1 /*
   2  * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
   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  *
  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.
  22  */
  23 /*
  24  * @test
  25  * @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759
  26  * @summary Validate ISO 4217 data for Currency class.
  27  */
  28 
  29 /*
  30  * ############################################################################
  31  *
  32  *  ValidateISO4217 is a tool to detect differences between the latest ISO 4217
  33  *  data and and Java's currency data which is based on ISO 4217.
  34  *  If there is a difference, the following file which includes currency data
  35  *  may need to be updated.
  36  *      src/share/classes/java/util/CurrencyData.properties
  37  *
  38  * ############################################################################
  39  *
  40  * 1) Make a golden-data file.
  41  *      From BSi's ISO4217 data (TABLE A1.doc), extract four (or eight, if currency is changing)
  42  *      fields and save as ./tablea1.txt.
  43  *        <Country code>\t<Currency code>\t<Numeric code>\t<Minor unit>[\t<Cutover Date>\t<new Currency code>\t<new Numeric code>\t<new Minor unit>]
  44  *      The Cutover Date is given in SimpleDateFormat's 'yyyy-MM-dd-HH-mm-ss' format in the GMT time zone.
  45  *


  75          * Defined in ISO 4217 list, but don't have code and minor unit info in
  76          * it. On the othe hand, both code and minor unit are defined in
  77          * .properties file. I don't know why, though.
  78          */
  79         {"GS", "GBP", "826", "2"},      // South Georgia And The South Sandwich Islands
  80 
  81         /* Not defined in ISO 4217 list, but defined in .properties file. */
  82         {"AX", "EUR", "978", "2"},      // \u00c5LAND ISLANDS
  83         {"PS", "ILS", "376", "2"},      // Palestinian Territory, Occupied
  84 
  85         /* Not defined in ISO 4217 list, but added in ISO 3166 country code list */
  86         {"JE", "GBP", "826", "2"},      // Jersey
  87         {"GG", "GBP", "826", "2"},      // Guernsey
  88         {"IM", "GBP", "826", "2"},      // Isle of Man
  89         {"BL", "EUR", "978", "2"},      // Saint Barthelemy
  90         {"MF", "EUR", "978", "2"},      // Saint Martin
  91     };
  92 
  93     /* Codes that are obsolete, do not have related country */
  94     static final String otherCodes =
  95         "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-CLF-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZMK-ZWD-ZWN-ZWR";
  96 
  97     static boolean err = false;
  98 
  99     static Set<Currency> testCurrencies = new HashSet<Currency>();
 100 
 101     public static void main(String[] args) throws Exception {
 102         CheckDataVersion.check();
 103         test1();
 104         test2();
 105         getAvailableCurrenciesTest();
 106 
 107         if (err) {
 108             throw new RuntimeException("Failed: Validation ISO 4217 data");
 109         }
 110     }
 111 
 112     static void test1() throws Exception {
 113 
 114         try (FileReader fr = new FileReader(new File(System.getProperty("test.src", "."), datafile));
 115              BufferedReader in = new BufferedReader(fr))