jdk/test/java/util/Locale/LocaleTestFmwk.java
author serb
Tue, 12 Nov 2013 20:24:25 +0400
changeset 21596 0e3a39f29dbc
parent 6501 684810d882b3
child 23010 6dadb192ad81
permissions -rw-r--r--
8027696: Incorrect copyright header in the tests Reviewed-by: alanb, malenkov, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
21596
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 6501
diff changeset
     7
 * published by the Free Software Foundation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
    23
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * Portions copyright (c) 2007 Sun Microsystems, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * The original version of this source code and documentation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * is copyrighted and owned by Taligent, Inc., a wholly-owned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * subsidiary of IBM. These materials are provided under terms
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * of a License Agreement between Taligent and Sun. This technology
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * is protected by multiple US and International patents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * This notice and attribution to Taligent may not be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Taligent is a registered trademark of Taligent, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Permission to use, copy, modify, and distribute this software
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * and its documentation for NON-COMMERCIAL purposes and without
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * fee is hereby granted provided that this copyright notice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * appears in all copies. Please refer to the file "copyright.html"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * for further important copyright and licensing information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import java.lang.reflect.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import java.text.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * LocaleTestFmwk is a base class for tests that can be run conveniently from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * the command line as well as under the Java test harness.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * Sub-classes implement a set of methods named Test<something>. Each
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * of these methods performs some test. Test methods should indicate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * errors by calling either err or errln.  This will increment the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * errorCount field and may optionally print a message to the log.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * Debugging information may also be added to the log via the log
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * and logln methods.  These methods will add their arguments to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * log only if the test is being run in verbose mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
public class LocaleTestFmwk {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    // Everything below here is boilerplate code that makes it possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    // to add a new test by simply adding a function to an existing class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    protected LocaleTestFmwk() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        // Create a hashtable containing all the test methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        testMethods = new Hashtable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        Method[] methods = getClass().getDeclaredMethods();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        for( int i=0; i<methods.length; i++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            if( methods[i].getName().startsWith("Test")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                    || methods[i].getName().startsWith("test")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                testMethods.put( methods[i].getName(), methods[i] );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    protected void run(String[] args) throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        System.out.println(getClass().getName() + " {");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        indentLevel++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        // Set up the log and reference streams.  We use PrintWriters in order to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        // take advantage of character conversion.  The JavaEsc converter will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        // convert Unicode outside the ASCII range to Java's \\uxxxx notation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        log = new PrintWriter(System.out,true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        // Parse the test arguments.  They can be either the flag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        // "-verbose" or names of test methods. Create a list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        // tests to be run.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        Vector testsToRun = new Vector( args.length );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        for( int i=0; i<args.length; i++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            if( args[i].equals("-verbose") ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                verbose = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            else if( args[i].equals("-prompt") ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                prompt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            } else if (args[i].equals("-nothrow")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                nothrow = true;
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   116
            } else if (args[i].equals("-exitcode")) {
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   117
                exitcode = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                Object m = testMethods.get( args[i] );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                if( m != null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                    testsToRun.addElement( m );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                    usage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        // If no test method names were given explicitly, run them all.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        if( testsToRun.size() == 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            Enumeration methodNames = testMethods.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            while( methodNames.hasMoreElements() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                testsToRun.addElement( methodNames.nextElement() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        // Run the list of tests given in the test arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        for( int i=0; i<testsToRun.size(); i++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            int oldCount = errorCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            Method testMethod = (Method)testsToRun.elementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            writeTestName(testMethod.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                testMethod.invoke(this, new Object[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            catch( IllegalAccessException e ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                errln("Can't acces test method " + testMethod.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            catch( InvocationTargetException e ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                errln("Uncaught exception thrown in test method "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                               + testMethod.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                e.getTargetException().printStackTrace(this.log);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            writeTestResult(errorCount - oldCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        indentLevel--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        writeTestResult(errorCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        if (prompt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            System.out.println("Hit RETURN to exit...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                System.in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                System.out.println("Exception: " + e.toString() + e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (nothrow) {
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   171
            if (exitcode) {
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   172
                System.exit(errorCount);
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   173
            }
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   174
            if (errorCount > 0) {
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   175
                throw new IllegalArgumentException("encountered " + errorCount + " errors");
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   176
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Adds given string to the log if we are in verbose mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    protected void log( String message ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if( verbose ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            indent(indentLevel + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            log.print( message );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    protected void logln( String message ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        log(message + System.getProperty("line.separator"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * Report an error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    protected void err( String message ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        errorCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        indent(indentLevel + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        log.print( message );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        log.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        if (!nothrow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            throw new RuntimeException(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    protected void errln( String message ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        err(message + System.getProperty("line.separator"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    protected void writeTestName(String testName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        indent(indentLevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        log.print(testName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        log.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        needLineFeed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    protected void writeTestResult(int count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if (!needLineFeed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            indent(indentLevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            log.print("}");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        needLineFeed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        if (count != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            log.println(" FAILED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            log.println(" Passed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    private final void indent(int distance) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (needLineFeed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            log.println(" {");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            needLineFeed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        log.print(spaces.substring(0, distance * 2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * Print a usage message for this test class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    void usage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        System.out.println(getClass().getName() +
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   246
                            ": [-verbose] [-nothrow] [-exitcode] [-prompt] [test names]");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        System.out.println("test names:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        Enumeration methodNames = testMethods.keys();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        while( methodNames.hasMoreElements() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            System.out.println("\t" + methodNames.nextElement() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    private boolean     prompt = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    private boolean     nothrow = false;
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 5506
diff changeset
   257
    private boolean     exitcode = false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    protected boolean   verbose = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    private PrintWriter log;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    private int         indentLevel = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    private boolean     needLineFeed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    private int         errorCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    private Hashtable testMethods;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    private final String spaces = "                                          ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
}