1 17 package org.alfresco.repo.importer; 18 19 import java.io.InputStream ; 20 import java.io.InputStreamReader ; 21 22 import org.alfresco.repo.security.authentication.AuthenticationComponent; 23 import org.alfresco.service.ServiceRegistry; 24 import org.alfresco.service.cmr.repository.NodeService; 25 import org.alfresco.service.cmr.repository.StoreRef; 26 import org.alfresco.service.cmr.view.ImporterService; 27 import org.alfresco.service.cmr.view.Location; 28 import org.alfresco.util.BaseSpringTest; 29 import org.alfresco.util.debug.NodeStoreInspector; 30 31 32 public class ImporterComponentTest extends BaseSpringTest 33 { 34 private ImporterService importerService; 35 private ImporterBootstrap importerBootstrap; 36 private NodeService nodeService; 37 private StoreRef storeRef; 38 private AuthenticationComponent authenticationComponent; 39 40 41 @Override 42 protected void onSetUpInTransaction() throws Exception 43 { 44 nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName()); 45 importerService = (ImporterService)applicationContext.getBean(ServiceRegistry.IMPORTER_SERVICE.getLocalName()); 46 47 importerBootstrap = (ImporterBootstrap)applicationContext.getBean("spacesBootstrap"); 48 49 this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent"); 50 51 this.authenticationComponent.setSystemUserAsCurrentUser(); 52 53 this.storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); 55 } 56 57 @Override 58 protected void onTearDownInTransaction() throws Exception 59 { 60 authenticationComponent.clearCurrentSecurityContext(); 61 super.onTearDownInTransaction(); 62 } 63 64 public void testImport() 65 throws Exception 66 { 67 InputStream test = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml"); 68 InputStreamReader testReader = new InputStreamReader (test, "UTF-8"); 69 Location location = new Location(storeRef); 70 importerService.importView(testReader, location, null, new ImportTimerProgress()); 71 System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef)); 72 } 73 74 public void testBootstrap() 75 { 76 StoreRef bootstrapStoreRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); 77 importerBootstrap.setStoreUrl(bootstrapStoreRef.toString()); 78 importerBootstrap.bootstrap(); 79 authenticationComponent.setSystemUserAsCurrentUser(); 80 System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, bootstrapStoreRef)); 81 } 82 } 83 84 | Popular Tags |