test/jdk/java/text/Format/DateFormat/SimpleDateFormatPatternTest.java
author yzhou
Thu, 10 Oct 2019 14:43:41 +0800
changeset 58534 6c4f71874b36
permissions -rw-r--r--
8231213: Migrate SimpleDateFormatConstTest to JDK Repo Reviewed-by: naoto
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58534
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
     1
/*
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
     4
 *
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
     8
 *
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    13
 * accompanied this code).
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    14
 *
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    18
 *
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    21
 * questions.
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    22
 */
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    23
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    24
/**
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    25
 * @test
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    26
 * @bug 4326988 6990146 8231213
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    27
 * @summary test SimpleDateFormat, check its pattern in the constructor
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    28
 * @run testng/othervm SimpleDateFormatPatternTest
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    29
 */
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    30
import java.lang.IllegalArgumentException;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    31
import java.text.DateFormat;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    32
import java.text.DateFormatSymbols;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    33
import java.text.SimpleDateFormat;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    34
import java.util.Locale;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    35
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    36
import org.testng.annotations.DataProvider;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    37
import org.testng.annotations.Test;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    38
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    39
public class SimpleDateFormatPatternTest {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    40
    private static String[] validPat = {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    41
            "yyyy-MM-dd h.mm.ss.a z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    42
            "yyyy'M'd' ahh'mm'ss' z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    43
            "dd MMMM yyyy hh:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    44
            "d MMM yy HH:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    45
            "dd/MM/yyyy HH:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    46
            "d' / 'MMMM' / 'yyyy HH:mm:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    47
            "d.M.yyyy H:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    48
            "d' de 'MMMM' de 'yyyy H'h'm'min's's' z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    49
            "dd. MMMM yyyy HH:mm:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    50
            "d-M-yyyy H:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    51
            "EEEE''d MMMM G yyyy, H'  'm'  'ss' '",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    52
            "dd.MMM.yyyy HH:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    53
            "yy-MM-dd h:mm:ss.a",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    54
            "d' de 'MMMM' de 'yyyy hh:mm:ss a z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    55
            "EEEE d MMMM yyyy H' h 'mm' min 'ss' s 'z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    56
            "d MMMM yyyy H:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    57
            "d/MM/yyyy hh:mm:ss a",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    58
            "EEEE, d, MMMM yyyy HH:mm:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    59
            "EEEE, d. MMMM yyyy HH.mm.' h' z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    60
            "EEEE, d' / 'MMMM' / 'yyyy HH:mm:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    61
            "d/MM/yyyy HH:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    62
            "d MMMM yyyy H:mm:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    63
            "MMMM d, yyyy h:mm:ss a z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    64
            "yyyy. MMMM d. H:mm:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    65
            "d' de 'MMMM' de 'yyyy H:mm:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    66
            "EEEE, MMMM d, yyyy h:mm:ss a z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    67
            "d/M/yyyy H:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    68
            "d-MMM-yy HH:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    69
            "EEEE d' de 'MMMM' de 'yyyy hh:mm:ss a z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    70
            "yyyy'M'd' ahh'mm'ss'",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    71
            "yyyy'MM'dd' EEEE ahh'mm'ss'",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    72
            "EEEE, d MMMM yyyy HH:mm:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    73
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    74
            //6990146: 'Y' for year; 'X' for time zone; 'u' for day number of the week
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    75
            "d/M/YYYY H:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    76
            "d-MMM-YY HH:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    77
            "EEEE d' de 'MMMM' de 'YYYY hh:mm:ss a X",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    78
            "YYYY M d ahh:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    79
            "YYYY MM dd EEEE u ahh/mm/ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    80
            "EEEE, u, d MMMM YYYY HH:mm:ss X",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    81
            "YYYY M d Z ahh mm ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    82
            "YYYY-MM-dd EEEE u ahh-mm-ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    83
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    84
            //*added for sr-Latn*
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    85
            "EEEE, dd. MMMM y. HH.mm.ss zzzz",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    86
            "dd. MMMM y. HH.mm.ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    87
            "dd.MM.y. HH.mm.ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    88
            "d.M.yy. HH.mm"
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    89
    };
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    90
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    91
    private static String[] invalidPat = {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    92
            "yyyy'M'd' ahh:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    93
            "EEEe d MM MM yyyy HH' h 'mm zzzZ",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    94
            "d MMMM\\ yyyy, H'  'm' 'g",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    95
            "EEEE d' @# MMMMde 'yyys HHH'mm z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    96
            "yyyy'MMe 2 #dd' EEEEahh'mm'ss' z,z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    97
            "yyyy.M.d H;mm.ses",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    98
            "EEEe, d MMMM yyyy h:mm:ss a z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
    99
            "EEEE, MMMM d, 'y y y y h:mm:ss 'o''clock' a z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   100
            "dd MMMM yyyy 0HHcl:mm:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   101
            "d.M_M_y.yy1yy HextH:mm|45:",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   102
            "d,D MMMTTTTTTTTTKM yy|+yy HH:m m:ss z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   103
            "d-MDtM M-yy H:mm:ss",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   104
            "yyyy/M///m/nM/d Dd H:m$m:s s",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   105
            "EEEE, dd. MMMM yyyy HH:m'''m' Uhr 'z",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   106
            //6990146
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   107
            "EEEE d' de 'MMMM' de 'YYYY hh:mm:ss a x",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   108
            "EEEE, U, d MMMM YYYY HH:mm:ss Z"
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   109
    };
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   110
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   111
    private static Locale[] locales = DateFormat.getAvailableLocales();
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   112
    private static Object[][] dfAllLocalesObj = createAllLocales();
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   113
    private static Object[][] invalidPatObj = createPatternObj(invalidPat);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   114
    private static Object[][] validPatObj = createPatternObj(validPat);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   115
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   116
    private static Object[][] createAllLocales() {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   117
        Object[][] objArray = new Object[locales.length][];
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   118
        for (int i = 0; i < locales.length; i++) {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   119
            objArray[i] = new Object[1];
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   120
            objArray[i][0] = locales[i];
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   121
        }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   122
        return objArray;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   123
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   124
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   125
    private static Object[][] createPatternObj(String[] pattern){
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   126
        Object[][] objArray = new Object[locales.length * pattern.length][];
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   127
        int k = 0;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   128
        for (int i = 0; i < locales.length; i++) {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   129
            for (int j = 0; j < pattern.length; j++) {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   130
                objArray[k] = new Object[2];
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   131
                objArray[k][0] = pattern[j];
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   132
                objArray[k][1] = locales[i];
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   133
                k = k + 1;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   134
            }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   135
        }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   136
        return objArray;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   137
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   138
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   139
    @DataProvider(name = "dfAllLocalesObj")
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   140
    Object[][] dfAllLocalesObj() {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   141
        return dfAllLocalesObj;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   142
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   143
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   144
    @DataProvider(name = "invalidPatternObj")
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   145
    Object[][] invalidPatternObj() {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   146
        return invalidPatObj;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   147
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   148
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   149
    @DataProvider(name = "validPatternObj")
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   150
    Object[][] validPatternObj() {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   151
        return validPatObj;
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   152
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   153
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   154
    //check Constructors for invalid pattern
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   155
    @Test(dataProvider = "invalidPatternObj",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   156
            expectedExceptions = IllegalArgumentException.class)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   157
    public void testIllegalArgumentException1(String pattern, Locale loc)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   158
            throws IllegalArgumentException {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   159
        Locale.setDefault(loc);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   160
        new SimpleDateFormat(pattern);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   161
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   162
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   163
    @Test(dataProvider = "invalidPatternObj",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   164
            expectedExceptions = IllegalArgumentException.class)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   165
    public void testIllegalArgumentException2(String pattern, Locale loc)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   166
            throws IllegalArgumentException {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   167
        Locale.setDefault(loc);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   168
        new SimpleDateFormat(pattern, new DateFormatSymbols());
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   169
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   170
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   171
    @Test(dataProvider = "invalidPatternObj",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   172
            expectedExceptions = IllegalArgumentException.class)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   173
    public void testIllegalArgumentException3 (String pattern, Locale loc)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   174
            throws IllegalArgumentException {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   175
        Locale.setDefault(loc);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   176
        new SimpleDateFormat(pattern, Locale.getDefault());
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   177
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   178
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   179
    @Test(dataProvider = "invalidPatternObj",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   180
            expectedExceptions = IllegalArgumentException.class)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   181
    public void testIllegalArgumentException4(String pattern, Locale loc)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   182
            throws IllegalArgumentException {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   183
        Locale.setDefault(loc);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   184
        new SimpleDateFormat().applyPattern(pattern);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   185
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   186
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   187
    //check Constructors for null pattern
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   188
    @Test(dataProvider = "dfAllLocalesObj",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   189
            expectedExceptions = NullPointerException.class)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   190
    public void testNullPointerException1(Locale loc)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   191
            throws NullPointerException {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   192
        Locale.setDefault(loc);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   193
        new SimpleDateFormat(null);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   194
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   195
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   196
    @Test(dataProvider = "dfAllLocalesObj",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   197
            expectedExceptions = NullPointerException.class)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   198
    public void testNullPointerException2(Locale loc)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   199
            throws NullPointerException {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   200
        Locale.setDefault(loc);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   201
        new SimpleDateFormat(null, new DateFormatSymbols());
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   202
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   203
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   204
    @Test(dataProvider = "dfAllLocalesObj",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   205
            expectedExceptions = NullPointerException.class)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   206
    public void testNullPointerException3(Locale loc)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   207
            throws NullPointerException {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   208
        Locale.setDefault(loc);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   209
        new SimpleDateFormat(null, Locale.getDefault());
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   210
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   211
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   212
    @Test(dataProvider = "dfAllLocalesObj",
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   213
            expectedExceptions = NullPointerException.class)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   214
    public void testNullPointerException4(Locale loc)
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   215
            throws NullPointerException {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   216
        Locale.setDefault(loc);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   217
        new SimpleDateFormat().applyPattern(null);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   218
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   219
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   220
    @Test(dataProvider = "validPatternObj")
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   221
    //check Constructors for valid pattern
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   222
    public void testValidPattern(String pattern, Locale loc) {
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   223
        Locale.setDefault(loc);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   224
        new SimpleDateFormat(pattern);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   225
        new SimpleDateFormat(pattern, new DateFormatSymbols());
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   226
        new SimpleDateFormat(pattern, Locale.getDefault());
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   227
        new SimpleDateFormat().applyPattern(pattern);
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   228
    }
6c4f71874b36 8231213: Migrate SimpleDateFormatConstTest to JDK Repo
yzhou
parents:
diff changeset
   229
}