org.opencms.file
Class TestLock

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.opencms.test.OpenCmsTestCase
              extended by org.opencms.file.TestLock
All Implemented Interfaces:
junit.framework.Test

public class TestLock
extends OpenCmsTestCase

Unit tests for lock operation.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.opencms.test.OpenCmsTestCase
OpenCmsTestCase.ConnectionData
 
Field Summary
 
Fields inherited from class org.opencms.test.OpenCmsTestCase
ARTICLE_TYPEID, DB_MYSQL, DB_ORACLE, m_additionalConnection, m_configuration, m_currentResourceStrorage, m_defaultConnection, m_defaultTablespace, m_indexTablespace, m_resourceStorages, m_setupConnection, m_tempTablespace
 
Constructor Summary
TestLock(String arg0)
          Default JUnit constructor.
 
Method Summary
static junit.framework.Test suite()
          Test suite for this test class.
 void testCopyToLockedFolder()
          Tests copying a file to a folder locked by another user.
 void testCreationInLockedFolder()
          Tests creating a new file in a folder locked by another user.
 void testLockFilter()
          Test the lock filter.
 void testLockForBaseOperations()
          Tests lock status of a resource for basic operations.
 void testLockForFile()
          Tests lock status of a file and its siblings.
 void testLockForFolder()
          Tests lock status of a folder and its siblings.
 void testLockForFolderPrelockedExclusive()
          Tests lock status of a folder and its siblings.
 void testLockForFolderPrelockedShared()
          Tests lock status of a folder and its siblings.
 void testLockForSiblings()
          Tests lock status of a resource during sibling creation.
 void testLockInherit()
          Tests an inherited lock in a resource delete scenario.
 void testLockOtherUser()
          Tests a lock set by other user.
 void testLockRequired()
          Ensures that a lock is required for all write/control operations.
 void testLockSteal()
          Tests to steal a lock.
 void testLockWithDeletedNewFiles()
          Tests lock status after a new file has been deleted in offline project.
 void testTempFileCreationInLockedFolder()
          Tests creating a new temporary file in a folder locked by another user.
 
Methods inherited from class org.opencms.test.OpenCmsTestCase
addTestDataPath, assertAce, assertAcl, assertAcl, assertContains, assertContainsNot, assertContent, assertDateContent, assertDateContentAfter, assertDateCreated, assertDateCreatedAfter, assertDateExpired, assertDateLastModified, assertDateLastModifiedAfter, assertDateReleased, assertEquals, assertEquals, assertEquals, assertFilter, assertFilter, assertFilter, assertFilter, assertFlags, assertHistory, assertHistoryForRestored, assertIsFolder, assertIsIdentical, assertIsNotIdentical, assertLock, assertLock, assertLock, assertModifiedInCurrentProject, assertPermissionString, assertProject, assertPropertyChanged, assertPropertyChanged, assertPropertydefinitionExist, assertPropertydefinitions, assertPropertyEqual, assertPropertyNew, assertPropertyNew, assertPropertyRemoved, assertPropertyRemoved, assertRelation, assertResourceId, assertResourceType, assertSiblingCount, assertSiblingCountIncremented, assertState, assertStructureId, assertType, assertUserCreated, assertUserLastModified, assertVersion, checkErrors, createStorage, deleteFile, echo, generateContent, generateContent, generateName, generateProperties, generateResources, generateSetupTestWrapper, generateUsers, getCmsObject, getConnectionName, getDatabaseProduct, getDbProduct, getPreCalculatedState, getReplacer, getSetupDataPath, getSetupDb, getTestDataPath, importData, importResources, importTestResource, initTestDataPath, removeDatabase, removeDatabase, removeOpenCms, removeStorage, resetMapping, restart, restartOpenCms, setMapping, setupDatabase, setupDatabase, setupOpenCms, setupOpenCms, setupOpenCms, setupOpenCms, setupOpenCms, storeResources, storeResources, switchStorage
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestLock

public TestLock(String arg0)
Default JUnit constructor.

Parameters:
arg0 - JUnit parameters
Method Detail

suite

public static junit.framework.Test suite()
Test suite for this test class.

Returns:
the test suite

testCopyToLockedFolder

public void testCopyToLockedFolder()
                            throws Exception
Tests copying a file to a folder locked by another user.

Throws:
Exception - if the test fails

testCreationInLockedFolder

public void testCreationInLockedFolder()
                                throws Exception
Tests creating a new file in a folder locked by another user.

Throws:
Exception - if the test fails

testLockFilter

public void testLockFilter()
                    throws Throwable
Test the lock filter. see bug #1460.

Throws:
Throwable - is something goes wrong

testLockForBaseOperations

public void testLockForBaseOperations()
                               throws Throwable
Tests lock status of a resource for basic operations.

Throws:
Throwable - if something goes wrong

testLockForFile

public void testLockForFile()
                     throws Throwable
Tests lock status of a file and its siblings.

Throws:
Throwable - if something goes wrong

testLockForFolder

public void testLockForFolder()
                       throws Throwable
Tests lock status of a folder and its siblings.

Throws:
Throwable - if something goes wrong

testLockForFolderPrelockedExclusive

public void testLockForFolderPrelockedExclusive()
                                         throws Throwable
Tests lock status of a folder and its siblings.

In this test, the folder has some pre-locked siblings with exclusive locks in it

Throws:
Throwable - if something goes wrong

testLockForFolderPrelockedShared

public void testLockForFolderPrelockedShared()
                                      throws Throwable
Tests lock status of a folder and its siblings.

In this test, the folder has some prelocked siblings with shared locks in it

Throws:
Throwable - if something goes wrong

testLockForSiblings

public void testLockForSiblings()
                         throws Throwable
Tests lock status of a resource during sibling creation.

Throws:
Throwable - if something goes wrong

testLockInherit

public void testLockInherit()
                     throws Throwable
Tests an inherited lock in a resource delete scenario.

Throws:
Throwable - if something goes wrong

testLockOtherUser

public void testLockOtherUser()
                       throws Throwable
Tests a lock set by other user.

Throws:
Throwable - if something goes wrong

testLockRequired

public void testLockRequired()
                      throws Throwable
Ensures that a lock is required for all write/control operations.

Throws:
Throwable - if something goes wrong

testLockSteal

public void testLockSteal()
                   throws Throwable
Tests to steal a lock.

Throws:
Throwable - if something goes wrong

testLockWithDeletedNewFiles

public void testLockWithDeletedNewFiles()
                                 throws Throwable
Tests lock status after a new file has been deleted in offline project.

Issue description: User A creates a new file, but deletes it without ever publishing it. Now user B create a new file with the same name / path. The file was still in the lock manager but for user A, this generated an error for user B.

Solution: Remove new files that are deleted from the lock manager.

Throws:
Throwable - if something goes wrong

testTempFileCreationInLockedFolder

public void testTempFileCreationInLockedFolder()
                                        throws Exception
Tests creating a new temporary file in a folder locked by another user.

Throws:
Exception - if the test fails