net.sf.farrago.test.concurrent
Class FarragoTestConcurrentTestCase
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.eigenbase.test.DiffTestCase
net.sf.farrago.test.ResultSetTestCase
net.sf.farrago.test.FarragoTestCase
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
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 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 |
FarragoTestConcurrentTestCase
protected FarragoTestConcurrentTestCase(String testName)
throws Exception
- Throws:
Exception
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 casejdbcURL
- 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)