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:
Derek Hulley
2006-01-19 13:10:20 +00:00
parent 1a7f5244ea
commit 5ce4763360

View File

@@ -346,12 +346,21 @@ public class FileFolderServiceImplTest extends TestCase
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);
assertNotNull(parentFolderInfo);
NodeRef parentFolderRef = parentFolderInfo.getNodeRef();
// create a file that already exists
UserTransaction rollbackTxn = null;
try
{
rollbackTxn = transactionService.getNonPropagatingUserTransaction();
rollbackTxn.begin();
fileFolderService.create(parentFolderRef, NAME_L1_FILE_A, ContentModel.TYPE_CONTENT);
fail("Failed to detect duplicate filename");
}
@@ -359,9 +368,15 @@ public class FileFolderServiceImplTest extends TestCase
{
// expected
}
finally
{
rollbackTxn.rollback();
}
// create folder of illegal type
try
{
rollbackTxn = transactionService.getNonPropagatingUserTransaction();
rollbackTxn.begin();
fileFolderService.create(parentFolderRef, "illegal folder", ContentModel.TYPE_SYSTEM_FOLDER);
fail("Illegal type not detected");
}
@@ -369,6 +384,11 @@ public class FileFolderServiceImplTest extends TestCase
{
// expected
}
finally
{
rollbackTxn.rollback();
}
// create a file
FileInfo fileInfo = fileFolderService.create(parentFolderRef, "newFile", ContentModel.TYPE_CONTENT);
// check
@@ -376,6 +396,11 @@ public class FileFolderServiceImplTest extends TestCase
assertFalse("File type expected", fileInfo.isFolder());
}
public void testCreateFile() throws Exception
{
}
public void testCreateInRoot() throws Exception
{
fileFolderService.create(rootNodeRef, "New Folder", ContentModel.TYPE_FOLDER);
@@ -455,9 +480,18 @@ public class FileFolderServiceImplTest extends TestCase
public void testGetReaderWriter() throws Exception
{
// testing a failure
txn.commit();
txn = transactionService.getUserTransaction();
txn.begin();
FileInfo dirInfo = getByName(NAME_L0_FOLDER_A, true);
UserTransaction rollbackTxn = null;
try
{
rollbackTxn = transactionService.getNonPropagatingUserTransaction();
rollbackTxn.begin();
fileFolderService.getWriter(dirInfo.getNodeRef());
fail("Failed to detect content write to folder");
}
@@ -465,6 +499,10 @@ public class FileFolderServiceImplTest extends TestCase
{
// expected
}
finally
{
rollbackTxn.rollback();
}
FileInfo fileInfo = getByName(NAME_L1_FILE_A, false);