// --------------------------------------------------------------------------------
// Create an object which is associated to the
// --------------------------------------------------------------------------------
Lockable lockable = new Lockable();
lockable.setPath("/test");
lockable.setA1("a1");
lockable.setA2("a2");
ocm.insert(lockable);
ocm.save();
// --------------------------------------------------------------------------------
// Get the object
// --------------------------------------------------------------------------------
lockable = (Lockable) ocm.getObject("/test");
assertNotNull("a is null", lockable);
// --------------------------------------------------------------------------------
// Check if the object is locked
// --------------------------------------------------------------------------------
assertFalse("the object is locked", ocm.isLocked("/test"));
assertNull("Attribute lockowner is not null", lockable.getLockOwner());
// --------------------------------------------------------------------------------
// Lock the object
// --------------------------------------------------------------------------------
Lock lock = ocm.lock("/test", true, false);
// --------------------------------------------------------------------------------
// Check if the object is locked
// --------------------------------------------------------------------------------
assertTrue("the object is not locked", ocm.isLocked("/test"));
// --------------------------------------------------------------------------------
// Unlock the object
// --------------------------------------------------------------------------------
ocm.unlock("/test", lock.getLockToken());
// --------------------------------------------------------------------------------
// Check if the object is locked
// --------------------------------------------------------------------------------
assertFalse("the object is locked", ocm.isLocked("/test"));
// --------------------------------------------------------------------------------
// Lock & update
// --------------------------------------------------------------------------------
lock = ocm.lock("/test", true, false);
assertTrue("the object is not locked", ocm.isLocked("/test"));
lockable = (Lockable) ocm.getObject("/test");
assertNotNull("Attribute lockowner is null", lockable.getLockOwner());
lockable.setA1("new a1 Value");
ocm.update(lockable);
ocm.save();
ocm.unlock("/test", lock.getLockToken());