cryptix.util.test
Class BaseTest

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--cryptix.util.test.BaseTest
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
Test3LFSR, TestAll, TestBase64Stream, TestBlowfish, TestBR, TestCAST5, TestDES, TestDES_EDE3, TestElGamal, TestHAVAL, TestHMAC, TestIDEA, TestIJCE, TestInstall, TestLOKI91, TestMD2, TestMD4, TestMD5, TestRC2, TestRC4, TestRijndael, TestRIPEMD128, TestRIPEMD160, TestRSA, TestSAFER, TestScar, TestSHA0, TestSHA1, TestSPEED, TestSquare, TestUnixCrypt

public abstract class BaseTest
extends java.applet.Applet

This abstract class acts as a base for all 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:

Planned features include:

Copyright © 1997, 1998 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.5 $

Since:
Cryptix 2.2.2
Author:
David Hopwood
See Also:
Serialized Form

Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.io.PrintWriter out
          The PrintWriter to which delayed output is sent.
protected  java.io.PrintWriter status
          The PrintWriter to which immediate output is sent.
 
Fields inherited from class java.applet.Applet
accessibleContext
 
Fields inherited from class java.awt.Container
component, containerListener, layoutMgr, listeningBoundsChildren, listeningChildren, ncomponents
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
protected BaseTest()
          Constructor for use by subclasses.
 
Method Summary
protected  void commandline(java.lang.String[] args)
          Used to run a test from the command line.
protected  void commandline(java.lang.String[] args, int offset)
          Used to run a test from the command line, skipping the first offset arguments (which are assumed to have been processed by the subclass).
 java.lang.String describeOptions()
          Describes the command-line options of this class.
 java.lang.String describeUsage()
          Describes the command-line usage of this class.
protected abstract  void engineTest()
          This method should be overridden by test subclasses, to perform the actual testing.
protected  void error(java.lang.Exception e)
          Reports an error due to an unexpected exception.
protected  void error(java.lang.String msg)
          Reports an error, with the given message.
protected  void error(java.lang.Throwable e)
           
protected  void fail(java.lang.String msg)
          Reports a failure, with the given message.
 int getErrors()
          Returns the number of errors so far.
 int getExpectedPasses()
          Returns the number of expected passes, or 0 if this has not yet been set, or is unknown.
 int getFailures()
          Returns the number of failures so far.
 java.lang.String getName()
          Gets the name of this test (as shown to the user).
 int getPasses()
          Returns the number of passes so far.
 int getSkipped()
          Returns the number of skipped tests so far.
 void init()
          Used when the test is running as an Applet.
 boolean isGuiEnabled()
          Returns true iff a GUI interface is being used.
 boolean isOverallPass()
          Returns true iff all the tests have completed successfully.
 boolean isVerbose()
          Returns true iff output is to be printed even if all tests pass.
protected  void parseOption(java.lang.String option)
          Parses a command-line option.
 void parseOptions(java.lang.String[] args, int offset)
          Processes command-line arguments from args, starting at index offset.
protected  void pass(java.lang.String msg)
          Reports a pass, with the given message.
protected  void passIf(boolean pass, java.lang.String msg)
          Reports a pass if pass is true, or a failure if it is false.
protected  void report()
          Forces a report of the number of passes, failures, errors, and expected passes so far.
protected  void setExpectedPasses(int n)
          Sets the number of expected passes for this test class.
 void setGuiEnabled(boolean flag)
          Sets whether a GUI interface is used.
 void setName(java.lang.String n)
          Sets the name of this test (as shown to the user).
 void setOutput(java.io.PrintWriter pw)
          Sets the PrintWriter to which output is to be sent.
 void setVerbose(boolean flag)
          Sets whether output is to be printed even if all tests pass.
protected  void skip(java.lang.String msg)
          Reports a skipped test, with the given message.
 void test()
          Begins the test proper.
 void waitForExit()
          Blocks until it is time to exit.
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paint, paintComponents, paintHeavyweightComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

