use of org.apache.cayenne.testdo.locking.SimpleLockingTestEntity in project cayenne by apache.
the class OptimisticLockingIT method testFailSimpleLockingOnDelete.
@Test
public void testFailSimpleLockingOnDelete() throws Exception {
createSimpleLockingDataSet();
List<SimpleLockingTestEntity> allObjects = new SelectQuery<>(SimpleLockingTestEntity.class).select(context);
assertEquals(1, allObjects.size());
SimpleLockingTestEntity object = allObjects.get(0);
// change description and save... no optimistic lock failure expected
object.setDescription("second update");
context.commitChanges();
// change row underneath, delete and save... optimistic lock failure expected
createSimpleLockUpdate();
context.deleteObjects(object);
try {
context.commitChanges();
fail("Optimistic lock failure expected.");
} catch (OptimisticLockException ex) {
// optimistic lock failure expected...
}
}
use of org.apache.cayenne.testdo.locking.SimpleLockingTestEntity in project cayenne by apache.
the class OptimisticLockingIT method testSuccessSimpleLockingOnUpdatePrecededByForgetSnapshot.
@Test
public void testSuccessSimpleLockingOnUpdatePrecededByForgetSnapshot() throws Exception {
createSimpleLockingDataSet();
List<SimpleLockingTestEntity> allObjects = new SelectQuery<>(SimpleLockingTestEntity.class).select(context);
assertEquals(1, allObjects.size());
SimpleLockingTestEntity object = allObjects.get(0);
// change description and save... no optimistic lock failure expected
object.setDescription("first update");
context.commitChanges();
context.getObjectStore().getDataRowCache().forgetSnapshot(object.getObjectId());
object.setDescription("second update");
context.commitChanges();
}
use of org.apache.cayenne.testdo.locking.SimpleLockingTestEntity in project cayenne by apache.
the class OptimisticLockingIT method testSuccessSimpleLockingOnUpdatePrecededByInvalidate.
@Test
public void testSuccessSimpleLockingOnUpdatePrecededByInvalidate() throws Exception {
createSimpleLockingDataSet();
List<SimpleLockingTestEntity> allObjects = new SelectQuery<>(SimpleLockingTestEntity.class).select(context);
assertEquals(1, allObjects.size());
SimpleLockingTestEntity object = allObjects.get(0);
// change description and save... no optimistic lock failure expected
object.setDescription("first update");
context.commitChanges();
context.invalidateObjects(object);
object.setDescription("second update");
context.commitChanges();
}
Aggregations