public void testRollback() {
DB db = DBFactory.getInstance();
String propertyKey = "testRollback-1";
String testValue = "testRollback-1";
try {
PropertyManager pm = PropertyManager.getInstance();
Property p1 = pm.createPropertyInstance(null, null, null, null, propertyKey, null, null, testValue, null);
pm.saveProperty(p1);
String propertyKey2 = "testRollback-2";
String testValue2 = "testRollback-2";
// name is null => generated DB error => rollback
Property p2 = pm.createPropertyInstance(null, null, null, null, null, null, null, testValue2, null);
pm.saveProperty(p2);
fail("Should generate error for rollback.");
} catch (Exception ex) {
db.closeSession();
}
// check if p1 is rollbacked
db = DBFactory.getInstance();
PropertyManager pm = PropertyManager.getInstance();
Property p =pm.findProperty(null, null, null, null, propertyKey);
this.assertNull("Property.save is NOT rollbacked", p);
}