Esempio n. 1
0
  @Test(expected = InvalidNodeTypeDefinitionException.class)
  public void shouldNotAllowOverridingChildNodeFromDifferentAncestors() throws Exception {
    /*
     * testNode
     * testNodeB extends testNode and declares node testChildNode
     * testNodeC extends testNode and declares node testChildNode
     * testNodeD extends testNodeB and testNodeC and overrides testChildNode --> ILLEGAL
     */
    ntTemplate.setName(TEST_TYPE_NAME);
    ntTemplate.setDeclaredSuperTypeNames(
        new String[] {
          "nt:base",
        });

    JcrNodeTypeTemplate nodeBTemplate = new JcrNodeTypeTemplate(this.context);
    nodeBTemplate.setName(TEST_TYPE_NAME + "B");
    nodeBTemplate.setDeclaredSuperTypeNames(new String[] {TEST_TYPE_NAME});

    JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
    child.setName(JcrLexicon.SYSTEM.getString(registry));
    child.setRequiredPrimaryTypeNames(new String[] {"nt:base"});
    nodeBTemplate.getNodeDefinitionTemplates().add(child);

    JcrNodeTypeTemplate nodeCTemplate = new JcrNodeTypeTemplate(this.context);
    nodeCTemplate.setName(TEST_TYPE_NAME + "C");
    nodeCTemplate.setDeclaredSuperTypeNames(new String[] {TEST_TYPE_NAME});

    child = new JcrNodeDefinitionTemplate(this.context);
    child.setName(JcrLexicon.SYSTEM.getString(registry));
    child.setRequiredPrimaryTypeNames(new String[] {"nt:base"});
    nodeCTemplate.getNodeDefinitionTemplates().add(child);

    JcrNodeTypeTemplate nodeDTemplate = new JcrNodeTypeTemplate(this.context);
    nodeDTemplate.setName(TEST_TYPE_NAME + "D");
    nodeDTemplate.setDeclaredSuperTypeNames(
        new String[] {nodeBTemplate.getName(), nodeCTemplate.getName()});

    List<NodeTypeDefinition> templates =
        Arrays.asList(
            new NodeTypeDefinition[] {ntTemplate, nodeBTemplate, nodeCTemplate, nodeDTemplate});
    compareTemplatesToNodeTypes(templates, repoTypeManager.registerNodeTypes(templates));
  }
 @Override
 public void afterEach() throws Exception {
   NodeIterator nodeIterator = session.getRootNode().getNodes();
   while (nodeIterator.hasNext()) {
     Node node = nodeIterator.nextNode();
     if (!JcrLexicon.SYSTEM.getString().equals(node.getName())) {
       node.remove();
     }
   }
   session.save();
   super.afterEach();
 }
Esempio n. 3
0
  @Test(expected = InvalidNodeTypeDefinitionException.class)
  public void shouldNotAllowOverridingProtectedChildNode() throws Exception {
    ntTemplate.setName(TEST_TYPE_NAME);
    ntTemplate.setDeclaredSuperTypeNames(new String[] {"mode:root", "mix:referenceable"});

    JcrNodeDefinitionTemplate child = new JcrNodeDefinitionTemplate(this.context);
    child.setName(JcrLexicon.SYSTEM.getString(registry));
    child.setRequiredPrimaryTypeNames(new String[] {"nt:base"});
    ntTemplate.getNodeDefinitionTemplates().add(child);

    List<NodeTypeDefinition> templates = Arrays.asList(new NodeTypeDefinition[] {ntTemplate});
    compareTemplatesToNodeTypes(templates, repoTypeManager.registerNodeTypes(templates));
  }