All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ccl.util.Test

java.lang.Object
   |
   +----ccl.util.Test

public abstract class Test
extends Object
implements Runnable
Framework and base class for all tests. Inherit _doit in your test and use bugIf( boolean ) statements for your actual test comparisons.

Features:
- support for stdout and stderr redirecting

Stdout redirection

Sometimes you test code which prints something to the console while for the test you don't want to confuse the user, since the test wants to print status information as well.

Console output will be redirected into two byte streams when desired (use 'Test.redirectStandardStreams( true )'). The test output will still be printed to the normal standard output streams.

When redirection takes place, the test can get a string with the last output to these streams and use this information for testing purposes as well. This buffer can also be cleaned anytime on purpose.

For an example how to write your own tests take a look at the ccl.util.test.UtilTest class

Version:
1999-09-03 $Id: Test.java 1.16 2000/05/14 14:30:37 clemens Exp clemens $
Author:
Chr. Clemens Lee < clemens@kclee.com >
See Also:
UtilTest

Variable Index

 o _bLastSubtest
 o _bLastSuccessfull
 o _bRedirectStandardStreams
 o _bShowLiveSignals
 o _bTest
 o _bTiming
 o _lBugs
 o _lGLobalTests
 o _lLastBugs
 o _lLastLocalTests
 o _lLocalTests
 o _newErr
 o _newOut
 o _oldErr
 o _oldOut
 o _oValue
 o _sLastSubTest
 o _subtests
 o _vCalendars

Constructor Index

 o Test()
 o Test(Test)

Method Index

 o _check(boolean)
 o _doIt()
Inherit this method to do your test inside of it.
 o _ensureRedirectedStreams()
If standard streams are redirected, ensure that redirected streams are in place.
 o _ensureStandardStreams()
If standard streams are redirected, normal streams are used now.
 o _enterSubTest(String)
 o _exitSubTest()
 o _getValue()
 o _increment()
 o _printMessage(String)
 o _printStackTrace()
 o _processFailure()
 o _setOutNew()
When we need to switch between two std output streams, this method helps doing so.
 o _setOutOld()
When we need to switch between two std output streams, this method helps doing so.
 o _setTests(Test)
Deprecated.
 o _showLiveSignal()
 o _showLiveSignals(boolean)
Deprecated.
 o bugIf(boolean)
 o bugIf(boolean, String)
 o bugIf(boolean, String, Throwable)
 o getBugs()
 o getComment()
Return a one line comment for this test.
 o getGlobalTests()
 o getLocalTests()
 o getTestDirectory()
 o getValue()
 o initialize(String[])
Process the arguments from the main class here.
 o isTest()
 o isTiming()
 o isVerbose()
 o main(String[])
example code for a real test main method

 Test pTest = (Test)(new SomeTest());
 pTest.initialize( argv );
 pTest.setVerbose( true );
 pTest.run();
 printResult( pTest );

 System.exit( 0 );
 
 o printResult(Test)
 o redirectStandardStreams(boolean)
Redirect stdout and stderr into private streams so the do not confuse the user with test output.
 o run()
 o setBug()
 o setTests(Test)
 o setTiming(boolean)
You want timing information? Set this to true!
 o setValue(Object)
 o setVerbose(boolean)
 o toString()

Variables

 o _lGLobalTests
 private long _lGLobalTests
 o _lLocalTests
 private long _lLocalTests
 o _lBugs
 private long _lBugs
 o _bTiming
 private boolean _bTiming
 o _bShowLiveSignals
 private boolean _bShowLiveSignals
 o _bLastSuccessfull
 private boolean _bLastSuccessfull
 o _bLastSubtest
 private boolean _bLastSubtest
 o _subtests
 private int _subtests
 o _lLastBugs
 private long _lLastBugs
 o _lLastLocalTests
 private long _lLastLocalTests
 o _sLastSubTest
 private String _sLastSubTest
 o _vCalendars
 private Vector _vCalendars
 o _oValue
 private static Object _oValue
 o _bTest
 private static boolean _bTest
 o _bRedirectStandardStreams
 private static boolean _bRedirectStandardStreams
 o _oldOut
 private static PrintStream _oldOut
 o _newOut
 private static PrintStream _newOut
 o _oldErr
 private static PrintStream _oldErr
 o _newErr
 private static PrintStream _newErr

