DatabaseOperation
類中。在這個示例中,只是通過 清單 4中定義的 MockStrutsTestCase
類型的 setUp()
方法中的一些增強的 fixture 邏輯中的 CLEAN_INSERT
標志來保證干凈的數據集。例如,在清單 8 中,定義了三個方法,分別利用 DbUnit API 把 dbunit-user-seed.xml 文件的內容插入數據庫。
private void executeSetUpOperation() throws Exception{
final IDatabaseConnection connection = this.getConnection();
try{
DatabaseOperation.CLEAN_INSERT.execute(connection, this.getDataSet());
}finally{
connection.close();