Undo fix for REPO-1022: MNT-16271. Tests working locally but race conditions are possible.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@133098 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2016-11-24 21:05:13 +00:00
parent b6358642e4
commit 5682ef0c34
2 changed files with 192 additions and 316 deletions

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.site;
import java.io.Serializable;
@@ -1229,7 +1229,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest
}, AuthenticationUtil.getAdminUserName());
// Create a test site
String siteShortName = "testDeleteSite-" + GUID.generate();
String siteShortName = "testUpdateSite";
this.siteService.createSite(TEST_SITE_PRESET, siteShortName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
SiteInfo siteInfo = this.siteService.getSite(siteShortName);
assertNotNull(siteInfo);
@@ -1258,122 +1258,6 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest
assertTrue(authorityService.authorityExists(testGroup));
}
@SuppressWarnings("deprecation")
public void testPurgeSiteSimple()
{
SiteService smallSiteService = (SiteService)this.applicationContext.getBean("siteService");
// Create a test group
final String testGroupName = "siteServiceImplTestGroup_" + GUID.generate();
String testGroup = AuthenticationUtil.runAs(
new AuthenticationUtil.RunAsWork<String>()
{
public String doWork() throws Exception
{
return authorityService.createAuthority(AuthorityType.GROUP, testGroupName);
}
}, AuthenticationUtil.getAdminUserName());
// Create a test site
String siteShortName = "testPurgeSite-" + GUID.generate();
this.siteService.createSite(TEST_SITE_PRESET, siteShortName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
SiteInfo siteInfo = this.siteService.getSite(siteShortName);
assertNotNull(siteInfo);
// Add the test group as a member of the site
this.siteService.setMembership(siteShortName, testGroup, SiteModel.SITE_CONTRIBUTOR);
// Delete the site
this.siteService.deleteSite(siteShortName);
assertNull(this.siteService.getSite(siteShortName));
NodeRef archivedNodeRef = nodeArchiveService.getArchivedNode(siteInfo.getNodeRef());
assertTrue("Deleted sites can be recovered from the Trash.", nodeService.exists(archivedNodeRef));
// Commit these site structures
setComplete();
endTransaction();
// We now do two transactions that will be thrown away to handle the purge use cases
// Now purge the site.
RetryingTransactionCallback<Void> purgeWork = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
// We already check that the authorities remain alive.
nodeArchiveService.purgeArchivedNode(archivedNodeRef); // service call starts a new txn
// Site-related groups should be wiped
assertFalse(authorityService.authorityExists(((SiteServiceImpl)smallSiteService).getSiteGroup(siteShortName, true)));
assertFalse(authorityService.authorityExists(((SiteServiceImpl) smallSiteService).getSiteGroup(siteShortName)));
Set<String> permissions = permissionService.getSettablePermissions(SiteModel.TYPE_SITE);
for (String permission : permissions)
{
String siteRoleGroup = ((SiteServiceImpl)smallSiteService).getSiteRoleGroup(siteShortName, permission, true);
assertFalse(authorityService.authorityExists(siteRoleGroup));
}
// Ensure that the added "normal" groups have not been deleted
assertTrue(authorityService.authorityExists(testGroup));
throw new RuntimeException("Expected $$");
}
};
try
{
transactionService.getRetryingTransactionHelper().doInTransaction(purgeWork);
}
catch (Exception e)
{
if (!e.getMessage().contains("$$"))
{
throw e;
}
}
// Create a new site and ensure that the purge does NOT wipe out the authorities ... but still works otherwise (MNT-16271)
RetryingTransactionCallback<Void> purgeWithExistingWork = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
siteService.createSite(TEST_SITE_PRESET, siteShortName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
// We already check that the authorities remain alive.
nodeArchiveService.purgeArchivedNode(archivedNodeRef); // service call starts a new txn
// Site-related groups should still exist
assertTrue(authorityService.authorityExists(((SiteServiceImpl)smallSiteService).getSiteGroup(siteShortName, true)));
assertTrue(authorityService.authorityExists(((SiteServiceImpl) smallSiteService).getSiteGroup(siteShortName)));
Set<String> permissions = permissionService.getSettablePermissions(SiteModel.TYPE_SITE);
for (String permission : permissions)
{
String siteRoleGroup = ((SiteServiceImpl)smallSiteService).getSiteRoleGroup(siteShortName, permission, true);
assertTrue(authorityService.authorityExists(siteRoleGroup));
}
// Ensure that the added "normal" groups have not been deleted
assertTrue(authorityService.authorityExists(testGroup));
throw new RuntimeException("Expected $$");
}
};
try
{
transactionService.getRetryingTransactionHelper().doInTransaction(purgeWithExistingWork);
}
catch (Exception e)
{
if (!e.getMessage().contains("$$"))
{
throw e;
}
}
// Start a new transaction to keep Spring's sequencing happy
startNewTransaction();
}
public void testIsPublic()
{
RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>()