| 1 | |
---|
| 2 | {{{ |
---|
| 3 | public class TestDbUnit extends DatabaseTestCase{ |
---|
| 4 | public static final String TABLE_LOGIN = "login"; |
---|
| 5 | private FlatXmlDataSet loadedDataSet; |
---|
| 6 | |
---|
| 7 | protected IDatabaseConnection getConnection() throws Exception{ |
---|
| 8 | Class.forName("com.mysql.jdbc.Driver"); |
---|
| 9 | Connection jdbcConnection = DriverManager.getConnection("jdbc:mysql://locatlhost:3306"); |
---|
| 10 | return new DatabaseConnection(jdbcConnection); |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | protected IDataSet getDataSet() throws Exception{ |
---|
| 14 | loadedDataSet = new FlatXmlDataSet(this.getClass().getResourceAsStream("input.xml")); |
---|
| 15 | return loadedDataSet; |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | public void testCheckLoginDataLoaded() throws Exception{ |
---|
| 19 | assertNotNull(loadedDataSet); |
---|
| 20 | int rowCount = loadedDataSet.getTable(TABLE_LOGIN).getRowCount(); |
---|
| 21 | assertEquals(3,rowCount); |
---|
| 22 | } |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | <dataset> |
---|
| 26 | <login id="1" empcode="E005" loginname="chandan" password="chandan" loginenabled="y"/> |
---|
| 27 | <login id="2" empcode="E006" loginname="chandan" password="chandan" loginenabled="y"/> |
---|
| 28 | <login id="3" empcode="E007" loginname="chandan" password="chandan" loginenabled="y"/> |
---|
| 29 | </dataset> |
---|
| 30 | }}} |