jdk/test/java/text/testlib/IntlTest.java
author amlu
Fri, 18 Nov 2016 14:39:03 +0800
changeset 42166 5582c83b1156
parent 42159 9ab10842acf7
permissions -rw-r--r--
8169836: ProblemList update for java/lang/management/MemoryMXBean/PendingAllGC.sh Reviewed-by: mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     1
/*
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     2
 * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     4
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     8
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    13
 * accompanied this code).
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    14
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    18
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    21
 * questions.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    22
 */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    23
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    24
import java.io.IOException;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    25
import java.io.PrintWriter;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    26
import java.lang.reflect.InvocationTargetException;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    27
import java.lang.reflect.Method;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    28
import java.lang.reflect.Modifier;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    29
import java.util.ArrayList;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    30
import java.util.Map;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    31
import java.util.LinkedHashMap;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    32
import java.util.List;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    33
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    34
/**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    35
 * IntlTest is a base class for tests that can be run conveniently from
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    36
 * the command line as well as under the Java test harness.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    37
 * <p>
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    38
 * Sub-classes implement a set of public void methods named "Test*" or
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    39
 * "test*" with no arguments. Each of these methods performs some
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    40
 * test. Test methods should indicate errors by calling either err() or
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    41
 * errln().  This will increment the errorCount field and may optionally
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    42
 * print a message to the log.  Debugging information may also be added to
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    43
 * the log via the log and logln methods.  These methods will add their
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    44
 * arguments to the log only if the test is being run in verbose mode.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    45
 */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    46
