From 5ce4763360ef0632f8e38690e050270e589eb65d Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Thu, 19 Jan 2006 13:10:20 +0000 Subject: [PATCH] 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 --- .../filefolder/FileFolderServiceImplTest.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java index 2de9f9aa7e..e0938fe6bb 100644 --- a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java +++ b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java @@ -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);