Releases: camassia-io/spring-boot-test-dbunit
Allow Java 11 consumers
Allow Java 11 consumers
Reduces the Target Compatibility version down to Java 11
Maven Central Release
Publishes the project to Sonatype Nexus (Maven Central)
Improved Support for Default use & clearing of tables
Rows in Tables can now be created using only defaults e.g.
dbunit.givenDataSet(
Table(
"table-name",
Row(emptyList())
)
)
or for file based:
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<demo id="[ID]" name="[NAME]"/> // All columns need to be specified
</dataset>
As long as there is a default configured for each mandatory column in 'table-name' then a row will be created using those
Tables can also be cleared programatically using
dbunit.givenDataSet(
Table("table-name") // Or Table("table-name", emptyList())
)
Support DatabaseSetup and Teardown annotations on nested class hierarchy
When using a test class hierarchy, previously only the test method + class containing the test method could be annotated with @DatabaseSetup
or @DatabaseTeardown
.
As of this change the parent, grandparent, great grandparent etc of the test method can have the annotations too.
Remember to use the operation = DatabaseOperation.INSERT
option on child level annotations though if adding to the same table at different stages.
This stops the data already in the table getting wiped once a new operation on that table is made at a lower level.
Templated val improvements
Improves the conventions for templated vals
- Doesn't treat json arrays as a templated variable name
- Templated variable names now need to follow a certain pattern
[A-Za-z0-9_\-]+
Error or emit Warn log if an Override isn't used
By default going forwards if a user specifies an Override that isn't used then an exception will be thrown.
This can be changed to a warn log with spring.dbunit.fail_on_unused_overrides=false
This should help avoid & highlight typos in tests
Version upgrades
Java 17, Gradle 7.4.2, dbunit 2.7.3
Bug fix for when a missing Override fell back to a null default
Previously an exception would be thrown. Now the null
default is used.
Introduce the concept of Extensions & Filename replacement
Extensions
Builds on Table Defaults & Overrides to streamline how they work.
These are configured by default but can be overridden using Beans
@Bean
@ConditionalOnMissingBean
fun extensions(
resourceLoader: ResourceLoader,
defaults: List<TableDefaults>,
config: DatabaseConfig
): Extensions {
val dbDefaults = Defaults(defaults, !(config.getProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES) as Boolean))
return Extensions(
listOf(
// Resolves all known templates and ignores unknowns for further processing
TemplatedCellMappingExtension,
// Replaces all [null]s will null
NullCellMappingExtension,
// Resolves all file replacements
ResourceBasedValueCellMappingExtension(resourceLoader),
// Resolves all remaining templates and uses global defaults for any missing values in the form [.*]
DefaultTemplatedCellMappingExtension(dbDefaults)
),
dbDefaults
)
}
File name replacement
You can now have a column value of [file:{somefilename.xyz}]
and Db Unit will use the File Loader to load the content of the file
e.g. [file:xyz.txt]