Fix ALF-19749: NodeService/CopyService interface changes breaks backwards compatibility with add-ons

- This maintains binary compatibility with extensions build before 4.2
 - e.g.  GOOGLEDOCS-235 Unable to deploy latest Google Docs Enterprise AMPs onto 4.2 (HEAD-QA) 
 - Reversed ALF-19217: NodeService and CopyService APIs return modified flags
   We are back to creating redundant versions when duplicate changes are made to data


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54488 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2013-08-27 11:12:54 +00:00
parent b97ff7bae0
commit 0d781560bf
14 changed files with 119 additions and 525 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -184,212 +184,7 @@ public class NodeServiceTest
{
assertNotNull(rootNodeRef);
}
public void testReturnValueAddAspect()
{
NodeRef testNode = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
assertTrue("Adding a new aspect should return true", nodeService.addAspect(testNode, ContentModel.ASPECT_AUTHOR, null));
assertFalse("Adding the same aspect twice should return false", nodeService.addAspect(testNode, ContentModel.ASPECT_AUTHOR, null));
}
public void testReturnValueSetType()
{
final NodeRef testNode = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
// As the node has cm:auditable aspect by default, setting the type will always return true, see org.alfresco.repo.domain.node.AbstractNodeDAOImpl.updateNodeImpl()
assertTrue("Resetting the type should return true", nodeService.setType(testNode, ContentModel.TYPE_CONTENT));
}
public void testReturnValueRemoveAspect()
{
NodeRef testNode = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
assertFalse("Removing not existing aspect should false", nodeService.removeAspect(testNode, ContentModel.ASPECT_GEOGRAPHIC));
assertTrue("Removing an existing aspect should return true", nodeService.setType(testNode, ContentModel.TYPE_CATEGORY));
}
public void testReturnValueSetProperties()
{
NodeRef testNode = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
assertFalse("Setting the same property should return false", nodeService.setProperties(testNode, Collections.singletonMap(ContentModel.PROP_LOCALE, (Serializable) I18NUtil.getLocale())));
assertTrue("Setting a new property value should return true", nodeService.setProperties(testNode, Collections.singletonMap(ContentModel.PROP_LOCALE, (Serializable)Locale.GERMAN)));
}
public void testReturnValueAddProperties()
{
NodeRef testNode = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
assertFalse("Adding the same property should return false", nodeService.addProperties(testNode, Collections.singletonMap(ContentModel.PROP_LOCALE, (Serializable) I18NUtil.getLocale())));
assertTrue("Adding a new property value should return true", nodeService.setProperties(testNode, Collections.singletonMap(ContentModel.PROP_COUNTER, (Serializable) 1)));
assertTrue("Adding an existing property with new value should return true", nodeService.setProperties(testNode, Collections.singletonMap(ContentModel.PROP_LOCALE, (Serializable)Locale.GERMAN)));
}
public void testReturnValueSetProperty()
{
NodeRef testNode = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
assertFalse("Setting the same property should return false", nodeService.setProperty(testNode, ContentModel.PROP_LOCALE, I18NUtil.getLocale()));
assertTrue("Setting a new property value should return true", nodeService.setProperty(testNode, ContentModel.PROP_COUNTER, 1));
assertTrue("Setting an existing property with new value should return true", nodeService.setProperty(testNode, ContentModel.PROP_LOCALE, Locale.GERMAN));
}
public void testReturnValueSetAssociations()
{
NodeRef testNode1 = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTAINER,
null).getChildRef();
NodeRef testNode2 = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
// the associations are reset, always return true
assertTrue("Setting a new association should return true", nodeService.setAssociations(testNode1, ContentModel.ASSOC_CHILDREN, Collections.singletonList(testNode2)));
}
public void testReturnValueDeleteStore()
{
// create a new store
RetryingTransactionCallback<StoreRef> createStoreWork = new RetryingTransactionCallback<StoreRef>()
{
public StoreRef execute()
{
return nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.nanoTime());
}
};
StoreRef testStore = txnService.getRetryingTransactionHelper().doInTransaction(createStoreWork);
assertTrue("Deleting a store should return true", nodeService.deleteStore(testStore));
}
public void testReturnValueSetChildAssociationIndex()
{
NodeRef container = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_FOLDER,
null).getChildRef();
@SuppressWarnings("unused")
NodeRef contentNode1 = nodeService.createNode(
container,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
@SuppressWarnings("unused")
NodeRef contentNode2 = nodeService.createNode(
container,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
List<ChildAssociationRef> children = nodeService.getChildAssocs(container);
assertTrue("Reset association index should return true", nodeService.setChildAssociationIndex(children.get(0), 0));
assertTrue("Changing association index should return true", nodeService.setChildAssociationIndex(children.get(0), 1));
}
public void testReturnValueDeleteNode()
{
NodeRef container = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_FOLDER,
null).getChildRef();
assertTrue("Deleting the node should return true", nodeService.deleteNode(container));
}
public void testReturnValueRemoveChild()
{
NodeRef container = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_FOLDER,
null).getChildRef();
NodeRef contentNode1 = nodeService.createNode(
container,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
assertTrue("Deleting a child should return true", nodeService.removeChild(container, contentNode1));
}
public void testReturnValueRemoveProperty()
{
NodeRef container = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_FOLDER,
null).getChildRef();
NodeRef contentNode1 = nodeService.createNode(
container,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
assertTrue("Adding a new property value should return true", nodeService.setProperties(contentNode1, Collections.singletonMap(ContentModel.PROP_COUNTER, (Serializable) 1)));
assertTrue("Removing a property should return true", nodeService.removeProperty(contentNode1, ContentModel.PROP_COUNTER));
}
public void testReturnValueRemoveAssociation()
{
NodeRef folder = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_FOLDER,
null).getChildRef();
NodeRef contentNode1 = nodeService.createNode(
folder,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTENT,
null).getChildRef();
NodeRef container = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
ContentModel.TYPE_CONTAINER,
null).getChildRef();
assertFalse("Removing last association should return false", nodeService.removeAssociation(folder, contentNode1, ContentModel.ASSOC_CONTAINS));
nodeService.createAssociation(container, contentNode1, ContentModel.ASSOC_CHILDREN);
assertTrue("Removing an association should return true", nodeService.removeAssociation(container, contentNode1, ContentModel.ASSOC_CHILDREN));
}
@Test public void testLocaleSupport() throws Exception
{
// Ensure that the root node has the default locale