/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
*
* (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
* (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
*
* Portions copyright (c) 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* The original version of this source code and documentation
* is copyrighted and owned by Taligent, Inc., a wholly-owned
* subsidiary of IBM. These materials are provided under terms
* of a License Agreement between Taligent and Sun. This technology
* is protected by multiple US and International patents.
*
* This notice and attribution to Taligent may not be removed.
* Taligent is a registered trademark of Taligent, Inc.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies. Please refer to the file "copyright.html"
* for further important copyright and licensing information.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
/**
* LocaleTestFmwk is a base class for tests that can be run conveniently from
* the command line as well as under the Java test harness.
* <p>
* Sub-classes implement a set of methods named Test<something>. Each
* of these methods performs some test. Test methods should indicate
* errors by calling either err or errln. This will increment the
* errorCount field and may optionally print a message to the log.
* Debugging information may also be added to the log via the log
* and logln methods. These methods will add their arguments to the
* log only if the test is being run in verbose mode.
*/
public class LocaleTestFmwk {
//------------------------------------------------------------------------
// Everything below here is boilerplate code that makes it possible
// to add a new test by simply adding a function to an existing class
//------------------------------------------------------------------------
protected LocaleTestFmwk() {
// Create a hashtable containing all the test methods.
testMethods = new Hashtable();
}
}
}
{
indentLevel++;
// Set up the log and reference streams. We use PrintWriters in order to
// take advantage of character conversion. The JavaEsc converter will
// convert Unicode outside the ASCII range to Java's \\uxxxx notation.
// Parse the test arguments. They can be either the flag
// "-verbose" or names of test methods. Create a list of
// tests to be run.
verbose = true;
}
prompt = true;
nothrow = true;
exitcode = true;
} else {
if( m != null ) {
testsToRun.addElement( m );
}
else {
usage();
return;
}
}
}
// If no test method names were given explicitly, run them all.
while( methodNames.hasMoreElements() ) {
}
}
// Run the list of tests given in the test arguments
int oldCount = errorCount;
try {
}
catch( IllegalAccessException e ) {
}
catch( InvocationTargetException e ) {
errln("Uncaught exception thrown in test method "
+ testMethod.getName());
}
}
indentLevel--;
if (prompt) {
try {
}
catch (IOException e) {
}
}
if (nothrow) {
if (exitcode) {
}
if (errorCount > 0) {
}
}
}
/**
* Adds given string to the log if we are in verbose mode.
*/
if( verbose ) {
}
}
}
/**
* Report an error
*/
errorCount++;
if (!nothrow) {
throw new RuntimeException(message);
}
}
}
needLineFeed = true;
}
if (!needLineFeed) {
}
needLineFeed = false;
if (count != 0)
else
}
if (needLineFeed) {
needLineFeed = false;
}
}
/**
* Print a usage message for this test class.
*/
void usage() {
": [-verbose] [-nothrow] [-exitcode] [-prompt] [test names]");
while( methodNames.hasMoreElements() ) {
}
}
private boolean prompt = false;
private boolean nothrow = false;
private boolean exitcode = false;
protected boolean verbose = false;
private boolean needLineFeed = false;
}