tests/libjava-mauve/src/gnu/testlet/java/util/Currency/France.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: JDK1.4
       
     2 
       
     3 // Copyright (C) 2004 Andrew John Hughes <gnu_andrew@member.fsf.org>
       
     4 
       
     5 // This file is part of Mauve.
       
     6 
       
     7 // Mauve is free software; you can redistribute it and/or modify
       
     8 // it under the terms of the GNU General Public License as published by
       
     9 // the Free Software Foundation; either version 2, or (at your option)
       
    10 // any later version.
       
    11 
       
    12 // Mauve is distributed in the hope that it will be useful,
       
    13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15 // GNU General Public License for more details.
       
    16 
       
    17 // You should have received a copy of the GNU General Public License
       
    18 // along with Mauve; see the file COPYING.  If not, write to
       
    19 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    20 // Boston, MA 02111-1307, USA.
       
    21 
       
    22 package gnu.testlet.java.util.Currency;
       
    23 
       
    24 import gnu.testlet.Testlet;
       
    25 import gnu.testlet.TestHarness;
       
    26 import java.util.Calendar;
       
    27 import java.util.Currency;
       
    28 import java.util.Locale;
       
    29 
       
    30 /**
       
    31  * Class to test the French currency.
       
    32  *
       
    33  * @author Andrew John Hughes <gnu_andrew@member.fsf.org>
       
    34  */
       
    35 public class France implements Testlet
       
    36 {
       
    37 
       
    38   private static final Locale TEST_LOCALE = Locale.FRANCE;
       
    39   private static final String ISO4217_CODE = "FRF";
       
    40   private static final String CURRENCY_SYMBOL = ").";
       
    41   private static final int FRACTION_DIGITS = 2;
       
    42   private static final String EURO_ISO4217_CODE = "EUR";
       
    43   private static final String EURO_CURRENCY_SYMBOL = "\u20AC";
       
    44   private static final int EURO_FRACTION_DIGITS = 2;
       
    45   private static final int EURO_CHANGE_YEAR = 2002;
       
    46   private static final int EURO_CHANGE_MONTH = 0;
       
    47   private static final int EURO_CHANGE_DATE = 1;
       
    48 
       
    49   public void test(TestHarness harness)
       
    50   {
       
    51     Currency currency;
       
    52     Calendar calendar;
       
    53     Calendar euroCalendar;
       
    54 
       
    55     /* Set default Locale for the JVM */
       
    56     Locale.setDefault(TEST_LOCALE);
       
    57     /* Get an instance of the currency */
       
    58     currency = Currency.getInstance(TEST_LOCALE);
       
    59     /* Get the current time in the locale */
       
    60     calendar = Calendar.getInstance(TEST_LOCALE);
       
    61     /* Get the Euro change-over time in the locale */
       
    62     euroCalendar = Calendar.getInstance(TEST_LOCALE);
       
    63     euroCalendar.set(EURO_CHANGE_YEAR, EURO_CHANGE_MONTH, EURO_CHANGE_DATE);
       
    64     /* Do different comparisons depending on the state of change to the Euro */
       
    65     if (calendar.after(euroCalendar))
       
    66       {
       
    67         /* Check for the correct currency code */
       
    68         harness.check(currency.getCurrencyCode(),EURO_ISO4217_CODE, "Euro ISO 4217 currency code retrieval check (" +
       
    69                       currency.getCurrencyCode() + ").");
       
    70         /* Check for the correct currency symbol */
       
    71         harness.check(currency.getSymbol(), EURO_CURRENCY_SYMBOL, "Euro currency symbol retrieval check (" +
       
    72                       currency.getSymbol() + ").");
       
    73         /* Check for the correct fraction digits */
       
    74         harness.check(currency.getDefaultFractionDigits(), EURO_FRACTION_DIGITS,
       
    75                       "Euro currency fraction digits retrieval check (" + currency.getDefaultFractionDigits() + ").");
       
    76         /* Check for the correct currency code from toString()*/
       
    77         harness.check(currency.toString(),EURO_ISO4217_CODE, "Euro ISO 4217 currency code retrieval check (" +
       
    78                       currency.toString() + ").");
       
    79       }
       
    80     else
       
    81       {
       
    82           /* Check for the correct currency code */
       
    83           harness.check(currency.getCurrencyCode(),ISO4217_CODE, "ISO 4217 currency code retrieval check (" +
       
    84                         currency.getCurrencyCode() + ").");
       
    85           /* Check for the correct currency symbol */
       
    86           harness.check(currency.getSymbol(), CURRENCY_SYMBOL, "Currency symbol retrieval check (" +
       
    87                         currency.getSymbol() + ").");
       
    88           /* Check for the correct fraction digits */
       
    89           harness.check(currency.getDefaultFractionDigits(), FRACTION_DIGITS, "Currency fraction digits retrieval check (" +
       
    90                         currency.getDefaultFractionDigits() + ").");
       
    91           /* Check for the correct currency code from toString()*/
       
    92           harness.check(currency.toString(),ISO4217_CODE, "ISO 4217 currency code retrieval check ("
       
    93                         + currency.toString() + ").");
       
    94       }
       
    95   }
       
    96 
       
    97 }