From 2ae9cf58e26e510818b7e05eb1498976fc854132 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Fri, 3 Jun 2016 16:07:54 +0000 Subject: [PATCH] Merged 5.2.N (5.2.1) to HEAD (5.2) 125036 cturlica: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1) 124935 arebegea: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2) 124871 cturlica: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4) 124788 adavis: Merged V4.2.6 (4.2.6) to V4.2-BUG-FIX (4.2.7) 124676 arebegea: MNT-15844 : CheckOutCheckInServiceImplTest.testCheckOutPermissions_ALF7680_ALF535 fails on SQL Server - fix the tests by doing the initialization of the test data in a new retrying transaction git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127771 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../coci/CheckOutCheckInServiceImplTest.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/source/test-java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java b/source/test-java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java index e38a9272f9..7ca2782ea3 100644 --- a/source/test-java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java +++ b/source/test-java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java @@ -93,7 +93,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest private CopyService copyService; private PersonService personService; private FileFolderService fileFolderService; - + private AuthenticationComponent authenticationComponent; /** * Data used by the tests */ @@ -144,9 +144,28 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest this.nodeService = serviceRegistry.getNodeService(); // Authenticate as system to create initial test data set - AuthenticationComponent authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent"); + this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent"); authenticationComponent.setSystemUserAsCurrentUser(); - + + RetryingTransactionCallback processInitWork = new RetryingTransactionCallback() + { + public Void execute() throws Throwable + { + initTestData(); + return null; + } + }; + // do the init test data in a new retrying transaction because + // there may be problems with the DB that needs to be retried; + // That is how Alfresco works, it relies on optimistic locking and retries + transactionService.getRetryingTransactionHelper().doInTransaction(processInitWork, false, true); + + } + + private void initTestData() + { + authenticationComponent.setSystemUserAsCurrentUser(); + // Create the store and get the root node reference this.storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); this.rootNodeRef = nodeService.getRootNode(storeRef);