diff --git a/README.adoc b/README.adoc index 974d1e3..7c0ed70 100644 --- a/README.adoc +++ b/README.adoc @@ -979,7 +979,9 @@ TIP: Complete source code of example above can be https://github.com/rmpestano/d == Export DataSets -In order to export database state *after test* execution into datasets files one can use *@ExportDataSet* Annotation (class or method level): +In order to export database state *after test* execution into datasets files one can use *@ExportDataSet* Annotation (class or method level) + +=== Example [source, java, linenums] ---- @@ -994,8 +996,27 @@ In order to export database state *after test* execution into datasets files one After execution of above test, all tables will be exported to a xml dataset. -[TIP] -==== +NOTE: *XML*, *YML*, *JSON*, *XLS* and *CSV* formats are supported. + +TIP: Full example above (and other related tests) can be https://github.com/rmpestano/dbunit-rules/blob/master/core/src/test/java/com/github/dbunit/rules/ExportDataSetIt.java#L35[found here^]. + +=== Configuration + +Following table you can find all options for ExportDataset: + +[cols="3*", options="header"] +|=== +|Name | Description | Default +|format| Exported dataset file format.| YML +|includeTables| A list of table names to include in exported dataset.| Default is empty which means *ALL tables*. +|queryList| A list of select statements which the result will used in exported dataset.| {} +|dependentTables| If true will bring dependent tables of declared includeTables.| false +|outputName| Name (and path) of output file.| "" +|=== + + +=== Programatic export + You don't need `@ExportDataSet`, you can use DataSetExporter component programmatically: [source,java,linenums] @@ -1011,34 +1032,17 @@ You don't need `@ExportDataSet`, you can use DataSetExporter component programma DataSetExporterImpl.getInstance().export(new DatabaseConnection(emProvider.connection()), <1> new DataSetExportConfig().outputFileName("target/user.yml")); File ymlDataSet = new File("target/user.yml"); - assertThat(ymlDataSet).exists(); - assertThat(contentOf(ymlDataSet)). - contains("USER:"+NEW_LINE + - " - ID: 1"+NEW_LINE + - " NAME: \"u1\""+NEW_LINE - ); + assertThat(ymlDataSet).exists(); + assertThat(contentOf(ymlDataSet)). + contains("USER:"+NEW_LINE + + " - ID: 1"+NEW_LINE + + " NAME: \"u1\""+NEW_LINE); } ---- <1> DatabaseConnection is from DBUnit api and it needs a JDBC connection. + -==== - -NOTE: *xml*, *yml*, *JSON*, *XLS* and *CSV* formats are supported. - -TIP: Full example above (and other related tests) can be https://github.com/rmpestano/dbunit-rules/blob/master/core/src/test/java/com/github/dbunit/rules/ExportDataSetIt.java#L35[found here^]. - -Following table you can find all options for ExportDataset: - -[cols="3*", options="header"] -|=== -|Name | Description | Default -|format| Exported dataset file format.| YML -|includeTables| A list of table names to include in exported dataset.| Default is empty which means ALL tables. -|queryList| A list of select statements which the result will used in exported dataset.| {} -|dependentTables| If true will bring dependent tables of declared includeTables.| false -|outputName| Name (and path) of output file.| "" -|=== == Snapshots