Class FarragoTestConcurrentTestCase

  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:
Direct Known Subclasses:

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);

$Id: //open/dev/farrago/src/net/sf/farrago/test/concurrent/ $
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
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


protected FarragoTestConcurrentTestCase(String testName)
                                 throws Exception
Method Detail


protected ConcurrentTestCommandGenerator newCommandGenerator()
Instantiates a new ConcurrentTestCommandGenerator.


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



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.

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


protected void setDataSource(ConcurrentTestCommandGenerator cmdGen,
                             String jdbcURL)


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


private void epilog(ConcurrentTestCommandGenerator cmdGen)