1 17 package org.alfresco.repo.descriptor; 18 19 import org.alfresco.repo.importer.ImporterBootstrap; 20 import org.alfresco.repo.security.authentication.AuthenticationComponent; 21 import org.alfresco.service.ServiceRegistry; 22 import org.alfresco.service.cmr.repository.NodeService; 23 import org.alfresco.service.cmr.repository.StoreRef; 24 import org.alfresco.service.descriptor.Descriptor; 25 import org.alfresco.service.descriptor.DescriptorService; 26 import org.alfresco.util.BaseSpringTest; 27 import org.alfresco.util.debug.NodeStoreInspector; 28 29 public class DescriptorServiceTest extends BaseSpringTest 30 { 31 private NodeService nodeService; 32 private ImporterBootstrap systemBootstrap; 33 private StoreRef storeRef; 34 private AuthenticationComponent authenticationComponent; 35 36 37 @Override 38 protected void onSetUpInTransaction() throws Exception 39 { 40 nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName()); 41 systemBootstrap = (ImporterBootstrap)applicationContext.getBean("systemBootstrap"); 42 43 storeRef = new StoreRef("system", "Test_" + System.currentTimeMillis()); 44 systemBootstrap.setStoreUrl(storeRef.toString()); 45 systemBootstrap.bootstrap(); 46 47 this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent"); 48 49 this.authenticationComponent.setSystemUserAsCurrentUser(); 50 51 52 53 54 System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef)); 55 } 56 57 @Override 58 protected void onTearDownInTransaction() throws Exception 59 { 60 authenticationComponent.clearCurrentSecurityContext(); 61 super.onTearDownInTransaction(); 62 } 63 64 65 public void testServerDescriptor() 66 { 67 ServiceRegistry registry = (ServiceRegistry)applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); 68 DescriptorService descriptorService = registry.getDescriptorService(); 69 Descriptor serverDescriptor = descriptorService.getServerDescriptor(); 70 71 String major = serverDescriptor.getVersionMajor(); 72 String minor = serverDescriptor.getVersionMinor(); 73 String revision = serverDescriptor.getVersionRevision(); 74 String label = serverDescriptor.getVersionLabel(); 75 String version = major + "." + minor + "." + revision; 76 if (label != null && label.length() > 0) 77 { 78 version += " (" + label + ")"; 79 } 80 81 assertEquals(version, serverDescriptor.getVersion()); 82 83 int schemaVersion = serverDescriptor.getSchema(); 84 assertTrue("Server schema version must be greater than 0", schemaVersion > 0); 85 } 86 87 public void testRepositoryDescriptor() 88 { 89 ServiceRegistry registry = (ServiceRegistry)applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); 90 DescriptorService descriptorService = registry.getDescriptorService(); 91 Descriptor repoDescriptor = descriptorService.getInstalledRepositoryDescriptor(); 92 93 String major = repoDescriptor.getVersionMajor(); 94 String minor = repoDescriptor.getVersionMinor(); 95 String revision = repoDescriptor.getVersionRevision(); 96 String label = repoDescriptor.getVersionLabel(); 97 String version = major + "." + minor + "." + revision; 98 if (label != null && label.length() > 0) 99 { 100 version += " (" + label + ")"; 101 } 102 103 assertEquals(version, repoDescriptor.getVersion()); 104 105 int schemaVersion = repoDescriptor.getSchema(); 106 assertTrue("Repository schema version must be greater than -1", schemaVersion > -1); 107 } 108 109 } 110 | Popular Tags |