1 17 package org.alfresco.repo.version; 18 19 import org.alfresco.model.ContentModel; 20 import org.alfresco.service.cmr.repository.ContentReader; 21 import org.alfresco.service.cmr.repository.ContentService; 22 import org.alfresco.service.cmr.repository.ContentWriter; 23 import org.alfresco.service.cmr.repository.NodeRef; 24 import org.alfresco.service.cmr.version.Version; 25 26 31 public class ContentServiceImplTest extends BaseVersionStoreTest 32 { 33 36 private final static String UPDATED_CONTENT = "This content has been updated with a new value."; 37 38 41 private ContentService contentService; 42 43 46 protected void onSetUpInTransaction() throws Exception 47 { 48 super.onSetUpInTransaction(); 49 50 this.contentService = (ContentService)this.applicationContext.getBean("contentService"); 52 } 53 54 57 public void testGetReader() 58 { 59 NodeRef versionableNode = createNewVersionableNode(); 61 62 Version version = createVersion(versionableNode, this.versionProperties); 64 NodeRef versionNodeRef = version.getFrozenStateNodeRef(); 65 66 ContentReader contentReader = this.contentService.getReader(versionNodeRef, ContentModel.PROP_CONTENT); 68 assertNotNull(contentReader); 69 assertEquals(TEST_CONTENT, contentReader.getContentString()); 70 71 ContentWriter contentWriter = this.contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true); 73 assertNotNull(contentWriter); 74 contentWriter.putContent(UPDATED_CONTENT); 75 Version version2 = createVersion(versionableNode, this.versionProperties); 76 NodeRef version2NodeRef = version2.getFrozenStateNodeRef(); 77 78 ContentReader contentReader2 = this.contentService.getReader(version2NodeRef, ContentModel.PROP_CONTENT); 80 assertNotNull(contentReader2); 81 assertEquals(UPDATED_CONTENT, contentReader2.getContentString()); 82 } 83 84 87 public void testGetWriter() 88 { 89 NodeRef versionableNode = createNewVersionableNode(); 91 92 Version version = createVersion(versionableNode, this.versionProperties); 94 95 try 97 { 98 ContentWriter contentWriter = this.contentService.getWriter( 99 version.getFrozenStateNodeRef(), 100 ContentModel.PROP_CONTENT, 101 true); 102 contentWriter.putContent("bobbins"); 103 fail("This operation is not supported."); 104 } 105 catch (Exception exception) 106 { 107 } 109 } 110 } 111 | Popular Tags |