mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Tightened up usage of failed transactions
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2146 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -346,12 +346,21 @@ public class FileFolderServiceImplTest extends TestCase
|
|||||||
|
|
||||||
public void testCreateFolder() throws Exception
|
public void testCreateFolder() throws Exception
|
||||||
{
|
{
|
||||||
|
// we are testing failures as well
|
||||||
|
txn.commit();
|
||||||
|
// start a new one
|
||||||
|
txn = transactionService.getNonPropagatingUserTransaction();
|
||||||
|
txn.begin();
|
||||||
|
|
||||||
FileInfo parentFolderInfo = getByName(NAME_L0_FOLDER_A, true);
|
FileInfo parentFolderInfo = getByName(NAME_L0_FOLDER_A, true);
|
||||||
assertNotNull(parentFolderInfo);
|
assertNotNull(parentFolderInfo);
|
||||||
NodeRef parentFolderRef = parentFolderInfo.getNodeRef();
|
NodeRef parentFolderRef = parentFolderInfo.getNodeRef();
|
||||||
// create a file that already exists
|
// create a file that already exists
|
||||||
|
UserTransaction rollbackTxn = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
rollbackTxn = transactionService.getNonPropagatingUserTransaction();
|
||||||
|
rollbackTxn.begin();
|
||||||
fileFolderService.create(parentFolderRef, NAME_L1_FILE_A, ContentModel.TYPE_CONTENT);
|
fileFolderService.create(parentFolderRef, NAME_L1_FILE_A, ContentModel.TYPE_CONTENT);
|
||||||
fail("Failed to detect duplicate filename");
|
fail("Failed to detect duplicate filename");
|
||||||
}
|
}
|
||||||
@@ -359,9 +368,15 @@ public class FileFolderServiceImplTest extends TestCase
|
|||||||
{
|
{
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
rollbackTxn.rollback();
|
||||||
|
}
|
||||||
// create folder of illegal type
|
// create folder of illegal type
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
rollbackTxn = transactionService.getNonPropagatingUserTransaction();
|
||||||
|
rollbackTxn.begin();
|
||||||
fileFolderService.create(parentFolderRef, "illegal folder", ContentModel.TYPE_SYSTEM_FOLDER);
|
fileFolderService.create(parentFolderRef, "illegal folder", ContentModel.TYPE_SYSTEM_FOLDER);
|
||||||
fail("Illegal type not detected");
|
fail("Illegal type not detected");
|
||||||
}
|
}
|
||||||
@@ -369,6 +384,11 @@ public class FileFolderServiceImplTest extends TestCase
|
|||||||
{
|
{
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
rollbackTxn.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
// create a file
|
// create a file
|
||||||
FileInfo fileInfo = fileFolderService.create(parentFolderRef, "newFile", ContentModel.TYPE_CONTENT);
|
FileInfo fileInfo = fileFolderService.create(parentFolderRef, "newFile", ContentModel.TYPE_CONTENT);
|
||||||
// check
|
// check
|
||||||
@@ -376,6 +396,11 @@ public class FileFolderServiceImplTest extends TestCase
|
|||||||
assertFalse("File type expected", fileInfo.isFolder());
|
assertFalse("File type expected", fileInfo.isFolder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreateFile() throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void testCreateInRoot() throws Exception
|
public void testCreateInRoot() throws Exception
|
||||||
{
|
{
|
||||||
fileFolderService.create(rootNodeRef, "New Folder", ContentModel.TYPE_FOLDER);
|
fileFolderService.create(rootNodeRef, "New Folder", ContentModel.TYPE_FOLDER);
|
||||||
@@ -455,9 +480,18 @@ public class FileFolderServiceImplTest extends TestCase
|
|||||||
|
|
||||||
public void testGetReaderWriter() throws Exception
|
public void testGetReaderWriter() throws Exception
|
||||||
{
|
{
|
||||||
|
// testing a failure
|
||||||
|
txn.commit();
|
||||||
|
txn = transactionService.getUserTransaction();
|
||||||
|
txn.begin();
|
||||||
|
|
||||||
FileInfo dirInfo = getByName(NAME_L0_FOLDER_A, true);
|
FileInfo dirInfo = getByName(NAME_L0_FOLDER_A, true);
|
||||||
|
|
||||||
|
UserTransaction rollbackTxn = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
rollbackTxn = transactionService.getNonPropagatingUserTransaction();
|
||||||
|
rollbackTxn.begin();
|
||||||
fileFolderService.getWriter(dirInfo.getNodeRef());
|
fileFolderService.getWriter(dirInfo.getNodeRef());
|
||||||
fail("Failed to detect content write to folder");
|
fail("Failed to detect content write to folder");
|
||||||
}
|
}
|
||||||
@@ -465,6 +499,10 @@ public class FileFolderServiceImplTest extends TestCase
|
|||||||
{
|
{
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
rollbackTxn.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
FileInfo fileInfo = getByName(NAME_L1_FILE_A, false);
|
FileInfo fileInfo = getByName(NAME_L1_FILE_A, false);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user