public abstract class IntlTest {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    47
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    48
    //------------------------------------------------------------------------
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    49
    // Everything below here is boilerplate code that makes it possible
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    50
    // to add a new test by simply adding a method to an existing class.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    51
    //------------------------------------------------------------------------
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    52
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    53
    protected IntlTest() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    54
        // Populate testMethods with all the test methods.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    55
        Method[] methods = getClass().getDeclaredMethods();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    56
        for (Method method : methods) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    57
            if (Modifier.isPublic(method.getModifiers())
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    58
                && method.getReturnType() == void.class
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    59
                && method.getParameterCount() == 0) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    60
                String name = method.getName();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    61
                if (name.length() > 4) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    62
                    if (name.startsWith("Test") || name.startsWith("test")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    63
                        testMethods.put(name, method);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    64
                    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    65
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    66
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    67
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    68
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    69
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    70
    protected void run(String[] args) throws Exception
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    71
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    72
        // Set up the log and reference streams.  We use PrintWriters in order to
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    73
        // take advantage of character conversion.  The JavaEsc converter will
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    74
        // convert Unicode outside the ASCII range to Java's \\uxxxx notation.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    75
        log = new PrintWriter(System.out, true);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    76
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    77
        // Parse the test arguments.  They can be either the flag
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    78
        // "-verbose" or names of test methods. Create a list of
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    79
        // tests to be run.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    80
        List<Method> testsToRun = new ArrayList<>(args.length);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    81
        for (String arg : args) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    82
            switch (arg) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    83
            case "-verbose":
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    84
                verbose = true;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    85
                break;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    86
            case "-prompt":
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    87
                prompt = true;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    88
                break;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    89
            case "-nothrow":
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    90
                nothrow = true;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    91
                break;
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    92
            case "-exitcode":
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    93
                exitCode = true;
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    94
                break;
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    95
            default:
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    96
                Method m = testMethods.get(arg);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    97
                if (m == null) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    98
                    System.out.println("Method " + arg + ": not found");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    99
                    usage();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   100
                    return;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   101
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   102
                testsToRun.add(m);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   103
                break;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   104
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   105
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   106
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   107
        // If no test method names were given explicitly, run them all.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   108
        if (testsToRun.isEmpty()) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   109
            testsToRun.addAll(testMethods.values());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   110
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   111
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   112
        System.out.println(getClass().getName() + " {");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   113
        indentLevel++;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   114
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   115
        // Run the list of tests given in the test arguments
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   116
        for (Method testMethod : testsToRun) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   117
            int oldCount = errorCount;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   118
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   119
            writeTestName(testMethod.getName());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   120
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   121
            try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   122
                testMethod.invoke(this, new Object[0]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   123
            } catch (IllegalAccessException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   124
                errln("Can't acces test method " + testMethod.getName());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   125
            } catch (InvocationTargetException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   126
                errln("Uncaught exception thrown in test method "
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   127
                        + testMethod.getName());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   128
                e.getTargetException().printStackTrace(this.log);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   129
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   130
            writeTestResult(errorCount - oldCount);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   131
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   132
        indentLevel--;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   133
        writeTestResult(errorCount);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   134
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   135
        if (prompt) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   136
            System.out.println("Hit RETURN to exit...");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   137
            try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   138
                System.in.read();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   139
            } catch (IOException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   140
                System.out.println("Exception: " + e.toString() + e.getMessage());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   141
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   142
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   143
        if (nothrow) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   144
            if (exitCode) {
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   145
                System.exit(errorCount);
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   146
            }
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   147
            if (errorCount > 0) {
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   148
                throw new IllegalArgumentException("encountered " + errorCount + " errors");
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   149
            }
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   150
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   151
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   152
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   153
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   154
     * Adds the given message to the log if we are in verbose mode.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   155
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   156
    protected void log(String message) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   157
        logImpl(message, false);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   158
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   159
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   160
    protected void logln(String message) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   161
        logImpl(message, true);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   162
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   163
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   164
    protected void logln() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   165
        logImpl(null, true);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   166
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   167
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   168
    private void logImpl(String message, boolean newline) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   169
        if (verbose) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   170
            if (message != null) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   171
                indent(indentLevel + 1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   172
                log.print(message);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   173
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   174
            if (newline) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   175
                log.println();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   176
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   177
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   178
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   179
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   180
    protected void err(String message) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   181
        errImpl(message, false);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   182
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   183
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   184
    protected void errln(String message) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   185
        errImpl(message, true);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   186
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   187
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   188
    private void errImpl(String message, boolean newline) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   189
        errorCount++;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   190
        indent(indentLevel + 1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   191
        log.print(message);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   192
        if (newline) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   193
            log.println();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   194
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   195
        log.flush();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   196
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   197
        if (!nothrow) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   198
            throw new RuntimeException(message);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   199
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   200
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   201
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   202
    protected int getErrorCount() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   203
        return errorCount;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   204
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   205
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   206
    protected void writeTestName(String testName) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   207
        indent(indentLevel);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   208
        log.print(testName);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   209
        log.flush();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   210
        needLineFeed = true;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   211
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   212
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   213
    protected void writeTestResult(int count) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   214
        if (!needLineFeed) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   215
            indent(indentLevel);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   216
            log.print("}");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   217
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   218
        needLineFeed = false;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   219
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   220
        if (count != 0) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   221
            log.println(" FAILED");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   222
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   223
            log.println(" Passed");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   224
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   225
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   226
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   227
    /*
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   228
     * Returns a spece-delimited hex String.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   229
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   230
    protected static String toHexString(String s) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   231
        StringBuilder sb = new StringBuilder(" ");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   232
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   233
        for (int i = 0; i < s.length(); i++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   234
            sb.append(Integer.toHexString(s.charAt(i)));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   235
            sb.append(' ');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   236
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   237
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   238
        return sb.toString();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   239
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   240
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   241
    private void indent(int distance) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   242
        if (needLineFeed) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   243
            log.println(" {");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   244
            needLineFeed = false;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   245
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   246
        log.print(SPACES.substring(0, distance * 2));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   247
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   248
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   249
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   250
     * Print a usage message for this test class.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   251
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   252
    void usage() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   253
        System.out.println(getClass().getName() +
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   254
                            ": [-verbose] [-nothrow] [-exitcode] [-prompt] [test names]");
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   255
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   256
        System.out.println("  Available test names:");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   257
        for (String methodName : testMethods.keySet()) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   258
            System.out.println("\t" + methodName);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   259
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   260
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   261
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   262
    private boolean     prompt;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   263
    private boolean     nothrow;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   264
    protected boolean   verbose;
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   265
    private boolean     exitCode;
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   266
    private PrintWriter log;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   267
    private int         indentLevel;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   268
    private boolean     needLineFeed;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   269
    private int         errorCount;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   270
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   271
    private final Map<String, Method> testMethods = new LinkedHashMap<>();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   272
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   273
    private static final String SPACES = "                                          ";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   274
}