1 17 package org.alfresco.util; 18 19 20 import junit.framework.TestCase; 21 22 import org.alfresco.repo.security.authentication.AuthenticationComponent; 23 import org.alfresco.repo.security.authentication.AuthenticationException; 24 import org.alfresco.service.ServiceRegistry; 25 import org.alfresco.service.cmr.action.ActionService; 26 import org.alfresco.service.cmr.repository.ContentService; 27 import org.alfresco.service.cmr.repository.NodeRef; 28 import org.alfresco.service.cmr.repository.NodeService; 29 import org.alfresco.service.cmr.repository.StoreRef; 30 import org.alfresco.service.cmr.security.AuthenticationService; 31 import org.alfresco.service.transaction.TransactionService; 32 import org.springframework.context.ApplicationContext; 33 34 41 public abstract class BaseAlfrescoTestCase extends TestCase 42 { 43 44 public static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); 45 46 47 protected ServiceRegistry serviceRegistry; 48 49 50 protected NodeService nodeService; 51 52 53 protected ContentService contentService; 54 55 56 protected AuthenticationService authenticationService; 57 58 59 protected StoreRef storeRef; 60 61 62 protected NodeRef rootNodeRef; 63 64 65 protected ActionService actionService; 66 protected TransactionService transactionService; 67 68 69 @Override 70 protected void setUp() throws Exception 71 { 72 super.setUp(); 73 this.serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); 75 this.nodeService = (NodeService)ctx.getBean("NodeService"); 77 this.contentService = (ContentService)ctx.getBean("ContentService"); 78 this.authenticationService = (AuthenticationService)ctx.getBean("authenticationService"); 79 this.actionService = (ActionService)ctx.getBean("actionService"); 80 this.transactionService = (TransactionService)ctx.getBean("transactionComponent"); 81 82 AuthenticationComponent authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent"); 84 authenticationComponent.setSystemUserAsCurrentUser(); 85 86 this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); 88 this.rootNodeRef = this.nodeService.getRootNode(this.storeRef); 89 90 91 } 92 93 94 @Override 95 protected void tearDown() throws Exception 96 { 97 authenticationService.clearCurrentSecurityContext(); 98 super.tearDown(); 99 } 100 101 } | Popular Tags |