Exemplo n.º 1
0
  @Test
  public void shouldAllowUnregisteringUnusedType() throws Exception {
    ntTemplate.setName(TEST_TYPE_NAME);

    JcrNodeDefinitionTemplate childNode = new JcrNodeDefinitionTemplate(this.context);
    childNode.setDefaultPrimaryTypeName(JcrNtLexicon.FILE.getString(this.registry));
    ntTemplate.getNodeDefinitionTemplates().add(childNode);

    try {
      repoTypeManager.registerNodeType(ntTemplate);
    } catch (Exception ex) {
      fail(ex.getMessage());
    }

    Name typeNameAsName = nameFactory.create(TEST_TYPE_NAME);
    int nodeTypeCount = nodeTypes().getAllNodeTypes().size();
    repoTypeManager.unregisterNodeType(Arrays.asList(new Name[] {typeNameAsName}), true);
    assertThat(nodeTypes().getAllNodeTypes().size(), is(nodeTypeCount - 1));
    assertThat(nodeTypes().getNodeType(typeNameAsName), is(nullValue()));
  }
Exemplo n.º 2
0
  @Test(expected = InvalidNodeTypeDefinitionException.class)
  public void shouldNotAllowUnregisteringDefaultPrimaryType() throws Exception {
    ntTemplate.setName(TEST_TYPE_NAME);

    JcrNodeDefinitionTemplate childNode = new JcrNodeDefinitionTemplate(this.context);
    childNode.setDefaultPrimaryTypeName(JcrNtLexicon.FILE.getString(this.registry));
    ntTemplate.getNodeDefinitionTemplates().add(childNode);

    try {
      repoTypeManager.registerNodeType(ntTemplate);
    } catch (Exception ex) {
      fail(ex.getMessage());
    }

    repoTypeManager.unregisterNodeType(
        Arrays.asList(
            new Name[] {
              JcrNtLexicon.FILE,
            }),
        true);
  }