org.osesb.utilities.threadmanaged.test
Class BasicThreadManagerTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.osesb.utilities.junit.OSESBTestCase
              extended by org.osesb.utilities.junit.OSESBDBUnitTestCase
                  extended by org.osesb.utilities.threadmanaged.test.BasicThreadManagerTest
All Implemented Interfaces:
junit.framework.Test

public class BasicThreadManagerTest
extends OSESBDBUnitTestCase

Basic tests of ThreadManager:

The tests use the following classes which implement IThreadManageable and IPoolableThreadManageable.


Field Summary
 
Fields inherited from class org.osesb.utilities.junit.OSESBDBUnitTestCase
dbunitDataSet, dbunitJDBCConnection
 
Fields inherited from class org.osesb.utilities.junit.OSESBTestCase
configFile, log, reader, testDataDirectory, testProperties, thisClassName
 
Constructor Summary
BasicThreadManagerTest(java.lang.String name)
          Construct a new instance.
 
Method Summary
static void main(java.lang.String[] args)
          The main method runs all the tests in the text ui
 void setUp()
          This method is called before a test is executed.
static junit.framework.Test suite()
          The suite method runs all the tests
 void tearDown()
          This method is called after a test is executed.
 void testRunThreadManaged()
          Test the ThreadManaged#runThreadManaged() method, which runs a ThreadManaged Thread and waits for it to complete.
 void testRunThreadManagedTaskList()
          Test the runThreadManagedTaskList() method, which runs a set of tasks that were added to the threadManagedInputTaskList and waits for them to complete or timeout.
 void testRunThreadManagedTaskListWithTimeout()
          Test the runThreadManagedTaskList() method, which runs a set of tasks that were added to the threadManagedInputTaskList and waits for them to complete or timeout.
 void testRunThreadManagedWithTimeout()
          Test the timeout feature of the ThreadManaged#runThreadManaged() method, which runs a ThreadManaged Thread and waits for it to complete or timeout.
 
Methods inherited from class org.osesb.utilities.junit.OSESBDBUnitTestCase
displayStartupMessage, loadDBUnitDatabaseConnection
 
Methods inherited from class org.osesb.utilities.junit.OSESBTestCase
getBooleanTestProperty, getIntTestProperty, getLongTestProperty, getTestResourcesAsStreams, getTestResourcesAsText, getTestResourcesFiles, loadTestProperties, readTestFilesAsStreams
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicThreadManagerTest

public BasicThreadManagerTest(java.lang.String name)
Construct a new instance.

OSESBTestCase (ancestor) constructor does the following:

  1. Instantiates a logging implementation.
  2. Instantiates an instance of ClassLoaderFileReader for reading test files from the ClassPath (not the file system).
  3. Loads Test.properties into ResourceBundle testProperties.
  4. Sets the testDataDirectory property using the testDataDirectory entry from Test.properties.

Method Detail

suite

public static junit.framework.Test suite()
The suite method runs all the tests


setUp

public void setUp()
           throws java.lang.Exception
This method is called before a test is executed.

Overrides:
setUp in class OSESBTestCase
Throws:
java.lang.Exception

tearDown

public void tearDown()
              throws java.lang.Exception
This method is called after a test is executed.

Overrides:
tearDown in class OSESBDBUnitTestCase
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
The main method runs all the tests in the text ui


testRunThreadManaged

public void testRunThreadManaged()
                          throws java.lang.Exception
Test the ThreadManaged#runThreadManaged() method, which runs a ThreadManaged Thread and waits for it to complete.

Throws:
java.lang.Exception

testRunThreadManagedWithTimeout

public void testRunThreadManagedWithTimeout()
                                     throws java.lang.Exception
Test the timeout feature of the ThreadManaged#runThreadManaged() method, which runs a ThreadManaged Thread and waits for it to complete or timeout.

ThreadManageableTestClass3's operative method, runForever(), runs forever in a loop with a Thread.sleep(). Therefore runForever() is interruptable. The test verifies that runThreadManaged() throws a ThreadTimeoutException and the interruption of runForever() should be logged to debug.

Throws:
java.lang.Exception

testRunThreadManagedTaskList

public void testRunThreadManagedTaskList()
                                  throws java.lang.Exception
Test the runThreadManagedTaskList() method, which runs a set of tasks that were added to the threadManagedInputTaskList and waits for them to complete or timeout. None of the tasks timeout.

Throws:
java.lang.Exception

testRunThreadManagedTaskListWithTimeout

public void testRunThreadManagedTaskListWithTimeout()
                                             throws java.lang.Exception
Test the runThreadManagedTaskList() method, which runs a set of tasks that were added to the threadManagedInputTaskList and waits for them to complete or timeout. One of the tasks times out.

Throws:
java.lang.Exception