You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.6 KiB
36 lines
1.6 KiB
[[integration-testing-support-jdbc]] |
|
= JDBC Testing Support |
|
|
|
|
|
[[integration-testing-support-jdbc-test-utils]] |
|
== JdbcTestUtils |
|
|
|
The `org.springframework.test.jdbc` package contains `JdbcTestUtils`, which is a |
|
collection of JDBC-related utility functions intended to simplify standard database |
|
testing scenarios. Specifically, `JdbcTestUtils` provides the following static utility |
|
methods. |
|
|
|
* `countRowsInTable(..)`: Counts the number of rows in the given table. |
|
* `countRowsInTableWhere(..)`: Counts the number of rows in the given table by using the |
|
provided `WHERE` clause. |
|
* `deleteFromTables(..)`: Deletes all rows from the specified tables. |
|
* `deleteFromTableWhere(..)`: Deletes rows from the given table by using the provided |
|
`WHERE` clause. |
|
* `dropTables(..)`: Drops the specified tables. |
|
|
|
[TIP] |
|
==== |
|
xref:testing/testcontext-framework/support-classes.adoc#testcontext-support-classes-junit4[`AbstractTransactionalJUnit4SpringContextTests`] |
|
and xref:testing/testcontext-framework/support-classes.adoc#testcontext-support-classes-testng[`AbstractTransactionalTestNGSpringContextTests`] |
|
provide convenience methods that delegate to the aforementioned methods in |
|
`JdbcTestUtils`. |
|
==== |
|
|
|
[[integration-testing-support-jdbc-embedded-database]] |
|
== Embedded Databases |
|
|
|
The `spring-jdbc` module provides support for configuring and launching an embedded |
|
database, which you can use in integration tests that interact with a database. |
|
For details, see xref:data-access/jdbc/embedded-database-support.adoc[Embedded Database Support] |
|
and xref:data-access/jdbc/embedded-database-support.adoc#jdbc-embedded-database-dao-testing[Testing Data Access |
|
Logic with an Embedded Database].
|
|
|