From a750e322f700a20c4d5789ae16a6c8cbbd51d11f Mon Sep 17 00:00:00 2001 From: N Smith Date: Tue, 12 Jul 2011 16:08:06 +0000 Subject: [PATCH] Fixed several failing Publishing tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28961 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../AbstractPublishingIntegrationTest.java | 10 ++++++-- .../publishing/PublishEventActionTest.java | 23 +++++++++++-------- .../publishing/PublishWebContentJbpmTest.java | 8 ++----- .../publishing/PublishingEventHelperTest.java | 2 +- .../publishing/PublishingEventProcessor.java | 8 +++++++ 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java b/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java index f42b258866..bf87a071cc 100644 --- a/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java +++ b/source/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java @@ -43,6 +43,7 @@ import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; import org.junit.After; import org.junit.Before; +import org.mockito.Mockito; /** * @author Nick Smith @@ -118,9 +119,14 @@ public abstract class AbstractPublishingIntegrationTest extends BaseSpringTest protected ChannelType mockChannelType() { ChannelType channelType = mock(ChannelType.class); - when(channelType.getId()).thenReturn(channelTypeId); - when(channelType.getChannelNodeType()).thenReturn(TYPE_DELIVERY_CHANNEL); + mockChannelTypeBehaviour(channelType); return channelType; } + protected void mockChannelTypeBehaviour(ChannelType channelType) + { + when(channelType.getId()).thenReturn(channelTypeId); + when(channelType.getChannelNodeType()).thenReturn(TYPE_DELIVERY_CHANNEL); + } + } diff --git a/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java b/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java index a163055869..52db9fdc25 100644 --- a/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishEventActionTest.java @@ -19,11 +19,6 @@ package org.alfresco.repo.publishing; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; -import static junit.framework.Assert.assertTrue; import static org.alfresco.model.ContentModel.ASPECT_GEOGRAPHIC; import static org.alfresco.model.ContentModel.ASPECT_TEMPORARY; import static org.alfresco.model.ContentModel.PROP_CONTENT; @@ -67,6 +62,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.junit.Test; +import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; /** @@ -139,7 +135,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest assertEquals(publishEventNode, assocs.get(0).getChildRef()); } - public void xtestUpdatePublishedNode() throws Exception + public void testUpdatePublishedNode() throws Exception { // Create content node without aspects NodeRef source = createContentNode(contentNodeName, content); @@ -152,8 +148,8 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest // Verify properties set correctly. Map publishedProps = nodeService.getProperties(publishedNode); - assertNull(publishedProps.containsKey(PROP_LATITUDE)); - assertNull(publishedProps.containsKey(PROP_LONGITUDE)); + assertFalse(publishedProps.containsKey(PROP_LATITUDE)); + assertFalse(publishedProps.containsKey(PROP_LONGITUDE)); assertEquals(contentNodeName, publishedProps.get(PROP_NAME)); assertEquals(content, readContent(source)); @@ -235,7 +231,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest } @SuppressWarnings("unchecked") - public void xtestChannelTypePublishIsCalledOnUpdate() throws Exception + public void testChannelTypePublishIsCalledOnUpdate() throws Exception { // Create content node with appropriate aspects added. NodeRef source = createContentNode(contentNodeName, content); @@ -327,7 +323,7 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest } @SuppressWarnings("unchecked") - public void xtestStatusUpdate() throws Exception + public void testStatusUpdate() throws Exception { NodeRef source = createContentNode(contentNodeName, content); @@ -336,6 +332,8 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest StatusUpdate status = queue.createStatusUpdate(message, source, channelName); String url = "http://test/url"; + when(channelType.getNodeUrl(any(NodeRef.class))).thenReturn(url); + when(channelType.canPublishStatusUpdates()).thenReturn(true); publishNode(source, status); @@ -414,6 +412,11 @@ public class PublishEventActionTest extends AbstractPublishingIntegrationTest this.channelType = mockChannelType(); channelService.register(channelType); } + else + { + Mockito.reset(channelType); + mockChannelTypeBehaviour(channelType); + } channelService.createChannel(siteId, channelTypeId, channelName, null); this.channel = channelHelper.getChannelNodeForEnvironment(environment.getNodeRef(), channelName); diff --git a/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java b/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java index 4e2183ff80..cf960f46ff 100644 --- a/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishWebContentJbpmTest.java @@ -92,12 +92,8 @@ public class PublishWebContentJbpmTest extends BaseSpringTest }; } - public void testBlank() throws Exception - { - } - @Test - public void xtestProcessTimers() throws Exception + public void testProcessTimers() throws Exception { final Calendar scheduledTime = Calendar.getInstance(); scheduledTime.add(Calendar.SECOND, 5); @@ -127,7 +123,7 @@ public class PublishWebContentJbpmTest extends BaseSpringTest } @Test - public void xtestProcessPublishPath() throws Exception + public void testProcessPublishPath() throws Exception { // Set Status to IN_PROGRESS nodeService.setProperty(event, PROP_PUBLISHING_EVENT_STATUS, Status.IN_PROGRESS.name()); diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java b/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java index 2cd32d636d..a3ebb8396f 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java @@ -166,7 +166,7 @@ public class PublishingEventHelperTest @SuppressWarnings({ "unchecked", "rawtypes" }) @Test - public void xtestCreateNode() throws Exception + public void testCreateNode() throws Exception { // Mock serializer since this behaviour is already tested in PublishingPackageSerializerTest. ContentWriter writer = mock(ContentWriter.class); diff --git a/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java b/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java index 5bf0bfc7b0..f7f7702556 100644 --- a/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java +++ b/source/java/org/alfresco/repo/publishing/PublishingEventProcessor.java @@ -28,6 +28,7 @@ import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -43,6 +44,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.util.GUID; import org.alfresco.util.ParameterCheck; @@ -194,6 +196,12 @@ public class PublishingEventProcessor // Add new aspects addAspects(publishedNode, newAspects); + + List assocs = nodeService.getChildAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + nodeService.removeChildAssociation(assoc); + } } /**