Database Plugin - Asserts¶
Contents :
‘dataset.dbunit’ does ‘contain’ ‘dataset.dbunit’¶
What ?
Asserts that the first dataset contains the second one.
ASSERT {dataset1<Res:dataset.dbunit>} DOES contain THE {dataset2<Res:dataset.dbunit>} [USING [{<Res:filter.dbunit>}],[{<Res:conf.dbunit.ppk>}] ] VERIFY {dataset1<Res:dataset.dbunit>} DOES contain THE {dataset2<Res:dataset.dbunit>} [USING [{<Res:filter.dbunit>}],[{<Res:conf.dbunit.ppk>}] ] |
> Input :
dataset1<Res:dataset.dbunit>
: The name of the resource which references the first DbUnit dataset (dataset.dbunit
type resource).dataset2<Res:dataset.dbunit>
: The name of the resource which references the second DbUnit dataset (dataset.dbunit
type resource).<Res:filter.dbunit>
(Optional) : This resource contains a filter DbUnit (filter.dbunit
type resource).<Res:conf.dbunit.ppk>
(Optional) : The name of the resource which references a configuration file to define the pseudo primary keys (conf.dbunit.ppk
type resource).
Example :
LOAD path/to/dataset1.xml AS dataset1_file CONVERT dataset1_file TO xml (structured) AS dataset1_xml CONVERT dataset1_xml TO dataset.dbunit (dataset) AS dataset1_dbu LOAD path/to/dataset1.xml AS dataset2_file CONVERT dataset2_file TO xml (structured) AS dataset2_xml CONVERT dataset2_xml TO dataset.dbunit (dataset) AS dataset2_dbu // Get the pseudo primary keys LOAD path/to/my_ppk.properties AS ppk_file CONVERT ppk_file TO properties (structured) AS ppk_properties CONVERT ppk_properties TO conf.dbunit.ppk (from.properties) AS ppk_dbu // Load the DbUnit filter LOAD path/to/filter-name.xml AS filter_file CONVERT filter_file TO filter.dbunit AS filter_dbu // Compare the two datasets ASSERT dataset1_dbu DOES contain THE dataset2_dbu USING ppk_dbu,filter_dbu |
Remarks
- During the assertion, if the first or the second dataset contains primary keys they are used for the assertion.
- If for a given table, a primary key and a pseudo primary key are defined, pseudo primary key overrides the primary key.
- If for a given table, a pseudo primary key has one or several columns excluded from the assertion by a DbUnit filter, the command fails.
‘dataset.dbunit’ is ‘equal’ ‘dataset.dbunit’¶
What ?
Asserts that the first dataset is equal to the second one (same number of tables, for each table same number of lines / columns and same data).
ASSERT {dataset1<Res:dataset.dbunit>} IS equal THE {dataset2<Res:dataset.dbunit>} [USING [{<Res:filter.dbunit>}],[{<Res:conf.dbunit.ppk>}] ] VERIFY {dataset1<Res:dataset.dbunit>} IS equal THE {dataset2<Res:dataset.dbunit>} [USING [{<Res:filter.dbunit>}],[{<Res:conf.dbunit.ppk>}] ] |
> Input :
dataset1<Res:dataset.dbunit>
: The name of the resource which references the first DbUnit dataset.(dataset.dbunit
type resource).dataset2<Res:dataset.dbunit>
: The name of the resource which references the second DbUnit dataset.(dataset.dbunit
type resource).<Res:filter.dbunit>
(Optional) : This resource contains a filter DbUnit (filter.dbunit
type resource).<Res:conf.dbunit.ppk>
(Optional) : The name of the resource which references a configuration file to define the pseudo primary keys.(conf.dbunit.ppk
type resource).
Example :
LOAD path/to/dataset1.xml AS dataset1_file CONVERT dataset1_file TO xml (structured) AS dataset1_xml CONVERT dataset1_xml TO dataset.dbunit (dataset) AS dataset1_dbu LOAD path/to/dataset1.xml AS dataset2_file CONVERT dataset2_file TO xml (structured) AS dataset2_xml CONVERT dataset2_xml TO dataset.dbunit (dataset) AS dataset2_dbu // Get the pseudo primary keys LOAD path/to/my_ppk.properties AS ppk_file CONVERT ppk_file TO properties (structured) AS ppk_properties CONVERT ppk_properties TO conf.dbunit.ppk (from.properties) AS ppk_dbu // Load the DbUnit filter LOAD path/to/filter-name.xml AS filter_file CONVERT filter_file TO filter.dbunit AS filter_dbu // Compare the two datasets ASSERT dataset1_dbu IS equal THE dataset2_dbu USING ppk_dbu,filter_dbu |
Remarks
- During the assertion, if the first or the second dataset contains primary keys they are used for the assertion.
- If for a given table, a primary key and a pseudo primary key are defined, pseudo primary key overrides the primary key.
- If for a given table, a pseudo primary key has one or several columns excluded from the assertion by a DbUnit filter, the command fails.