[BAEL-2749] Insertion test with ignore cols
This commit is contained in:
parent
ef19d83db5
commit
07947ce4d6
@ -55,4 +55,22 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase {
|
||||
ITable actualTable = databaseDataSet.getTable("CLIENTS");
|
||||
Assertion.assertEquals(expectedTable, actualTable);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAssertByQuery() throws Exception {
|
||||
IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(getClass()
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("expected-user.xml"));
|
||||
ITable expectedTable = expectedDataSet.getTable("CLIENTS");
|
||||
Connection conn = getDataSource().getConnection();
|
||||
conn.createStatement()
|
||||
.executeUpdate(
|
||||
"INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')");
|
||||
ITable actualData = getConnection()
|
||||
.createQueryTable(
|
||||
"result_name",
|
||||
"SELECT * FROM CLIENTS WHERE id='2'");
|
||||
Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[]{"id"});
|
||||
}
|
||||
}
|
||||
|
5
dbunit/src/test/resources/expected-user.xml
Normal file
5
dbunit/src/test/resources/expected-user.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<dataset>
|
||||
<CLIENTS id='1' first_name='John' last_name='Jansen'/>
|
||||
</dataset>
|
Loading…
x
Reference in New Issue
Block a user