## grendel
Class SelfTest

    grendel.SelfTest

Direct Known Subclasses:
  SelfTest

public class 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.

Field Summary
`protected static java.io.File` | `playdir` The directory where you can store temporary stuff.
`protected static java.util.Properties` | `props` The Properties instance that all the javamail stuff will use.
`protected static javax.mail.Session` | `session` The javax.mail.Session object.

Constructor Summary
`SelfTest()`

Method Summary
`void` | `cleanDirectory(java.io.File dir)` Recursively cleans out the contents of the given directory.
`void` | `cleanPlayDirectory()` Blows away the play directory.
`void` | `endTests()` Clean up at the end.
`java.lang.String` | `getStackTrace(java.lang.Throwable t)` Given a throwable, return as a string the stack trace from it.
`void` | `installFile(java.lang.String resname, java.lang.String filename)` Takes a file from the jar file and stores it into the play directory.
`static void` | `main(java.lang.String[] args)` Run all the grendel selftests.
`void` | `makePlayDir()` Creates an empty directory for your test to put stuff into.
`java.lang.String` | `prettyTime(long time)` Given a long that represents a time, returns a String representation of it suitable for putting in a log message.
`void` | `setUserAndPassword(java.lang.String user, java.lang.String password)` Stuff in the name and password we want to be used for the next test.
`void` | `startTests(java.lang.String[] args)` Initialize things.
`void` | `writeKnownBug(java.lang.Object o, java.lang.String methodName, int bugnum, java.lang.String message)` Report a bug that we already know about and that has an outstanding bug report sitting in the bug database.

Field Detail

### props

    protected static java.util.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.

### session

    protected static javax.mail.Session session

  The javax.mail.Session object. This is created for you by startTests.

### playdir

    protected static java.io.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.

Constructor Detail

### SelfTest

    public SelfTest()

Method Detail

### main

    public static void main(java.lang.String[] args)

  Run all the grendel selftests. Every package within grendel ought to add itself here.

### startTests

    public void startTests(java.lang.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(java.lang.String user,
                                   java.lang.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(java.io.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 java.lang.String getStackTrace(java.lang.Throwable t)

  Given a throwable, return as a string the stack trace from it.

### installFile

    public void installFile(java.lang.String resname,
                            java.lang.String filename)

  Takes a file from the jar file and stores it into the play directory.
  Parameters:
    `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 java.lang.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(java.lang.Object o,
                              java.lang.String methodName,
                              int bugnum,
                              java.lang.String message)

  Report a bug that we already know about and that has an outstanding bug report sitting in the bug database.