Path: blob/master/test/jdk/sun/util/resources/Calendar/Bug4518811.java
41155 views
/*1* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 451881126* @modules jdk.localedata27* @summary Verifies the minimum days of the week for euro locales28*/2930// this code is a bit brute-force, but I've been coding in nothing but Shell for the last year, so I'm rusty.3132import java.util.Locale;33import java.util.Calendar;3435public class Bug4518811 {36public static void main(String [] args) {3738int totalErrors=0;3940// go through the locales41totalErrors += getDays("ca", "ES");42totalErrors += getDays("cs", "CZ");43totalErrors += getDays("da", "DK");44totalErrors += getDays("de", "AT");45totalErrors += getDays("el", "GR");46totalErrors += getDays("en", "GB");47totalErrors += getDays("en", "IE");48totalErrors += getDays("es", "ES");49totalErrors += getDays("et", "EE");50totalErrors += getDays("fi", "FI");51totalErrors += getDays("fr", "BE");52totalErrors += getDays("fr", "FR");53totalErrors += getDays("is", "IS");54totalErrors += getDays("lt", "LT");55totalErrors += getDays("nl", "BE");56totalErrors += getDays("pl", "PL");57totalErrors += getDays("pt", "PT");5859if (totalErrors > 0)60throw new RuntimeException();61//System.err.println("Minimal Days in First Week: "+c.getMinimalDaysInFirstWeek());62}6364static int getDays(String lang, String loc){65int errors=0;66Locale newlocale = new Locale(lang, loc);6768Calendar newCal = Calendar.getInstance(newlocale);6970int minDays = newCal.getMinimalDaysInFirstWeek();71System.out.println("The Min Days in First Week for "+ lang +"_" + loc + " is " + minDays);7273if (minDays != 4){74System.out.println("Warning! Should be 4, not " + minDays +"!");75errors++;76}77return errors;78}79}808182