@Test
@FixFor( "MODE-2142" )
public void shouldNotAllowChangingThePrefixOfUsedNamespaces() throws Exception {

    String prefix = "admb";
    String uri = "http://www.admb.be/modeshape/admb/1.0";
    NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
    // First create a namespace for the nodeType which is going to be added
    registry.registerNamespace(prefix, uri);
    assertThatNamespaceIsRegistered(prefix, uri);
    // Start creating a nodeTypeTemplate, keep it basic.
    NodeTypeTemplate nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate();
    String nodeTypeName = prefix + ":test";
    nodeTypeTemplate.setName(nodeTypeName);
    nodeTypeManager.registerNodeType(nodeTypeTemplate, false);
    try {
        registry.registerNamespace("newPrefix", uri);
        fail("Should not allow changing the prefix of a namespace used by a node type");
    } catch (NamespaceException e) {
        //expected
    }
    nodeTypeManager.unregisterNodeType(nodeTypeName);
    registry.registerNamespace("newPrefix", uri);
    assertThatNamespacePrefixIsNotRegistered(prefix);
    assertThatNamespaceIsRegistered("newPrefix", uri);
}