@Test
public void testInsert()throws Exception{
dataSet_Insert=new FlatXmlDataSet(new File("user_insert.xml"));
IDatabaseConnection conn=tester.getConnection();
try{
DatabaseOperation.INSERT.execute(conn, dataSet_Insert);
assert conn.getRowCount("users")==3;
}finally{
conn.close();
}
}
@Test
public void testUpdate()throws Exception{
IDataSet dataSet_Update=new FlatXmlDataSet(new File("user_update.xml"));
IDatabaseConnection conn=tester.getConnection();
IDataSet expect=new FlatXmlDataSet(new File("user_update_expected.xml"));
IDataSet act=tester.getConnection().createDataSet();
try{
DatabaseOperation.UPDATE.execute(conn, dataSet_Update);
System.out.println(act.getTable("users").getRowCount());
System.out.println(act.getTable("users").getValue(act.getTable("users").getRowCount()-2,"last_name"));
assert act.getTable("users").getValue(act.getTable("users").getRowCount()-2,"last_name").toString().equals("shifan");
}finally{
conn.close();
}
}
@AfterClass
public void clearDB() throws Exception{
IDatabaseConnection conn=tester.getConnection();
try{
//数据还原
DatabaseOperation.CLEAN_INSERT.execute(conn, dataSet_init);
}finally{
conn.close();
}
}
}