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