[BAEL-2749] Insertion test with ignore cols

This commit is contained in:
Joao Esperancinha 2020-03-31 13:31:11 +02:00
parent ef19d83db5
commit 07947ce4d6
2 changed files with 23 additions and 0 deletions

View File

@ -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"});
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<CLIENTS id='1' first_name='John' last_name='Jansen'/>
</dataset>