status

protected java.io.PrintWriter status
The PrintWriter to which immediate output is sent.

out

protected java.io.PrintWriter out
The PrintWriter to which delayed output is sent.
Constructor Detail

BaseTest

protected BaseTest()
Constructor for use by subclasses.
Method Detail

init

public void init()
Used when the test is running as an Applet.
Overrides:
init in class java.applet.Applet

setGuiEnabled

public void setGuiEnabled(boolean flag)
Sets whether a GUI interface is used.

isGuiEnabled

public boolean isGuiEnabled()
Returns true iff a GUI interface is being used.

waitForExit

public void waitForExit()
Blocks until it is time to exit.

commandline

protected void commandline(java.lang.String[] args)
Used to run a test from the command line. Each test class' main method should create an instance and call the commandline method on it, passing the array of command line arguments. For example, in class TestFoo:
    public static void main(String[] args) {
        new TestFoo().commandline(args);
    }
 

commandline

protected void commandline(java.lang.String[] args,
                           int offset)
Used to run a test from the command line, skipping the first offset arguments (which are assumed to have been processed by the subclass).

parseOption

protected void parseOption(java.lang.String option)
                    throws TestException
Parses a command-line option. If the option is not recognised, super.parseOption(option) should be called.

Case should generally not be significant in option names.


parseOptions

public void parseOptions(java.lang.String[] args,
                         int offset)
                  throws TestException
Processes command-line arguments from args, starting at index offset.

describeUsage

public java.lang.String describeUsage()
Describes the command-line usage of this class.

describeOptions

public java.lang.String describeOptions()
Describes the command-line options of this class.

setName

public void setName(java.lang.String n)
Sets the name of this test (as shown to the user). The default is the name of the class.
Overrides:
setName in class java.awt.Component

getName

public java.lang.String getName()
Gets the name of this test (as shown to the user).
Overrides:
getName in class java.awt.Component

setOutput

public void setOutput(java.io.PrintWriter pw)
Sets the PrintWriter to which output is to be sent. In most cases this does not need to be set by the test class; the commandline method will do that automatically.

setVerbose

public void setVerbose(boolean flag)
Sets whether output is to be printed even if all tests pass.

isVerbose

public boolean isVerbose()
Returns true iff output is to be printed even if all tests pass.

test

public void test()
          throws TestException
Begins the test proper. This method is called automatically by commandline, but it can also be called directly.

fail

protected void fail(java.lang.String msg)
Reports a failure, with the given message.

error

protected void error(java.lang.String msg)
Reports an error, with the given message.

skip

protected void skip(java.lang.String msg)
Reports a skipped test, with the given message.

error

protected void error(java.lang.Exception e)
Reports an error due to an unexpected exception.

error

protected void error(java.lang.Throwable e)

pass

protected void pass(java.lang.String msg)
Reports a pass, with the given message.

passIf

protected void passIf(boolean pass,
                      java.lang.String msg)
Reports a pass if pass is true, or a failure if it is false. In either case, the given message is used.

setExpectedPasses

protected void setExpectedPasses(int n)
Sets the number of expected passes for this test class. This can be called at any time by the engineTest method, but should normally be called at the start of that method.

report

protected void report()
Forces a report of the number of passes, failures, errors, and expected passes so far.

getFailures

public int getFailures()
Returns the number of failures so far.

getErrors

public int getErrors()
Returns the number of errors so far.

getPasses

public int getPasses()
Returns the number of passes so far.

getSkipped

public int getSkipped()
Returns the number of skipped tests so far.

getExpectedPasses

public int getExpectedPasses()
Returns the number of expected passes, or 0 if this has not yet been set, or is unknown.

isOverallPass

public boolean isOverallPass()
Returns true iff all the tests have completed successfully.

engineTest

protected abstract void engineTest()
                            throws java.lang.Exception
This method should be overridden by test subclasses, to perform the actual testing.