SHARE
TWEET

ContentServiceTest

a guest Jan 23rd, 2017 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.millim.ged.test;
  2.  
  3. import java.io.Serializable;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6.  
  7. import org.alfresco.model.ContentModel;
  8. import org.alfresco.repo.nodelocator.NodeLocatorService;
  9. import org.alfresco.repo.nodelocator.XPathNodeLocator;
  10. import org.alfresco.repo.security.authentication.AuthenticationUtil;
  11. import org.alfresco.service.cmr.repository.ContentReader;
  12. import org.alfresco.service.cmr.repository.ContentService;
  13. import org.alfresco.service.cmr.repository.NodeRef;
  14. import org.alfresco.service.cmr.repository.NodeService;
  15. import org.apache.log4j.Logger;
  16. import org.junit.Test;
  17. import org.junit.runner.RunWith;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.beans.factory.annotation.Qualifier;
  20. import org.springframework.test.context.ContextConfiguration;
  21. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  22.  
  23. import com.tradeshift.test.remote.Remote;
  24. import com.tradeshift.test.remote.RemoteTestRunner;
  25.  
  26. @RunWith(RemoteTestRunner.class)
  27. @Remote(runnerClass=SpringJUnit4ClassRunner.class)
  28. @ContextConfiguration("classpath:alfresco/application-context.xml")
  29. public class MyTest {
  30.    
  31.     private static final String ADMIN_USER_NAME = "admin";
  32.  
  33.     static Logger log = Logger.getLogger(BillFolderAspectTest.class);
  34.  
  35.     private final static String BILL_SMART_FOLDER_JSON_XPATH = "/app:company_home/app:dictionary/app:smart_folders/cm:bil_billFolder.json";
  36.  
  37.     @Autowired
  38.     @Qualifier("NodeService")
  39.     protected NodeService nodeService;
  40.  
  41.     @Autowired
  42.     @Qualifier("nodeLocatorService")
  43.     protected NodeLocatorService nodeLocatorService;
  44.    
  45.     @Autowired
  46.     @Qualifier("contentService")
  47.     protected ContentService contentService;
  48.  
  49.     @Test
  50.     public void testAddFolderInBillFolder() {
  51.         AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER_NAME);
  52.    
  53.         final Map<String,Serializable> params=new HashMap<>();
  54.         params.put(XPathNodeLocator.QUERY_KEY,BILL_SMART_FOLDER_JSON_XPATH);
  55.         NodeRef jsonFile = nodeLocatorService.getNode(XPathNodeLocator.NAME, null, params);
  56.        
  57.         ContentReader contentReader = contentService.getReader(jsonFile, ContentModel.PROP_CONTENT);
  58.         String content = contentReader.getContentString();
  59.        
  60.     }
  61. }
RAW Paste Data
Top