Added assertPersonCount() functionality for increased robustness.

This commit is contained in:
Sam Brannen
2009-08-28 09:23:02 +00:00
parent 66a799552f
commit eda193fc98

View File

@@ -52,6 +52,14 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp
private SessionFactory sessionFactory;
protected int countRowsInPersonTable() {
return countRowsInTable("person");
}
protected void assertPersonCount(int expectedCount) {
assertEquals("Verifying number of rows in the 'person' table.", expectedCount, countRowsInPersonTable());
}
@Before
public void setUp() {
assertInTransaction(true);
@@ -72,7 +80,9 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp
public void saveJuergenWithDriversLicense() {
DriversLicense driversLicense = new DriversLicense(2L, 2222L);
Person juergen = new Person(JUERGEN, driversLicense);
int numRows = countRowsInPersonTable();
personService.save(juergen);
assertPersonCount(numRows + 1);
assertNotNull("Should be able to save and retrieve Juergen", personService.findByName(JUERGEN));
assertNotNull("Juergen's ID should have been set", juergen.getId());
}