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