Examples of IEntityLockService


Examples of org.jasig.portal.concurrency.IEntityLockService

public void testServiceConvert() throws Exception
{

    String msg = null;
    boolean valid = false;
    IEntityLockService service = getService();
    int readSecs = 30;
    int writeSecs = 45;

    // Create a READ lock on Group testKeys[3], owned by testIds[0]:
    print("Creating new READ lock");
    IEntityLock lock = service.newLock(GROUP_CLASS, testKeys[3], IEntityLockService.READ_LOCK, testIds[0], readSecs);
    msg = "Testing if new lock is valid";
    valid = service.isValid(lock);
    print(msg);
    assertTrue(msg, valid);

    // Convert the READ lock to a WRITE lock:
    print("Converting READ lock to WRITE");
    service.convert(lock, IEntityLockService.WRITE_LOCK, writeSecs);
    msg = "Testing if converted lock is still valid";
    valid = service.isValid(lock);
    print(msg);
    assertTrue(msg, valid);

    // Convert the WRITE lock back to a READ lock:
    print("Converting WRITE lock to READ");
    service.convert(lock, IEntityLockService.READ_LOCK, readSecs);
    msg = "Testing if converted lock is still valid";
    valid = service.isValid(lock);
    print(msg);
    assertTrue(msg, valid);

    // Now try to create a WRITE lock on the same entity for a different owner.
    IEntityLock duplicateLock = null;
    msg = "Attempting to create a duplicate lock; should be null";
    print(msg);

    try { duplicateLock = service.newLock(GROUP_CLASS, testKeys[3], IEntityLockService.WRITE_LOCK, testIds[1]); }
    catch (LockingException le) {print("Caught exception: " + le.getMessage()); }

    assertNull(msg, duplicateLock);

}
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLockService

*/
public void testServiceLockRenewal() throws Exception
{
    String msg = null;
    boolean valid = false;
    IEntityLockService service = getService();

    msg = "Attempting to renew an old lock";
    print(msg);
    IEntityLock badLock = testLocks[2];
    msg = "Checking if lock was renewed.";
    print(msg);
    try { service.renew(badLock); } catch (Exception ex) {print("Caught Exception: " + ex.getMessage()); }
    assertTrue(msg, ! service.isValid(badLock));

    msg = "Attempting to renew a valid lock";
    print(msg);
    IEntityLock goodLock = testLocks[0];
    msg = "Checking if lock was renewed.";
    print(msg);
    try { service.renew(goodLock); } catch (Exception ex) {print("Caught Exception: " + ex.getMessage()); }
    assertTrue(msg, service.isValid(goodLock));

}
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLockService

    String msg = null;
    boolean valid = false;

    print("Creating new lock");
    IEntityLockService service = getService();
    IEntityLock newLock = service.newLock(GROUP_CLASS, testKeys[3], IEntityLockService.WRITE_LOCK, testIds[0]);
    msg = "Testing if new lock is valid";
    valid = getService().existsInStore(newLock);
    print(msg);
    assertTrue(msg, valid);
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLockService

public void testServiceConvert() throws Exception
{

    String msg = null;
    boolean valid = false;
    IEntityLockService service = getService();
    int readSecs = 30;
    int writeSecs = 45;

    // Create a READ lock on Group testKeys[3], owned by testIds[0]:
    print("Creating new READ lock");
    IEntityLock lock = service.newLock(GROUP_CLASS, testKeys[3], IEntityLockService.READ_LOCK, testIds[0], readSecs);
    msg = "Testing if new lock is valid";
    valid = service.isValid(lock);
    print(msg);
    assertTrue(msg, valid);

    // Convert the READ lock to a WRITE lock:
    print("Converting READ lock to WRITE");
    service.convert(lock, IEntityLockService.WRITE_LOCK, writeSecs);
    msg = "Testing if converted lock is still valid";
    valid = service.isValid(lock);
    print(msg);
    assertTrue(msg, valid);

    // Convert the WRITE lock back to a READ lock:
    print("Converting WRITE lock to READ");
    service.convert(lock, IEntityLockService.READ_LOCK, readSecs);
    msg = "Testing if converted lock is still valid";
    valid = service.isValid(lock);
    print(msg);
    assertTrue(msg, valid);

    // Now try to create a WRITE lock on the same entity for a different owner.
    IEntityLock duplicateLock = null;
    msg = "Attempting to create a duplicate lock; should be null";
    print(msg);

    try { duplicateLock = service.newLock(GROUP_CLASS, testKeys[3], IEntityLockService.WRITE_LOCK, testIds[1]); }
    catch (LockingException le) {print("Caught exception: " + le.getMessage()); }

    assertNull(msg, duplicateLock);

}
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLockService

*/
public void testServiceLockRenewal() throws Exception
{
    String msg = null;
    boolean valid = false;
    IEntityLockService service = getService();

    msg = "Attempting to renew an old lock";
    print(msg);
    IEntityLock badLock = testLocks[2];
    msg = "Checking if lock was renewed.";
    print(msg);
    try { service.renew(badLock); } catch (Exception ex) {print("Caught Exception: " + ex.getMessage()); }
    assertTrue(msg, ! service.isValid(badLock));

    msg = "Attempting to renew a valid lock";
    print(msg);
    IEntityLock goodLock = testLocks[0];
    msg = "Checking if lock was renewed.";
    print(msg);
    try { service.renew(goodLock); } catch (Exception ex) {print("Caught Exception: " + ex.getMessage()); }
    assertTrue(msg, service.isValid(goodLock));

}
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLockService

    String msg = null;
    boolean valid = false;

    print("Creating new lock");
    IEntityLockService service = getService();
    IEntityLock newLock = service.newLock(GROUP_CLASS, testKeys[3], IEntityLockService.WRITE_LOCK, testIds[0]);
    msg = "Testing if new lock is valid";
    valid = getService().existsInStore(newLock);
    print(msg);
    assertTrue(msg, valid);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.