com.cafesoft.core.util
Class TestUtils

java.lang.Object
  |
  +--com.cafesoft.core.util.TestUtils

public class TestUtils
extends Object

A helper class that provides convienence methods for JUnit testing classes. This class is not meant to be distributed however there is nothing special that would cause problems if it was shipped.

Since:
11/30/01

Constructor Summary
TestUtils()
           
 
Method Summary
static void configureLog4J(String logsDirPath, Object object)
          Configure Log4j to run for the particular test class.
static void configureLog4J(String logsDirPath, String name, Object object)
          Configure Log4j to run for the particular test class.
static Logger getLogger(String logsDirPath, Object object)
          Creates a new Logger for the specfied object.
static void main(String[] args)
          A simple test.
static void pause(int seconds)
          Have the current executing thread sleep for the specified amount of seconds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestUtils

public TestUtils()
Method Detail

configureLog4J

public static void configureLog4J(String logsDirPath,
                                  Object object)
Configure Log4j to run for the particular test class.

There is a very strange behavior with the JUnit tests. A new test case is created for each test. Without this method a new adapter would be added for each time the test case was created.

Therefore, this method will configure the Log4j tool once.

Parameters:
logsDirPath - the path where the resultant log file should be placed
object - the object that the logger is being configured for. This will be translated into the objects class name which will become the log files name as well.

configureLog4J

public static void configureLog4J(String logsDirPath,
                                  String name,
                                  Object object)
Configure Log4j to run for the particular test class.

There is a very strange behavior with the JUnit tests. A new test case is created for each test. Without this method a new adapter would be added for each time the test case was created.

Therefore, this method will configure the Log4j tool once.

Parameters:
logsDirPath - the path where the resultant log file should be placed
object - the object that the logger is being configured for. This will be translated into the objects class name which will become the log files name as well.

getLogger

public static Logger getLogger(String logsDirPath,
                               Object object)
Creates a new Logger for the specfied object. The log will be written to logsDirPath + the name of the object + .txt.

Parameters:
logsDirPath - the directory where the log will be written
object - the object requesting a logger
Returns:
a Logger for the specified object

main

public static void main(String[] args)
A simple test.

Parameters:
args - contains command-line arguments

pause

public static void pause(int seconds)
Have the current executing thread sleep for the specified amount of seconds

Parameters:
seconds - The number of seconds to sleep


Generated on 8:41:50 AM June 06, 2005, © 1996-2005 Cafésoft LLC. All rights reserved.