From 1073576c12be5d1fb444a5e7e6c971d22135acd8 Mon Sep 17 00:00:00 2001 From: Britt Park Date: Wed, 20 Jun 2007 15:19:02 +0000 Subject: [PATCH] Make bootstrap for AVMLockingService more robust. Fixed AVMLockingServiceTest failures. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6035 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../avm/locking/AVMLockingServiceImpl.java | 15 +++++++++++ .../avm/locking/AVMLockingServiceTest.java | 26 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceImpl.java b/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceImpl.java index e882c42fc8..14812e53bf 100644 --- a/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceImpl.java +++ b/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceImpl.java @@ -169,6 +169,21 @@ public class AVMLockingServiceImpl implements AVMLockingService Attribute table = fAttributeService.getAttribute(LOCK_TABLE); if (table != null) { + Attribute stores = fAttributeService.getAttribute(LOCK_TABLE + '/' + STORES); + if (stores == null) + { + fAttributeService.setAttribute(LOCK_TABLE, STORES, new MapAttributeValue()); + } + Attribute users = fAttributeService.getAttribute(LOCK_TABLE + '/' + USERS); + if (users == null) + { + fAttributeService.setAttribute(LOCK_TABLE, USERS, new MapAttributeValue()); +; } + Attribute webProjects = fAttributeService.getAttribute(LOCK_TABLE + '/' + WEB_PROJECTS); + if (webProjects == null) + { + fAttributeService.setAttribute(LOCK_TABLE, WEB_PROJECTS, new MapAttributeValue()); + } return null; } fAttributeService.setAttribute("", LOCK_TABLE, new MapAttributeValue()); diff --git a/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceTest.java b/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceTest.java index 24d5810e2c..c05e8c85e6 100644 --- a/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceTest.java +++ b/source/java/org/alfresco/repo/avm/locking/AVMLockingServiceTest.java @@ -25,17 +25,27 @@ package org.alfresco.repo.avm.locking; +import java.io.Serializable; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import org.alfresco.model.ContentModel; +import org.alfresco.model.WCMAppModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.service.cmr.attributes.AttributeService; import org.alfresco.service.cmr.avm.locking.AVMLock; import org.alfresco.service.cmr.avm.locking.AVMLockingService; +import org.alfresco.service.cmr.remote.RepoRemote; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.PersonService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; import org.springframework.context.support.FileSystemXmlApplicationContext; import junit.framework.TestCase; @@ -60,6 +70,12 @@ public class AVMLockingServiceTest extends TestCase private static AuthenticationComponent fAuthenticationComponent; + private static NodeService fNodeService; + + private static RepoRemote fRepoRemote; + + private static NodeRef fWebProject; + /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ @@ -76,7 +92,16 @@ public class AVMLockingServiceTest extends TestCase fAuthenticationService = (AuthenticationService)fContext.getBean("AuthenticationService"); fAuthenticationComponent = (AuthenticationComponent)fContext.getBean("AuthenticationComponent"); fAuthenticationComponent.setSystemUserAsCurrentUser(); + fNodeService = (NodeService)fContext.getBean("NodeService"); + fRepoRemote = (RepoRemote)fContext.getBean("RepoRemoteService"); } + // Set up a fake web project. + NodeRef root = fRepoRemote.getRoot(); + Map properties = new HashMap(); + properties.put(WCMAppModel.PROP_AVMSTORE, "alfresco"); + fWebProject = fNodeService.createNode(root, ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "alfresco"), + WCMAppModel.TYPE_AVMWEBFOLDER, properties).getChildRef(); // Set up sample users groups and roles. fAuthenticationService.createAuthentication("Buffy", "Buffy".toCharArray()); fPersonService.getPerson("Buffy"); @@ -123,6 +148,7 @@ public class AVMLockingServiceTest extends TestCase fAuthorityService.deleteAuthority("GROUP_Scoobies"); fAuthorityService.deleteAuthority("ROLE_SUPER_POWERED"); fAuthorityService.deleteAuthority("GROUP_vampires"); + fNodeService.deleteNode(fWebProject); } public void testAll()