All Packages This Package Class Hierarchy Class Search Index
Class grendel.SelfTest
java.lang.Object | +----selftest.SelfTestRoot | +----grendel.SelfTest
This is the base grendel SelfTest. Running this classes main() will execute the main() of all the SelfTest classes within the Grendel project.
This class also contains useful stuff for all of the Grendel SelfTest classes to use. It is expected that all of those classes will inherit from this one.
public class SelfTest extends selftest.SelfTestRoot { // Fields 6 private static StupidAuthenticator authenticator; static byte[] copybuf; private static boolean firsttime; protected static File playdir; protected static Properties props; protected static Session session; // Constructors 1 public SelfTest(); // Methods 11 public void cleanDirectory(File); public void cleanPlayDirectory(); public void endTests(); public String getStackTrace(Throwable); public void installFile(String, String); public static void main(String[]); public void makePlayDir(); public String prettyTime(long); public void setUserAndPassword(String, String); public void startTests(String[]); public void writeKnownBug(Object, String, int, String); }
Fields
props
protected static Properties props
The Properties instance that all the javamail stuff will use. We try not to use calypso.util.Preferences during SelfTest, because there's no real way to control the values to be found there. Typically, your SelfTest code will stuff values into this Properties database so that the Store you're using will pull those values out.
authenticator
private static StupidAuthenticator authenticator
A stupid authenticator that we use to stuff in name/password info into our tests.
session
protected static Session session
The javax.mail.Session object. This is created for you by startTests.
playdir
protected static File playdir
The directory where you can store temporary stuff. If you want to use this, be sure to call makePlayDir() at the beginning of your test; that will ensure that the directory exists and is empty.
firsttime
private static boolean firsttime
copybuf
static byte[] copybuf
Constructors
SelfTest
public SelfTest()
Default constructor
Methods
main
public static void main(String[] args)
Run all the grendel selftests. Every package within grendel ought to add itself here.
startTests
public void startTests(String[] args)
Initialize things. If a subclass overrides this method, it must call this superclass's method (via super.startTests()) The framework requires args to be passed down to SelfTestRoot.startTests.
endTests
public void endTests()
Clean up at the end. If a subclass overrides this method, it must call this superclass's method (via super.endTests())
setUserAndPassword
public void setUserAndPassword(String user, String password)
Stuff in the name and password we want to be used for the next test.
makePlayDir
public void makePlayDir()
Creates an empty directory for your test to put stuff into. If a previously running test made one, it gets blown away.
The very first time this is called, we make sure that the directory doesn't already exist. We want to make sure not to blow away something that was already sitting on disk that doesn't belong to us.
cleanDirectory
public void cleanDirectory(File dir)
Recursively cleans out the contents of the given directory. Potentially very dangerous!
cleanPlayDirectory
public void cleanPlayDirectory()
Blows away the play directory. Since endTests() calls this, there generally won't be any reason for anyone else to.
getStackTrace
public String getStackTrace(Throwable t)
Given a throwable, return as a string the stack trace from it.
installFile
public void installFile(String resname, String filename)
Takes a file from the jar file and stores it into the play directory.
Parameter Description resname The name of the resource to grab from the jar file. This name is interpreted relative to the package that your SelfTest subclass is in. filename The name of the file to create. This name is interpreted relative to the playdir.
prettyTime
public String prettyTime(long time)
Given a long that represents a time, returns a String representation of it suitable for putting in a log message.
writeKnownBug
public void writeKnownBug(Object o, String methodName, int bugnum, String message)
Report a bug that we already know about and that has an outstanding bug report sitting in the bug database.
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4