doSimpleTest(false, 2, 0);
doSimpleTest(false, 0, 2);
}
private void doSimpleTest(boolean newPC, int before, int after) {
OpenJPAEntityManager pm = getPM();
ModRuntimeTest1 pc = new ModRuntimeTest1();
startTx(pm);
pc.setStringField("orig");
pc.setIntField(-11);
//FIXME jthomas - setDateField
//pc.setDateField(randomDate());
pm.persist(pc);
Object oid = pm.getObjectId(pc);
if (!newPC) {
endTx(pm);
pm = getPM();
startTx(pm);
pc = (ModRuntimeTest1) pm.find(ModRuntimeTest1.class, oid);
}
for (int i = 0; i < before; i++) {
pc.setStringField("before" + i);
pc.setIntField(i);
//FIXME jthomas - setDateField
//pc.setDateField(randomDate());
pm.setSavepoint("before" + i);
}
pc.setStringField("value");
pc.setIntField(333);
//FIXME jthomas - setDateField
//pc.setDateField(randomDate());
//Date date = (Date) pc.getDateField().clone();
pm.setSavepoint("test");
for (int i = 0; i < after; i++) {
pc.setStringField("after" + i);
pc.setIntField(i * 10);
//FIXME jthomas - setDateField
//pc.setDateField(randomDate());
pm.setSavepoint("after" + i);
}
pm.rollbackToSavepoint("test");
assertEquals("value", pc.getStringField());
assertEquals(333, pc.getIntField());
//FIXME jthomas - setDateField
//assertEquals(date, pc.getDateField());
endTx(pm);
endEm(pm);
pm = getPM();
pc = (ModRuntimeTest1) pm.find(ModRuntimeTest1.class, oid);
assertEquals("value", pc.getStringField());
assertEquals(333, pc.getIntField());
//FIXME jthomas - setDateField
//assertEquals(date, pc.getDateField());
endEm(pm);