Skip to content

Commit

Permalink
refs #47
Browse files Browse the repository at this point in the history
readme
  • Loading branch information
rmpestano committed Sep 12, 2016
1 parent 6f7fb45 commit 423b015
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
----
Expand All @@ -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]
Expand All @@ -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

Expand Down

0 comments on commit 423b015

Please sign in to comment.