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
This commit is contained in:
Britt Park
2007-06-20 15:19:02 +00:00
parent b6149b20a2
commit 1073576c12
2 changed files with 41 additions and 0 deletions

View File

@@ -169,6 +169,21 @@ public class AVMLockingServiceImpl implements AVMLockingService
Attribute table = fAttributeService.getAttribute(LOCK_TABLE); Attribute table = fAttributeService.getAttribute(LOCK_TABLE);
if (table != null) 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; return null;
} }
fAttributeService.setAttribute("", LOCK_TABLE, new MapAttributeValue()); fAttributeService.setAttribute("", LOCK_TABLE, new MapAttributeValue());

View File

@@ -25,17 +25,27 @@
package org.alfresco.repo.avm.locking; package org.alfresco.repo.avm.locking;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; 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.repo.security.authentication.AuthenticationComponent;
import org.alfresco.service.cmr.attributes.AttributeService; import org.alfresco.service.cmr.attributes.AttributeService;
import org.alfresco.service.cmr.avm.locking.AVMLock; import org.alfresco.service.cmr.avm.locking.AVMLock;
import org.alfresco.service.cmr.avm.locking.AVMLockingService; 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.AuthenticationService;
import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PersonService; 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 org.springframework.context.support.FileSystemXmlApplicationContext;
import junit.framework.TestCase; import junit.framework.TestCase;
@@ -60,6 +70,12 @@ public class AVMLockingServiceTest extends TestCase
private static AuthenticationComponent fAuthenticationComponent; private static AuthenticationComponent fAuthenticationComponent;
private static NodeService fNodeService;
private static RepoRemote fRepoRemote;
private static NodeRef fWebProject;
/* (non-Javadoc) /* (non-Javadoc)
* @see junit.framework.TestCase#setUp() * @see junit.framework.TestCase#setUp()
*/ */
@@ -76,7 +92,16 @@ public class AVMLockingServiceTest extends TestCase
fAuthenticationService = (AuthenticationService)fContext.getBean("AuthenticationService"); fAuthenticationService = (AuthenticationService)fContext.getBean("AuthenticationService");
fAuthenticationComponent = (AuthenticationComponent)fContext.getBean("AuthenticationComponent"); fAuthenticationComponent = (AuthenticationComponent)fContext.getBean("AuthenticationComponent");
fAuthenticationComponent.setSystemUserAsCurrentUser(); fAuthenticationComponent.setSystemUserAsCurrentUser();
fNodeService = (NodeService)fContext.getBean("NodeService");
fRepoRemote = (RepoRemote)fContext.getBean("RepoRemoteService");
} }
// Set up a fake web project.
NodeRef root = fRepoRemote.getRoot();
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
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. // Set up sample users groups and roles.
fAuthenticationService.createAuthentication("Buffy", "Buffy".toCharArray()); fAuthenticationService.createAuthentication("Buffy", "Buffy".toCharArray());
fPersonService.getPerson("Buffy"); fPersonService.getPerson("Buffy");
@@ -123,6 +148,7 @@ public class AVMLockingServiceTest extends TestCase
fAuthorityService.deleteAuthority("GROUP_Scoobies"); fAuthorityService.deleteAuthority("GROUP_Scoobies");
fAuthorityService.deleteAuthority("ROLE_SUPER_POWERED"); fAuthorityService.deleteAuthority("ROLE_SUPER_POWERED");
fAuthorityService.deleteAuthority("GROUP_vampires"); fAuthorityService.deleteAuthority("GROUP_vampires");
fNodeService.deleteNode(fWebProject);
} }
public void testAll() public void testAll()