diff --git a/source/test-java/org/alfresco/repo/dictionary/DictionaryModelTypeTest.java b/source/test-java/org/alfresco/repo/dictionary/DictionaryModelTypeTest.java
index 6f7235267f..3bd9fed846 100644
--- a/source/test-java/org/alfresco/repo/dictionary/DictionaryModelTypeTest.java
+++ b/source/test-java/org/alfresco/repo/dictionary/DictionaryModelTypeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
+ * Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -18,9 +18,12 @@
*/
package org.alfresco.repo.dictionary;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
@@ -56,6 +59,7 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
private static final QName TEST_MODEL_ONE = QName.createQName("{http://www.alfresco.org/test/testmodel1/1.0}testModelOne");
private static final QName TEST_MODEL_TWO = QName.createQName("{http://www.alfresco.org/test/testmodel2/1.0}testModelTwo");
+ private static final QName TEST_MODEL_THREE = QName.createQName("{http://www.alfresco.org/test/testmodel3/1.0}testModelThree");
/** Test model XMLs */
@@ -286,6 +290,52 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
"";
+ public static final String MODEL_THREE_XML =
+ "" +
+
+ " Test model three" +
+ " Alfresco" +
+ " 2005-05-30" +
+ " 1.0" +
+
+ " " +
+ " " +
+ " " +
+ " " +
+
+ " " +
+ " " +
+ " " +
+
+ " " +
+
+ " " +
+ " Base" +
+ " The Base Type" +
+ " cm:content" +
+ " " +
+ " " +
+ " d:text" +
+ " true" +
+ " " +
+ " " +
+ " " +
+
+ " " +
+ " Base" +
+ " The Base Type" +
+ " test3:base" +
+ " " +
+ " " +
+ " true" +
+ " " +
+ " " +
+ " " +
+
+ " " +
+
+ "";
+
/** Services used in tests */
private DictionaryService dictionaryService;
private NamespaceService namespaceService;
@@ -881,4 +931,65 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
}
});
}
+
+ /**
+ * Test for MNT-11653
+ */
+ public void testOverrideMandatoryProperty()
+ {
+ try
+ {
+ // Check that the model has not yet been loaded into the dictionary
+ this.dictionaryService.getModel(TEST_MODEL_THREE);
+ fail("This model has not yet been loaded into the dictionary service");
+ }
+ catch (DictionaryException exception)
+ {
+ // We expect this exception
+ }
+
+ // Check that the namespace is not yet in the namespace service
+ String uri = this.namespaceService.getNamespaceURI("test3");
+ assertNull(uri);
+
+ // Create a model node
+ PropertyMap properties = new PropertyMap(1);
+ properties.put(ContentModel.PROP_MODEL_ACTIVE, true);
+
+ final NodeRef modelNode = this.nodeService.createNode(
+ this.rootNodeRef,
+ ContentModel.ASSOC_CHILDREN,
+ QName.createQName(NamespaceService.ALFRESCO_URI, "dictionaryModels"),
+ ContentModel.TYPE_DICTIONARY_MODEL,
+ properties).getChildRef();
+ assertNotNull(modelNode);
+
+ // Add the model content to the model node
+ ContentWriter contentWriter = this.contentService.getWriter(modelNode, ContentModel.PROP_CONTENT, true);
+ contentWriter.setEncoding("UTF-8");
+ contentWriter.setMimetype(MimetypeMap.MIMETYPE_XML);
+ contentWriter.putContent(MODEL_THREE_XML);
+
+ // End the transaction to force update
+ setComplete();
+ endTransaction();
+
+ // create node using new type
+ final NodeRef node1 = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback()
+ {
+ public NodeRef execute() throws Exception
+ {
+ Map properties = new HashMap<>();
+ properties.put(QName.createQName("http://www.alfresco.org/test/testmodel3/1.0", "prop1"), "testvalue");
+ NodeRef node = nodeService.createNode(
+ rootNodeRef,
+ ContentModel.ASSOC_CHILDREN,
+ QName.createQName("http://www.alfresco.org/model/system/1.0", "node1"),
+ QName.createQName("http://www.alfresco.org/test/testmodel3/1.0", "base-override"),
+ properties).getChildRef();
+ assertNotNull(node);
+ return node;
+ }
+ });
+ }
}