⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basetest.java

📁 jpeg2000编解码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// $Id: BaseTest.java,v 1.1.1.1 2002/08/27 12:32:16 grosbois Exp $//// $Log: BaseTest.java,v $// Revision 1.1.1.1  2002/08/27 12:32:16  grosbois// Add cryptix 3.2//// Revision 1.5  1999/07/26 16:12:48  iang// Now catches Throwable, as unknown class errors were sneaking through//// Revision 1.4  1999/07/25 22:56:26  iang// added Throwable, something's slipping through....//// Revision 1.3  1998/02/22 04:18:30  hopwood// + Committed changes below.//// Revision 1.2.1  1998/02/14  hopwood// + Added support for running as an applet, and as a standalone GUI program//   (needs some work still).// + Output defaults to System.out.// + Exit with code TestException.COMPLETE_SUCCESS if no exception is thrown.// + Case is now not significant for the -verbose option.//// Revision 1.2  1998/02/01 05:11:49  hopwood// + Committed changes below.//// Revision 1.1.1  1998/02/01  hopwood// + Removed unnecessary line feeds in output.// + Added isVerbose method.//// Revision 1.1  1998/01/28 05:44:02  hopwood// + Major update of test classes.//// Revision 0.1.8.2  1998/01/28  hopwood// + Added ability to skip tests.//// Revision 0.1.8.1  1998/01/13  hopwood// + Output now goes to a StringWriter initially, and is only printed when//   one or more tests fail. A -verbose option can be used to obtain the//   previous behaviour.// + Distinguish between failures (incorrect output) and errors (problems with//   the testing, or unexpected exceptions).// + Changed expectedPasses back to 0, since the expectedPasses == passes == 0//   case now causes an error, which has the same effect.// + Exceptions that are uncaught by the test class should cause an error.// + Added more convenience methods.// + Encapsulated variables properly.// + Removed debugging cycle for the time being.// + Documented methods and variables.// + Moved to cryptix.util.test package.//// Revision 0.1.8  1998/01/13 13:51:05  iang// + Made expectedPasses==1 so that pre-initialisation exceptions are caught//   and given exit(1).  Problem arose with TestRSA doing preparation.// + Also commented out the noisy bits of the not-yet-written//   debug-ON cycle.  Should really be protected with a property (?) but the//   'finally' part made that non-trivial as that did the exceptions.//// Revision 0.1.7  1998/01/12 04:10:39  hopwood// + Made engineTest() protected.// + Cosmetics.//// Revision 0.1.6.1  1998/01/12  hopwood// + Made all methods protected. The reflection hack added in 1.5.1 is no//   longer needed.//// Revision 0.1.6  1997/12/22 15:07:47  raif// *** empty log message ***//// Revision 0.1.5.1  1997/12/23  raif// + Use reflection API to invoke engineTest. Doing so//   eliminates the need to modify existing code.// + Other changes to allow use by Maker.//// Revision 0.1.5  1997/12/21 19:09:05  iang// + Commented out the changes to passes variables, exit codes always fail=1.//// Revision 0.1.4  1997/12/15 02:40:54  hopwood// + Committed changes below.//// Revision 0.1.3.1  1997/12/15  hopwood// + Use IanG's conventions for return codes.//// Revision 0.1.3  1997/11/29 17:47:08  hopwood// + Minor changes to test API.// + Added better support for BaseTest subclasses in TestAll (doesn't work//   yet).//// Revision 0.1.2  1997/11/29 05:12:22  hopwood// + Changes to use new test API (BaseTest).//// Revision 0.1.1.1.1.2  1997/11/23  hopwood// + Fleshed out the API a little more, added 'expectedPasses'.//// Revision 0.1.1.1.1.1  1997/11/21  hopwood// + Added the beginnings of a test API (fail, pass, done, engineTest etc.)//   At the moment these methods are all package-private, in case some tests//   are insecure.//// Revision 0.1.1.1.1  1997/11/03 22:36:55  hopwood// + Imported to CVS (tagged as 'start').//// Revision 0.1.0.0  1997/09/14  David Hopwood// + Original version.//// $Endlog$/* * Copyright (c) 1997, 1998 Systemics Ltd * on behalf of the Cryptix Development Team.  All rights reserved. */package cryptix.util.test;import java.io.PrintWriter;import java.io.StringWriter;import java.applet.Applet;/** * This abstract class acts as a base for <em>all</em> Cryptix test classes. * Its purpose is to provide a framework that will allow us to easily add new * testing features. Features that have already been added include: * <ul> *   <li> only printing complete output when one or more tests fail. * </ul> * <p> * Planned features include: * <ul> *   <li> testing as an applet, *   <li> testing as a standalone GUI program (with the -gui option), *   <li> repeating tests that have failed at a higher debugging level. * </ul> * <p> * <b>Copyright</b> &copy; 1997, 1998 * <a href="http://www.systemics.com/">Systemics Ltd</a> on behalf of the * <a href="http://www.systemics.com/docs/cryptix/">Cryptix Development Team</a>. * <br>All rights reserved. * <p> * <b>$Revision: 1.1.1.1 $</b> * @author  David Hopwood * @since   Cryptix 2.2.2 */public abstract class BaseTestextends Applet{// Constants and fields//...........................................................................    private static final String SEPARATOR =        "\n===========================================================================";    /** The PrintWriter to which output is sent by default. */    private static PrintWriter defaultOutput = new PrintWriter(System.out, true);    /** The PrintWriter to which immediate output is sent. */    protected PrintWriter status;    /** The PrintWriter to which delayed output is sent. */    protected PrintWriter out;    /** The name of this test. */    private String name;    /** A StringWriter that collects delayed output. */    private StringWriter sw;    /** The number of failures so far. */    private int failures;    /** The number of errors so far. */    private int errors;    /** The number of passes so far. */    private int passes;    /** The number of skipped tests so far. */    private int skipped;    /** The number of expected passes. */    private int expectedPasses;    /** true if there is an overall pass. */    private boolean overallPass;    /** true if output is to be printed even if all tests pass. */    private boolean verbose;    /** true if the program was run from the command line. */    private boolean commandLine;// Constructor//...........................................................................    /** Constructor for use by subclasses. */    protected BaseTest() {        name = this.getClass().getName();        status = defaultOutput;    }// GUI and Applet support//...........................................................................    /**     * The GUI implementation (in a separate class to avoid creating unwanted     * dependencies in this one).     */    private TestGUI gui;    /** Used when the test is running as an Applet. */    public synchronized void init() {        initGui();        try { test(); }        catch (TestException e) { e.printStackTrace(status); }    }    /** Initialises the GUI interface. */    private void initGui() {        gui = new TestGUI(this);        add(gui);        setOutput(gui.getOutput());    }    /** Sets whether a GUI interface is used. */    public synchronized void setGuiEnabled(boolean flag) {        if (flag && gui == null) {            initGui();            if (commandLine) gui.useAppFrame(true);        } else if (!flag && gui != null) {            if (commandLine) gui.useAppFrame(false);            setOutput(defaultOutput);            gui = null;        }    }    /** Returns true iff a GUI interface is being used. */    public boolean isGuiEnabled() {        return gui != null;    }    /** Blocks until it is time to exit. */    public synchronized void waitForExit() {        if (gui != null) gui.waitForExit();    }// Command-line parsing//...........................................................................    /**     * Used to run a test from the command line. Each test class' main method     * should create an instance and call the <code>commandline</code>     * method on it, passing the array of command line arguments. For example,     * in class TestFoo:     * <pre>     *    public static void main(String[] args) {     *        new TestFoo().commandline(args);     *    }     * </pre>     */    protected void commandline(String[] args) {        commandline(args, 0);    }    /**     * Used to run a test from the command line, skipping the first <i>offset</i>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -