Added assertPersonCount() functionality for increased robustness.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1784 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Sam Brannen 2009-08-28 09:23:02 +00:00
parent db7751e5ee
commit 94b16a169b
1 changed files with 10 additions and 0 deletions

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());
}