1 21 22 package org.dbunit.operation; 23 24 import org.dbunit.AbstractDatabaseTest; 25 import org.dbunit.dataset.IDataSet; 26 import org.dbunit.dataset.ITable; 27 import org.dbunit.dataset.xml.XmlDataSet; 28 29 import java.io.File ; 30 import java.io.FileReader ; 31 import java.io.Reader ; 32 33 38 public class CompositeOperationTest extends AbstractDatabaseTest 39 { 40 public CompositeOperationTest(String s) 41 { 42 super(s); 43 } 44 45 public void testExecute() throws Exception 46 { 47 String tableName = "PK_TABLE"; 48 String columnName = "PK0"; 49 Reader in = new FileReader ( 50 new File ("src/xml/compositeOperationTest.xml")); 51 IDataSet xmlDataSet = new XmlDataSet(in); 52 53 ITable tableBefore = createOrderedTable(tableName, columnName); 55 assertEquals("row count before", 3, tableBefore.getRowCount()); 56 assertEquals("before", "0", tableBefore.getValue(0, columnName).toString()); 57 assertEquals("before", "1", tableBefore.getValue(1, columnName).toString()); 58 assertEquals("before", "2", tableBefore.getValue(2, columnName).toString()); 59 60 DatabaseOperation operation = new CompositeOperation( 61 DatabaseOperation.DELETE_ALL, DatabaseOperation.INSERT); 62 operation.execute(_connection, xmlDataSet); 63 64 ITable tableAfter = createOrderedTable(tableName, columnName); 65 assertEquals("row count after", 2, tableAfter.getRowCount()); 66 assertEquals("after", "1", tableAfter.getValue(0, columnName).toString()); 67 assertEquals("after", "3", tableAfter.getValue(1, columnName).toString()); 68 } 69 70 } 71 72 73 74 75 | Popular Tags |