Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

99771: Merged 5.0.N (5.0.2) to HEAD-BUG-FIX (5.1/Cloud)
      99702: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.2)
         99655: Reverse Merge V4.2-BUG-FIX (4.2.5)
            << Caused build failures >>
            99553: MNT-12628: Following on from MNT-12501 - Rollback of synchronous transactions is not behaving consistently
               - Added a static variable holding the RollbackOnly state to RetryingTransactionHelper. Currently used by RetryingTransactionInterceptor.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@100498 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-03-27 22:57:20 +00:00
parent ea2418e9be
commit bc6720c6cc
3 changed files with 3 additions and 97 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -703,61 +703,6 @@ public class NodeServiceTest
assertEquals("Expected exact number of reference assocs", 1, childAssocRefs.size());
}
/**
* Test for MNT-12501
*/
@Test public void testRollbackTransaction()
{
final NodeRef workspaceRootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
final String name = GUID.generate();
final NodeRef[] nodes = new NodeRef[2];
// Now create 2 nodes with the same name and swallow the exception inside
RetryingTransactionCallback<Void> newNodeCallback = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
Map<QName, Serializable> props = new HashMap<QName, Serializable>(3);
props.put(ContentModel.PROP_NAME, name);
try
{
NodeRef node1 = nodeService.createNode(
workspaceRootNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NAMESPACE, "duplicate"),
ContentModel.TYPE_FOLDER,
props).getChildRef();
nodes[0] = node1;
NodeRef node2 = nodeService.createNode(
workspaceRootNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NAMESPACE, "duplicate"),
ContentModel.TYPE_FOLDER,
props).getChildRef();
nodes[1] = node2;
}
catch (Exception e)
{
// swallow the exception
}
return null;
}
};
try
{
txnService.getRetryingTransactionHelper().doInTransaction(newNodeCallback);
// The exception is swallowed inside the callback
//fail("Duplicate child node name not detected.");
}
catch (DuplicateChildNodeNameException e)
{
// The exception is swallowed inside the callback
}
assertNotNull("The first node was not created.", nodes[0]);
assertFalse("The node creation should be rolled back.", nodeService.exists(nodes[0]));
assertNull("The duplicate node should not be created.", nodes[1]);
}
private NodeRef setupTestGetChildren(final NodeRef workspaceRootNodeRef, final int numberOfReferences)
{
RetryingTransactionCallback<NodeRef> setupCallback = new RetryingTransactionCallback<NodeRef>()