Class ConcurrentTestCommandGenerator.AbstractCommand
- java.lang.Object
-
- org.apache.calcite.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.PluginCommand
,ConcurrentTestCommandScript.PrepareCommand
,ConcurrentTestCommandScript.PrintCommand
,ConcurrentTestCommandScript.ShellCommand
- Enclosing class:
- ConcurrentTestCommandGenerator
protected abstract static class ConcurrentTestCommandGenerator.AbstractCommand extends java.lang.Object implements ConcurrentTestCommand
abstract base to handle SQLExceptions
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.calcite.test.concurrent.ConcurrentTestCommand
ConcurrentTestCommand.ShouldHaveFailedException
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
failComment
private java.util.regex.Pattern
failPattern
private boolean
failureExpected
private boolean
shouldFail
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCommand()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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(java.lang.String comment, java.lang.String pattern)
Marks a command to show that it is expected to fail, and indicates how.
-
-
-
Method Detail
-
markToFail
public ConcurrentTestCommand markToFail(java.lang.String comment, java.lang.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 interfaceConcurrentTestCommand
- Parameters:
comment
- a brief description of the expected errorpattern
- 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 interfaceConcurrentTestCommand
- 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 interfaceConcurrentTestCommand
-
doExecute
protected abstract void doExecute(ConcurrentTestCommandExecutor exec) throws java.lang.Exception
- Throws:
java.lang.Exception
-
execute
public void execute(ConcurrentTestCommandExecutor exec) throws java.lang.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 interfaceConcurrentTestCommand
- Parameters:
exec
- the ConcurrentTestCommandExecutor firing this command.- Throws:
java.lang.Exception
- to indicate a test failure- See Also:
ConcurrentTestCommandExecutor.getStatement()
,ConcurrentTestCommandExecutor.setStatement(java.sql.Statement)
-
-