<?xml version='1.0' encoding='UTF-8'?> <!--DOCTYPE dataset SYSTEM 'testData/dbunit-test_data_set.dtd'--> <!-- See DbUnit's XmlDataSet. Database definition for AbstractEmbeddedDbTestCase - uses DbUnit to load the data into an embedded derby DB - To connect to the DB: user sa, psw emty, url jdbc:derby:<absolute path to this project>\testData\testDB Note: Only 1 connection to the Derby DB at a time is allowed!!!! IMPORTANT ========= 1) You must have <table> entry for any table you want DbUnit to clear for you. Even if you don't want DbUnit to insert any data you must still declare at least <table name="yourSchema.yourTable" /> for the table yourSchema.yourTable to be emptied during test setUp(). 2) When using a column that contains XML value, you may use <![CDATA[ to supply the value. But there should be no space within '<value><![CDATA[<?xml ...' otherwise you may get Xerces' exception 'The processing instruction target matching "[xX][mM][lL]" is not allowed.' ABOUT FILE FORMAT ================= This format is better than flat data set because it describes explicitly the columns though it's also more verbose. Also, thanks to setting the DbUnit feature QUALIFIED_TABLE_NAMES to true in the test, we can use fully qualified table names and thus have tables in different schemas. HOW TO CREATE ============= To create a DbUnit data set like this you've several options: 1. Write it manually. 2. Use DbUnit itself to connect to a DB, load a data set and store it into a XmlDataSet. 3. Use the Eclipse plugin QuantumDB and its ability to export table into DbUnit data set format. 4. Use Jailer (http://jailer.sourceforge.net/home.htm) - it can export also only a sample of a DB while preserving referential integrity. --> <dataset> <!-- ######### TABLES TO FILL WITH DATA DURING TestCase#setUp() ######### --> <table name="my_test_schema.my_test_table"> <column>id</column> <column>some_text</column> <row> <value>1</value> <value>some text #1, xml must be escaped like in & , ></value> </row> <row> <value>2</value> <value><![CDATA[some xml entities may be here like in &, <>]]></value> </row> <row> <value>3</value> <null /> </row> </table> <!-- ######### TABLES TO CLEAR WITHOUT INSERTING ANY DATA DURING TestCase#setUp() ######### Provide names of the tables whose content shall be dropped prior to running a test method. You don't need to list its columns. --> <!-- <table name="my_test_schema.example_table2" /> --> </dataset>