test/jdk/java/util/TimeZone/Bug8066652Run.java
author naoto
Fri, 26 Jul 2019 08:56:28 -0700
changeset 57544 99d2dd7b84a8
parent 55680 cd48f8f260c8
permissions -rw-r--r--
8212970: TZ database in "vanguard" format support Reviewed-by: rriggs, joehw, erikj, scolebourne
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52423
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
     1
/*
55680
cd48f8f260c8 8227289: Enable assertions for some shell to java conversion tests after JDK-8218960
yzhou
parents: 52423
diff changeset
     2
 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
52423
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
     4
 *
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
     7
 * published by the Free Software Foundation.
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
     8
 *
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    13
 * accompanied this code).
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    14
 *
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    18
 *
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    21
 * questions.
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    22
 */
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    23
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    24
/*
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    25
 * @test
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    26
 * @bug 8066652
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    27
 * @requires os.family == "mac"
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    28
 * @summary tests thread safe native function localtime_r is accessed by multiple
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    29
 *          threads at same time and zone id should not be  "GMT+00:00"
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    30
 *          if default timezone is "GMT" and user specifies a fake timezone.
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    31
 * @library /test/lib
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    32
 * @build Bug8066652
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    33
 * @run main Bug8066652Run
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    34
 */
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    35
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    36
import java.util.Map;
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    37
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    38
import jdk.test.lib.JDKToolLauncher;
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    39
import jdk.test.lib.Utils;
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    40
import jdk.test.lib.process.ProcessTools;
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    41
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    42
public class Bug8066652Run {
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    43
    private static String cp = Utils.TEST_CLASSES;
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    44
    private static ProcessBuilder pb = new ProcessBuilder();
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    45
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    46
    public static void main(String[] args) throws Throwable {
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    47
        //set system TimeZone to GMT using environment variable TZ
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    48
        Map<String, String> env = pb.environment();
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    49
        env.put("TZ", "GMT");
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    50
        System.out.println("Current TimeZone:" + pb.environment().get("TZ"));
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    51
        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    52
        //Setting invalid TimeZone using VM option
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    53
        launcher.addToolArg("-Duser.timezone=Foo/Bar")
55680
cd48f8f260c8 8227289: Enable assertions for some shell to java conversion tests after JDK-8218960
yzhou
parents: 52423
diff changeset
    54
                .addToolArg("-ea")
cd48f8f260c8 8227289: Enable assertions for some shell to java conversion tests after JDK-8218960
yzhou
parents: 52423
diff changeset
    55
                .addToolArg("-esa")
52423
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    56
                .addToolArg("-cp")
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    57
                .addToolArg(cp)
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    58
                .addToolArg("Bug8066652");
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    59
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    60
        pb.command(launcher.getCommand());
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    61
        int exitCode = ProcessTools.executeCommand(pb)
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    62
                .getExitValue();
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    63
        if (exitCode != 0) {
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    64
            throw new RuntimeException("Unexpected exit code: " + exitCode);
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    65
        }
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    66
    }
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    67
}
00db205006c9 8210409: Refactor java.util.TimeZone:i18n shell tests to plain java tests
mli
parents:
diff changeset
    68