org.eigenbase.test.concurrent
Class ConcurrentTestCommandGenerator.AbstractCommand

java.lang.Object
  extended by org.eigenbase.test.concurrent.ConcurrentTestCommandGenerator.AbstractCommand
All Implemented Interfaces:
ConcurrentTestCommand
Direct Known Subclasses:
ConcurrentTestCommandGenerator.CloseCommand, ConcurrentTestCommandGenerator.CommandWithTimeout, ConcurrentTestCommandGenerator.CommitCommand, ConcurrentTestCommandGenerator.DdlCommand, ConcurrentTestCommandGenerator.ExplainCommand, ConcurrentTestCommandGenerator.PrepareCommand, ConcurrentTestCommandGenerator.RollbackCommand, ConcurrentTestCommandGenerator.SleepCommand, ConcurrentTestCommandGenerator.SynchronizationCommand, ConcurrentTestCommandScript.CommandWithTimeout, ConcurrentTestCommandScript.EchoCommand, ConcurrentTestCommandScript.PrepareCommand, ConcurrentTestCommandScript.PrintCommand, ConcurrentTestCommandScript.ShellCommand
Enclosing class:
ConcurrentTestCommandGenerator

protected abstract static class ConcurrentTestCommandGenerator.AbstractCommand
extends Object
implements ConcurrentTestCommand

abstract base to handle SQLExceptions


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eigenbase.test.concurrent.ConcurrentTestCommand
ConcurrentTestCommand.ShouldHaveFailedException
 
Field Summary
private  String failComment
           
private  Pattern failPattern
           
private  boolean failureExpected
           
private  boolean shouldFail
           
 
Constructor Summary
protected ConcurrentTestCommandGenerator.AbstractCommand()
           
 
Method Summary
protected abstract  void doExecute(ConcurrentTestCommandExecutor exec)
           
 void execute(ConcurrentTestCommandExecutor exec)
          Executes this command.
 boolean isFailureExpected()
          Returns true if the command should fail.
 ConcurrentTestCommand markToFail()
          Set this command to expect a patternless failure.
 ConcurrentTestCommand markToFail(String comment, String pattern)
          Marks a command to show that it is expected to fail, and indicates how.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shouldFail

private boolean shouldFail

failComment

private String failComment

failPattern

private Pattern failPattern

failureExpected

private boolean failureExpected
Constructor Detail

ConcurrentTestCommandGenerator.AbstractCommand

protected ConcurrentTestCommandGenerator.AbstractCommand()
Method Detail

markToFail

public ConcurrentTestCommand markToFail(String comment,
                                        String pattern)
Description copied from interface: ConcurrentTestCommand
Marks a command to show that it is expected to fail, and indicates how. Used for negative tests. Normally when a command fails the embracing test fails. But when a marked command fails, the error is caught and inspected: if it matches the expected error, the test continues. However if it does not match, if another kind of exception is thrown, or if no exception is caught, then the test fails. Assumes the error is indicated by a java.sql.SQLException. Optionally checks for the expected error condition by matching the error message against a regular expression. (Scans the list of chained SQLExceptions).

Specified by:
markToFail in interface ConcurrentTestCommand
Parameters:
comment - a brief description of the expected error
pattern - null, or a regular expression that matches the expected error message.

isFailureExpected

public boolean isFailureExpected()
Description copied from interface: ConcurrentTestCommand
Returns true if the command should fail. This allows special error handling for expected failures that don't have patterns.

Specified by:
isFailureExpected in interface ConcurrentTestCommand
Returns:
true if command is expected to fail

markToFail

public ConcurrentTestCommand markToFail()
Description copied from interface: ConcurrentTestCommand
Set this command to expect a patternless failure.

Specified by:
markToFail in interface ConcurrentTestCommand

doExecute

protected abstract void doExecute(ConcurrentTestCommandExecutor exec)
                           throws Exception
Throws:
Exception

execute

public void execute(ConcurrentTestCommandExecutor exec)
             throws Exception
Description copied from interface: ConcurrentTestCommand
Executes this command. The ConcurrentTestCommandExecutor provides access to a JDBC connection and previously prepared statements.

Specified by:
execute in interface ConcurrentTestCommand
Parameters:
exec - the ConcurrentTestCommandExecutor firing this command.
Throws:
ConcurrentTestCommand.ShouldHaveFailedException - to indicate a test failure
Exception
See Also:
ConcurrentTestCommandExecutor.getStatement(), ConcurrentTestCommandExecutor.setStatement(java.sql.Statement)