Esempio n. 1
0
  @Test(expected = NodeTypeExistsException.class)
  public void shouldNotAllowRedefinitionOfNewTypeIfAllowUpdatesIsFalse() throws Exception {
    Name testTypeName = nameFactory.create(TEST_TYPE_NAME);
    ntTemplate.setName(TEST_TYPE_NAME);
    ntTemplate.setDeclaredSuperTypeNames(new String[] {"nt:base"});

    JcrNodeType testNodeType = repoTypeManager.registerNodeType(ntTemplate);

    assertThat(testNodeType.getName(), is(TEST_TYPE_NAME));
    JcrNodeType nodeTypeFromRepo = nodeTypes().getNodeType(testTypeName);
    assertThat(nodeTypeFromRepo, is(notNullValue()));
    assertThat(nodeTypeFromRepo.getName(), is(TEST_TYPE_NAME));

    testNodeType = repoTypeManager.registerNodeType(ntTemplate);
  }
Esempio n. 2
0
  @Test
  public void shouldAllowDefinitionWithExistingSupertypes() throws Exception {
    Name testTypeName = nameFactory.create(TEST_TYPE_NAME);
    ntTemplate.setName(TEST_TYPE_NAME);
    ntTemplate.setDeclaredSuperTypeNames(new String[] {"nt:base", "mix:referenceable"});

    JcrNodeType testNodeType = repoTypeManager.registerNodeType(ntTemplate);

    assertThat(testNodeType.getName(), is(TEST_TYPE_NAME));
    JcrNodeType nodeTypeFromRepo = nodeTypes().getNodeType(testTypeName);
    assertThat(nodeTypeFromRepo, is(notNullValue()));
    assertThat(nodeTypeFromRepo.getName(), is(TEST_TYPE_NAME));
  }
Esempio n. 3
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()));
  }
Esempio n. 4
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);
  }
Esempio n. 5
0
 @Test(expected = NodeTypeExistsException.class)
 public void shouldNotAllowModificationIfAllowUpdatesIsFalse() throws Exception {
   ntTemplate.setName("nt:base");
   repoTypeManager.registerNodeType(ntTemplate);
 }