org.alfresco.repo.lock
Class JobLockServiceTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.alfresco.repo.lock.JobLockServiceTest
All Implemented Interfaces:
junit.framework.Test

public class JobLockServiceTest
extends junit.framework.TestCase

Tests the high-level capabilities provided by the service implementation. The DAO tests stress the underlying database work, so we only need to deal with deadlock resolution, etc.

Since:
3.2
See Also:
the service being tested, the DAO being indirectly tested

Field Summary
static java.lang.String NAMESPACE
           
 
Constructor Summary
JobLockServiceTest()
           
 
Method Summary
 void setUp()
           
 void testDeadlockPrevention()
          Sets up two threads in a deadlock scenario.
 void testEnforceTxn()
           
 void testLockCallbackReleaseInactive()
           
 void testLockCallbackReleaseSelf()
           
 void testLockCallbackReleaseTimed()
          Lets job "run" for 3 seconds and checks at 2s and 4s.
 void testLockInReadOnly()
          Checks that the lock can be aquired by a read-only transaction i.e.
 void testLockReleaseOnCommit()
          Checks that locks are released on commit
 void testLockReleaseOnRollback()
          Checks that locks are released on rollback
 void testSetUp()
           
 void testSimpleLock()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAMESPACE

public static final java.lang.String NAMESPACE
See Also:
Constant Field Values
Constructor Detail

JobLockServiceTest

public JobLockServiceTest()
Method Detail

setUp

public void setUp()
           throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

testSetUp

public void testSetUp()

testSimpleLock

public void testSimpleLock()

testEnforceTxn

public void testEnforceTxn()

testLockInReadOnly

public void testLockInReadOnly()
                        throws java.lang.Exception
Checks that the lock can be aquired by a read-only transaction i.e. that locking is independent of the outer transaction.

Throws:
java.lang.Exception

testLockReleaseOnCommit

public void testLockReleaseOnCommit()
                             throws java.lang.Exception
Checks that locks are released on commit

Throws:
java.lang.Exception

testLockReleaseOnRollback

public void testLockReleaseOnRollback()
                               throws java.lang.Exception
Checks that locks are released on rollback

Throws:
java.lang.Exception

testDeadlockPrevention

public void testDeadlockPrevention()
                            throws java.lang.Throwable
Sets up two threads in a deadlock scenario. Each of the threads has a long wait timeout for the required locks. If there were a deadlock, the shorter of the the wait times would be how long it would take before one of them is thrown out. Firstly, we check that one of the threads is thrown out. Then we check that the thread is thrown out quickly.

Throws:
java.lang.Throwable

testLockCallbackReleaseInactive

public void testLockCallbackReleaseInactive()
                                     throws java.lang.Exception
Throws:
java.lang.Exception

testLockCallbackReleaseSelf

public void testLockCallbackReleaseSelf()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testLockCallbackReleaseTimed

public void testLockCallbackReleaseTimed()
                                  throws java.lang.Exception
Lets job "run" for 3 seconds and checks at 2s and 4s.

Throws:
java.lang.Exception


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.