Constructors

 o Test
 public Test()
 o Test
 public Test(Test tstParent_)

Methods

 o _showLiveSignal
 private void _showLiveSignal()
 o _getValue
 protected Object _getValue()
 o _enterSubTest
 protected void _enterSubTest(String sName_)
Parameters:
sName_ - e.g. "jacob".
 o _exitSubTest
 protected void _exitSubTest()
 o _setTests
 protected void _setTests(Test pTest_)
Note: _setTests() is deprecated. Use setTests(..) instead.

 o _increment
 protected void _increment()
 o _showLiveSignals
 protected void _showLiveSignals(boolean bShowLiveSignals_)
Note: _showLiveSignals() is deprecated. Use setVerbose(..) instead.

 o getLocalTests
 public long getLocalTests()
 o getGlobalTests
 public long getGlobalTests()
 o getBugs
 public long getBugs()
 o setBug
 public void setBug()
 o setValue
 public void setValue(Object oValue_)
 o isVerbose
 public boolean isVerbose()
 o setVerbose
 public void setVerbose(boolean bVerbose_)
 o setTiming
 public void setTiming(boolean bTiming_)
You want timing information? Set this to true!

 o isTiming
 public boolean isTiming()
 o printResult
 public static void printResult(Test pTest_)
 o _processFailure
 private void _processFailure()
 o _check
 private boolean _check(boolean bCondition_)
 o _printStackTrace
 private void _printStackTrace()
 o _printMessage
 private void _printMessage(String sDescription)
 o bugIf
 public boolean bugIf(boolean bCondition)
 o bugIf
 public boolean bugIf(boolean bCondition,
                      String sDescription)
 o bugIf
 public boolean bugIf(boolean bCondition,
                      String sDescription,
                      Throwable pThrowable)
 o _doIt
 protected abstract void _doIt() throws Exception
Inherit this method to do your test inside of it.

Throws: Exception
Whatever can go wrong.
 o run
 public void run()
 o main
 public static void main(String argv[])
example code for a real test main method

 Test pTest = (Test)(new SomeTest());
 pTest.initialize( argv );
 pTest.setVerbose( true );
 pTest.run();
 printResult( pTest );
 System.exit( 0 );
 

 o initialize
 public void initialize(String asArg_[])
Process the arguments from the main class here. This way you can pass arguments to this test also from the test center, which does not use the main method to invoke a test.

 o isTest
 public static boolean isTest()
 o getValue
 public static Object getValue()
 o getTestDirectory
 public String getTestDirectory()
 o toString
 public String toString()
Overrides:
toString in class Object
 o setTests
 public void setTests(Test test_)
 o getComment
 public String getComment()
Return a one line comment for this test. Should be overwritten be test classes inheriting from this class.

 o _setOutNew
 private static void _setOutNew()
When we need to switch between two std output streams, this method helps doing so. E.g. we redirect std out but want to print a "test SUCCESS" message, then we use _setOutOld, print, _setOutNew methods.

 o _setOutOld
 private static void _setOutOld()
When we need to switch between two std output streams, this method helps doing so. E.g. we redirect std out but want to print a "test SUCCESS" message, then we use _setOutOld, print, _setOutNew methods.

 o _ensureStandardStreams
 private static void _ensureStandardStreams()
If standard streams are redirected, normal streams are used now.

 o _ensureRedirectedStreams
 private static void _ensureRedirectedStreams()
If standard streams are redirected, ensure that redirected streams are in place.

 o redirectStandardStreams
 public static void redirectStandardStreams(boolean bRedirect_)
Redirect stdout and stderr into private streams so the do not confuse the user with test output. Look at the class documentation at the top for detailed stdout redirection documentation.


All Packages  Class Hierarchy  This Package  Previous  Next  Index