From 88dee4b596f93f49d9869fdb0cf5cb11c3ea5da9 Mon Sep 17 00:00:00 2001 From: Raluca Munteanu Date: Mon, 28 Mar 2016 08:02:11 +0000 Subject: [PATCH] Merged 5.1.N (5.1.2) to 5.2.N (5.2.1) 124492 aleahu: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2) 124466 aleahu: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4) 124434 aleahu: Merged V4.2.6 (4.2.6) to V4.2-BUG-FIX (4.2.7) 124387 amorarasu: MNT-15888: The ImapServiceImplTest fails intermittently on MySQL and MariaDB - The re-authentication is done in a retrying transaction. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@124520 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/imap/ImapServiceImplTest.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/source/test-java/org/alfresco/repo/imap/ImapServiceImplTest.java b/source/test-java/org/alfresco/repo/imap/ImapServiceImplTest.java index 80dbae2b6c..b1aef2b507 100644 --- a/source/test-java/org/alfresco/repo/imap/ImapServiceImplTest.java +++ b/source/test-java/org/alfresco/repo/imap/ImapServiceImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. + * Copyright (C) 2005-2016 Alfresco Software Limited. * * This file is part of Alfresco * @@ -60,6 +60,7 @@ import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; import org.alfresco.repo.node.integrity.IntegrityChecker; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.permissions.AccessDeniedException; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderUtil; @@ -237,6 +238,7 @@ public class ImapServiceImplTest extends TestCase { e.printStackTrace(); } + AuthenticationUtil.clearCurrentSecurityContext(); } private void importInternal(String acpName, NodeRef space) @@ -276,11 +278,18 @@ public class ImapServiceImplTest extends TestCase return present; } - private void reauthenticate(String name, String password) + private void reauthenticate(final String name, final String password) { - authenticationService.invalidateTicket(authenticationService.getCurrentTicket()); - authenticationService.clearCurrentSecurityContext(); - authenticationService.authenticate(name, password.toCharArray()); + transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() + { + public Object execute() + { + authenticationService.invalidateTicket(authenticationService.getCurrentTicket()); + authenticationService.clearCurrentSecurityContext(); + authenticationService.authenticate(name, password.toCharArray()); + return null; + } + }); } public void testGetFolder() throws Exception