use of org.dbunit.assertion.DbUnitAssert in project stdlib by petergeneric.
the class DbunitModuleTest method test.
@Test
public void test() throws Exception {
// DB is initially empty
new DbUnitAssert().assertEquals(new FlatXmlDataSetBuilder().build(new StringReader("<dataset><SimpleEntity/><GroupEntity/><simple_entity_join_table/></dataset>")), dataset.get());
// Add some db contents
try (HibernateTransaction tx = txutils.start().withAutoCommit()) {
dao.save(new SimpleEntity(1, "alice", new GroupEntity(1), new GroupEntity(2)));
dao.save(new SimpleEntity(2, "bob"));
dao.save(new SimpleEntity(3, "carol"));
dao.save(new SimpleEntity(4, "dave"));
}
// DB should now have 4 rows
FlatXmlDataSet expected = new FlatXmlDataSetBuilder().build(this.getClass().getResourceAsStream("/com/peterphi/std/guice/hibernatetest/alice-bob-carol-dave-dataset.xml"));
new DbUnitAssert().assertEquals(expected, dataset.get());
}
Aggregations