1 17 package org.alfresco.util; 18 19 import org.alfresco.repo.security.authentication.AuthenticationComponent; 20 import org.alfresco.service.cmr.action.ActionService; 21 import org.alfresco.service.cmr.repository.ContentService; 22 import org.alfresco.service.cmr.repository.NodeRef; 23 import org.alfresco.service.cmr.repository.NodeService; 24 import org.alfresco.service.cmr.repository.StoreRef; 25 import org.alfresco.service.cmr.security.AuthenticationService; 26 import org.alfresco.service.transaction.TransactionService; 27 28 37 public abstract class BaseAlfrescoSpringTest extends BaseSpringTest 38 { 39 40 protected NodeService nodeService; 41 42 43 protected ContentService contentService; 44 45 46 protected AuthenticationService authenticationService; 47 48 49 protected StoreRef storeRef; 50 51 52 protected NodeRef rootNodeRef; 53 54 55 protected ActionService actionService; 56 protected TransactionService transactionService; 57 58 61 @Override 62 protected void onSetUpInTransaction() throws Exception 63 { 64 super.onSetUpInTransaction(); 65 66 this.nodeService = (NodeService) this.applicationContext.getBean("nodeService"); 68 this.contentService = (ContentService) this.applicationContext.getBean("contentService"); 69 this.authenticationService = (AuthenticationService) this.applicationContext.getBean("authenticationService"); 70 this.actionService = (ActionService)this.applicationContext.getBean("actionService"); 71 this.transactionService = (TransactionService)this.applicationContext.getBean("transactionComponent"); 72 73 AuthenticationComponent authenticationComponent = (AuthenticationComponent) this.applicationContext 75 .getBean("authenticationComponent"); 76 authenticationComponent.setSystemUserAsCurrentUser(); 77 78 this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); 80 this.rootNodeRef = this.nodeService.getRootNode(this.storeRef); 81 82 83 84 } 85 86 @Override 87 protected void onTearDownInTransaction() throws Exception 88 { 89 authenticationService.clearCurrentSecurityContext(); 90 super.onTearDownInTransaction(); 91 } 92 93 } 94 | Popular Tags |