mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Unit test Suite for DAOs and some extra content clean tests and fallout
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14838 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,7 +27,9 @@ package org.alfresco.repo.content;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.transaction.RollbackException;
|
||||
import javax.transaction.UserTransaction;
|
||||
@@ -791,4 +793,44 @@ public class RoutingContentServiceTest extends TestCase
|
||||
assertNotNull("Should be able to get reader", reader);
|
||||
assertEquals("Unknown mimetype was changed", bogusMimetype, reader.getMimetype());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that node copy and delete behaviour behaves correctly w.r.t. cleanup and shared URLs
|
||||
*/
|
||||
public void testPostCopyContentRetrieval() throws Exception
|
||||
{
|
||||
ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.putContent("Some content");
|
||||
ContentData writerContentData = writer.getContentData();
|
||||
ContentData nodeContentData = (ContentData) nodeService.getProperty(contentNodeRef, ContentModel.PROP_CONTENT);
|
||||
assertNotNull(nodeContentData);
|
||||
assertEquals("ContentData not the same from NodeService and from ContentWriter", writerContentData, nodeContentData);
|
||||
|
||||
Map<QName, Serializable> copyProperties = nodeService.getProperties(contentNodeRef);
|
||||
copyProperties.remove(ContentModel.PROP_NODE_UUID);
|
||||
// Copy the node
|
||||
NodeRef contentCopyNodeRef = nodeService.createNode(
|
||||
rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName(TEST_NAMESPACE, GUID.generate()),
|
||||
ContentModel.TYPE_CONTENT,
|
||||
copyProperties).getChildRef();
|
||||
// Now get and check the ContentData for the copy
|
||||
ContentData copyNodeContentData = (ContentData) nodeService.getProperty(contentCopyNodeRef, ContentModel.PROP_CONTENT);
|
||||
assertNotNull(copyNodeContentData);
|
||||
// The copy should share the same URL even
|
||||
assertEquals("Copied node's cm:content ContentData was different", writerContentData, copyNodeContentData);
|
||||
|
||||
// Delete the first node and ensure that the second valud remains good and the content is editable
|
||||
nodeService.deleteNode(contentNodeRef);
|
||||
copyNodeContentData = (ContentData) nodeService.getProperty(contentCopyNodeRef, ContentModel.PROP_CONTENT);
|
||||
assertNotNull(copyNodeContentData);
|
||||
assertEquals("Post-delete value didn't remain the same", writerContentData, copyNodeContentData);
|
||||
ContentReader copyNodeContentReader = contentService.getReader(contentCopyNodeRef, ContentModel.PROP_CONTENT);
|
||||
assertTrue("Physical content was removed", copyNodeContentReader.exists());
|
||||
|
||||
txn.commit();
|
||||
txn = null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user