jdk/test/sun/util/resources/Calendar/Bug4518811.java
author weijun
Thu, 08 Sep 2011 09:04:28 +0800
changeset 10435 e9df9d264894
parent 5506 202f599c92aa
child 40791 a080a12eaa93
permissions -rw-r--r--
7087428: move client tests out of jdk_misc Reviewed-by: alanb, ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *@test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 *@bug 4518811
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *@summary Verifies the minimum days of the week for euro locales
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
// this code is a bit brute-force, but I've been coding in nothing but Shell for the last year, so I'm rusty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Calendar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
public class Bug4518811 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  public static void main(String [] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
      int totalErrors=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
      // go through the locales
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
      totalErrors += getDays("ca", "ES");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
      totalErrors += getDays("cs", "CZ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
      totalErrors += getDays("da", "DK");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
      totalErrors += getDays("de", "AT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
      totalErrors += getDays("el", "GR");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
      totalErrors += getDays("en", "GB");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
      totalErrors += getDays("en", "IE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
      totalErrors += getDays("es", "ES");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
      totalErrors += getDays("et", "EE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
      totalErrors += getDays("fi", "FI");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
      totalErrors += getDays("fr", "BE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
      totalErrors += getDays("fr", "FR");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
      totalErrors += getDays("is", "IS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
      totalErrors += getDays("lt", "LT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
      totalErrors += getDays("nl", "BE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
      totalErrors += getDays("pl", "PL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
      totalErrors += getDays("pt", "PT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
      if (totalErrors > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
          throw new RuntimeException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
      //System.err.println("Minimal Days in First Week: "+c.getMinimalDaysInFirstWeek());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    static int getDays(String lang, String loc){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        int errors=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        Locale newlocale = new Locale(lang, loc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        Calendar newCal = Calendar.getInstance(newlocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        int minDays = newCal.getMinimalDaysInFirstWeek();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        if (minDays != 4){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            System.out.println("Warning! Should be 4, not " + minDays +"!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            errors++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        return errors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
}