T - type of parameter placeholder identifiers, see getIdentifier(int).public interface TestKit<T>
createTable() and dropTable()).
Functionality that is not supported by a driver should exclude the individual tests by using @Disabled.
Implementors need to provide the following methods:
getConnectionFactory(): Provide the ConnectionFactory under test.getCreateTableWithAutogeneratedKey(): Return the CREATE TABLE statement to create a table.getPlaceholder(int): Return an parameter placeholder for the nth argument. Arguments start at zero.getIdentifier(int): Return an identifier for the nth argument. The placeholder was obtained prior to this call via getPlaceholder(int). Arguments start at zero
getJdbcOperations(): Return a handle to JdbcOperations configured to the same data source as getConnectionFactory(). Used for test fixture setup/teardown.The following customization hooks can be overridden to adapt the TCK to a specific database:
expand(TestStatement, Object...): Return the SQL statement for a specific TestKit.TestStatement.blobType(): Returns the SQL type for a Blob column.clobType(): Returns the SQL type for a Clob column.| Modifier and Type | Interface and Description |
|---|---|
static class |
TestKit.TestStatement
Enumeration of TCK statements.
|
| Modifier and Type | Method and Description |
|---|---|
default void |
autoCommitByDefault() |
default void |
batch() |
static Statement |
bind(Statement statement,
Object identifier,
Object value) |
default void |
bindFails() |
default void |
bindNull() |
static Statement |
bindNull(Statement statement,
Object identifier,
Class<?> type) |
default void |
bindNullAsParameter() |
default void |
bindNullFails() |
default void |
bindValueAsParameter() |
default void |
blobInsert() |
default void |
blobSelect() |
default String |
blobType()
Customization hook: Returns the SQL type for a
Blob column. |
static Exception |
captureException(Callable<?> throwingCallable)
|
default void |
changeAutoCommitCommitsTransaction() |
default void |
clobInsert() |
default void |
clobSelect() |
default String |
clobType()
Customization hook: Returns the SQL type for a
Clob column. |
static <T> Collection<T> |
collectionOf(T... values)
Returns an unordered
Collection containing 0 or more values. |
default void |
columnMetadata() |
default void |
compoundStatement() |
default void |
createStatementFails() |
default void |
createTable() |
default String |
doGetSql(TestKit.TestStatement statement)
Customization hook to obtain a SQL text for a
TestKit.TestStatement. |
default void |
dropTable() |
default void |
duplicateColumnNames() |
default String |
expand(TestKit.TestStatement statement,
Object... args)
Obtain and expand SQL text for a
TestKit.TestStatement. |
default Object |
extractColumn(Row row)
Customization hook to extract the
value column from Row. |
default <V> V |
extractColumn(Row row,
Class<V> type)
Customization hook to extract the
value column from Row. |
default reactor.core.publisher.Mono<Collection<Integer>> |
extractColumns(Result result)
Customization hook to extract the
value column from Result. |
default reactor.core.publisher.Mono<Long> |
extractRowsUpdated(Result result)
Customization hook to extract
Result.getRowsUpdated(). |
ConnectionFactory |
getConnectionFactory()
Returns a
ConnectionFactory for the connected database. |
default String |
getCreateTableWithAutogeneratedKey()
Deprecated.
since 0.8.3, use
doGetSql(TestStatement) as customization hook instead using TestKit.TestStatement.CREATE_TABLE_AUTOGENERATED_KEY. |
T |
getIdentifier(int index)
Returns the bind identifier for a given substitution.
|
default String |
getInsertIntoWithAutogeneratedKey()
Deprecated.
since 0.8.3, use
doGetSql(TestStatement) as customization hook instead using TestKit.TestStatement.INSERT_VALUE_AUTOGENERATED_KEY. |
org.springframework.jdbc.core.JdbcOperations |
getJdbcOperations()
Returns a
JdbcOperations for the connected database. |
String |
getPlaceholder(int index)
Returns the database-specific placeholder for a given substitution.
|
default void |
prepareStatement() |
default void |
prepareStatementWithIncompleteBatchFails() |
default void |
prepareStatementWithIncompleteBindingFails() |
default void |
prepareStatementWithTrailingAddShouldFail() |
default void |
returnGeneratedValues() |
default void |
returnGeneratedValuesFails() |
default void |
row() |
default void |
rowMetadata() |
default void |
sameAutoCommitLeavesTransactionUnchanged() |
default void |
savePoint() |
default void |
savePointStartsTransaction() |
default void |
segmentInsertEmitsUpdateCount() |
default void |
segmentInsertWithFilterCompletesWithoutOnNext() |
default void |
segmentSelectWithEmitsRow() |
default void |
segmentSelectWithFilterCompletesWithoutOnNext() |
default void |
transactionCommit() |
default void |
transactionRollback() |
default void |
validate() |
default reactor.core.publisher.Mono<Long> extractRowsUpdated(Result result)
Result.getRowsUpdated().result - the result objectdefault reactor.core.publisher.Mono<Collection<Integer>> extractColumns(Result result)
value column from Result.result - the result object@Nullable default Object extractColumn(Row row)
value column from Row.row - the row@Nullable default <V> V extractColumn(Row row, Class<V> type)
value column from Row.V - column value typerow - the rowtype - column value typedefault String expand(TestKit.TestStatement statement, Object... args)
TestKit.TestStatement. SQL retrieval can be customized by using doGetSql(TestStatement).statement - the test statementargs - parameters for String.format(java.lang.String, java.lang.Object...) replacement.default String doGetSql(TestKit.TestStatement statement)
TestKit.TestStatement.statement - the test statement@Deprecated default String getInsertIntoWithAutogeneratedKey()
doGetSql(TestStatement) as customization hook instead using TestKit.TestStatement.INSERT_VALUE_AUTOGENERATED_KEY.INSERT INTO statement for a table which created
by getCreateTableWithAutogeneratedKey(), only contains the
data for second column value which should be 100.
Example:
INSERT INTO test VALUES(100);
// or
INSERT INTO test VALUES(DEFAULT,100);
INSERT INTO statement@Deprecated default String getCreateTableWithAutogeneratedKey()
doGetSql(TestStatement) as customization hook instead using TestKit.TestStatement.CREATE_TABLE_AUTOGENERATED_KEY.CREATE TABLE statement for a table named test
with two columns: First one uses auto-generated keys, second one is named value of type INT.
Example:
CREATE TABLE test ( id SERIAL, value INTEGER );
// or
CREATE TABLE test ( id INTEGER IDENTITY, value INTEGER );
CREATE TABLE statementdefault String blobType()
Blob column.Blob column.default String clobType()
Clob column.Clob column.@BeforeEach default void createTable()
@AfterEach default void dropTable()
ConnectionFactory getConnectionFactory()
ConnectionFactory for the connected database.ConnectionFactory for the connected databaseString getPlaceholder(int index)
index - the zero-index number of the substitutionT getIdentifier(int index)
index - the zero-index number of the substitutionorg.springframework.jdbc.core.JdbcOperations getJdbcOperations()
JdbcOperations for the connected database.JdbcOperations for the connected database@Test default void autoCommitByDefault()
@Test default void changeAutoCommitCommitsTransaction()
@Test default void sameAutoCommitLeavesTransactionUnchanged()
@Test default void batch()
@Test default void bindFails()
@Test default void bindValueAsParameter()
@Test default void bindNullAsParameter()
@Test default void bindNull()
@Test default void bindNullFails()
@Test default void blobInsert()
@Test default void blobSelect()
@Test default void clobInsert()
@Test default void clobSelect()
@Test default void columnMetadata()
@Test default void rowMetadata()
@Test default void row()
@Test default void compoundStatement()
@Test default void createStatementFails()
@Test default void duplicateColumnNames()
@Test default void prepareStatement()
@Test default void prepareStatementWithTrailingAddShouldFail()
@Test default void prepareStatementWithIncompleteBatchFails()
@Test default void prepareStatementWithIncompleteBindingFails()
@Test default void returnGeneratedValues()
@Test default void returnGeneratedValuesFails()
@Test default void savePoint()
@Test default void savePointStartsTransaction()
@Test default void segmentInsertEmitsUpdateCount()
@Test default void segmentInsertWithFilterCompletesWithoutOnNext()
@Test default void segmentSelectWithFilterCompletesWithoutOnNext()
@Test default void segmentSelectWithEmitsRow()
@Test default void transactionCommit()
@Test default void transactionRollback()
@Test default void validate()
@SafeVarargs static <T> Collection<T> collectionOf(T... values)
Collection containing 0 or more values.T - Class of objects in valuesvalues - 0 or more valuesCollection containing valuesstatic Exception captureException(Callable<?> throwingCallable)
throwingCallable - the callable code blockIllegalStateException - if throwingCallable did not throw an exception.Copyright © 2022. All rights reserved.