net.sf.farrago.test.concurrent
Class FarragoTestConcurrentTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.eigenbase.test.DiffTestCase
              extended by net.sf.farrago.test.ResultSetTestCase
                  extended by net.sf.farrago.test.FarragoTestCase
                      extended by net.sf.farrago.test.concurrent.FarragoTestConcurrentTestCase
All Implemented Interfaces:
Test
Direct Known Subclasses:
FarragoTestConcurrentScriptedTestCase

public abstract class FarragoTestConcurrentTestCase
extends FarragoTestCase

FarragoTestConcurrentTestCase provides a basic harness for executing multi-threaded test cases. It extends FarragoTestCase to exploit the multi-thread test utility from the package org.eigenbase.test.concurrent. To build a test case programmatically, obtain a ConcurrentTestCommandGenerator via the method newCommandGenerator() and use it to configure one or more threads to execute one or more commands. Once configured, run the test by calling executeTest(ConcurrentTestCommandGenerator, boolean, String). An alternative is to write a test script in the mtsql format; see FarragoTestConcurrentScriptedTestCase.

Note: To properly configure a test based on this class, you must provide a suite() method that wraps the tests in your class with v * the necessary initialization from FarragoTestCase. The normal implementation is:

   ...
   import junit.framework.Test;
   ...

   public class MyTest
       extends FarragoTestConcurrentTestCase
   {
       ...
       public static Test suite()
       {
           return wrappedSuite(MyTest.class);
       }
       ...
   }
 

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/test/concurrent/FarragoTestConcurrentTestCase.java#15 $
Author:
Stephan Zuercher

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.farrago.test.FarragoTestCase
FarragoTestCase.Cleanup, FarragoTestCase.CleanupFactory
 
Field Summary
 
Fields inherited from class net.sf.farrago.test.FarragoTestCase
allocOwner, connection, preparedStmt, repos, stmt, tracer
 
Fields inherited from class net.sf.farrago.test.ResultSetTestCase
resultSet
 
Fields inherited from class org.eigenbase.test.DiffTestCase
logFile, logOutputStream, refFile
 
Constructor Summary
protected FarragoTestConcurrentTestCase(String testName)
           
 
Method Summary
private  void epilog(ConcurrentTestCommandGenerator cmdGen)
           
protected  void executeTest(ConcurrentTestCommandGenerator cmdGen, boolean synchronizeClockTicks, String jdbcURL)
          Executes a test case, possibly after interpolating synchronization.
protected  void innerExecuteTest(ConcurrentTestCommandGenerator cmdGen, boolean synchronizeClockTicks)
           
protected  ConcurrentTestCommandGenerator newCommandGenerator()
          Instantiates a new ConcurrentTestCommandGenerator.
protected  ConcurrentTestCommandScript newScriptedCommandGenerator(String filename)
          Instantiates a new ConcurrentTestCommandScript with the given file.
protected  void setDataSource(ConcurrentTestCommandGenerator cmdGen, String jdbcURL)
           
 
Methods inherited from class net.sf.farrago.test.FarragoTestCase
forceShutdown, getJdbcUri, getSession, getTestlogRoot, getTestlogRootStatic, newConnection, newJdbcEngineDriver, restoreParameters, restoreParameters, runCleanup, runSqlLineTest, runSqlLineTest, saveParameters, saveParameters, setRefFileDiffMasks, setUp, shouldDiff, staticSetUp, staticTearDown, tearDown, tearDownImpl, wrappedSuite, wrappedSuite
 
Methods inherited from class net.sf.farrago.test.ResultSetTestCase
compareResultList, compareResultLists, compareResultSet, compareResultSetWithDelta, compareResultSetWithPattern, getResultSetCount
 
Methods inherited from class org.eigenbase.test.DiffTestCase
addDiffMask, addIgnorePattern, diffFile, diffLines, diffTestLog, fileContents, openTestLog, openTestLogOutputStream, setGC, setVerbose
 
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

FarragoTestConcurrentTestCase

protected FarragoTestConcurrentTestCase(String testName)
                                 throws Exception
Throws:
Exception
Method Detail

newCommandGenerator

protected ConcurrentTestCommandGenerator newCommandGenerator()
Instantiates a new ConcurrentTestCommandGenerator.


newScriptedCommandGenerator

protected ConcurrentTestCommandScript newScriptedCommandGenerator(String filename)
                                                           throws IOException
Instantiates a new ConcurrentTestCommandScript with the given file.

Throws:
IOException

executeTest

protected void executeTest(ConcurrentTestCommandGenerator cmdGen,
                           boolean synchronizeClockTicks,
                           String jdbcURL)
                    throws Exception
Executes a test case, possibly after interpolating synchronization. Note: If synchronizeClockTicks is true, the command lists configured for each thread are normalized so that each thread has the same set of execution orders (or clock ticks). When a thread is missing a clock tick that other threads contain, a no-op command is added for the clock tick. Prior to execution, a synchronization object is created. All ConcurrentTestCommandExecutors for the test wait at a synchronization point until all threads have reached the point before continuing on to execute the clock tick's command. If synchronizeClockTicks is false, no synchronization occurs and all threads execute their commands, in order, as fast as they can.

Each ConcurrentTestCommandExecutor's first error is reported on System.err. If any ConcurrentTestCommandExecutor has an error, the test fails.

Parameters:
synchronizeClockTicks - flag for thread synchronization (see above)
cmdGen - embodies the test case
jdbcURL - identifies server
Throws:
Exception - if no connection found or if a thread operation is interrupted

setDataSource

protected void setDataSource(ConcurrentTestCommandGenerator cmdGen,
                             String jdbcURL)

innerExecuteTest

protected void innerExecuteTest(ConcurrentTestCommandGenerator cmdGen,
                                boolean synchronizeClockTicks)
                         throws Exception
Throws:
Exception

epilog

private void epilog(ConcurrentTestCommandGenerator cmdGen)