mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
75030: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 71714: Added a event publishing test to WebDAVHelper git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@75358 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -20,11 +20,12 @@ package org.alfresco.repo.webdav;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.alfresco.events.types.ContentReadEvent;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.events.EventPublisherForTestingOnly;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
@@ -32,8 +33,8 @@ import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -52,6 +53,7 @@ public class WebDAVHelperIntegrationTest
|
||||
private NodeRef rootNodeRef;
|
||||
private NodeRef rootFolder;
|
||||
private NodeService nodeService;
|
||||
private EventPublisherForTestingOnly eventPublisher;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpSpring()
|
||||
@@ -73,6 +75,8 @@ public class WebDAVHelperIntegrationTest
|
||||
|
||||
rootFolder = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
|
||||
ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_FOLDER).getChildRef();
|
||||
|
||||
eventPublisher = (EventPublisherForTestingOnly) ctx.getBean("eventPublisher");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,4 +136,26 @@ public class WebDAVHelperIntegrationTest
|
||||
FileInfo found = webDAVHelper.getNodeForPath(rootFolder, "/");
|
||||
assertEquals(rootFolder, found.getNodeRef());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublishEvent()
|
||||
{
|
||||
FileInfo folderInfo = fileFolderService.create(rootFolder, "my_folder", ContentModel.TYPE_FOLDER);
|
||||
FileInfo fileInfo = fileFolderService.create(folderInfo.getNodeRef(), "my_file.txt", ContentModel.TYPE_CONTENT);
|
||||
webDAVHelper.publishReadEvent(fileInfo, "text", 2l, "UTF-8", null);
|
||||
|
||||
List<ContentReadEvent> readEvents = eventPublisher.getQueueByType(ContentReadEvent.class);
|
||||
boolean found = false;
|
||||
for (ContentReadEvent event : readEvents)
|
||||
{
|
||||
if (fileInfo.getNodeRef().getId().equals(event.getNodeId()))
|
||||
{
|
||||
assertEquals(event.getMimeType(),("text"));
|
||||
assertEquals(event.getClient(),Client.webdav);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(found);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user