Пример #1
0
  @Test
  @FixFor("MODE-1912")
  public void shouldRemoveMixVersionablePropertiesWhenRemovingMixin() throws Exception {
    Node node = session.getRootNode().addNode("testNode");
    node.addMixin(JcrMixLexicon.VERSIONABLE.getString());
    session.save();

    // mix:referenceable
    assertNotNull(node.getProperty(JcrLexicon.UUID.getString()));
    // mix:simpleVersionable
    assertTrue(node.getProperty(JcrLexicon.IS_CHECKED_OUT.getString()).getBoolean());
    // mix:versionable
    assertNotNull(node.getProperty(JcrLexicon.BASE_VERSION.getString()));
    assertNotNull(node.getProperty(JcrLexicon.VERSION_HISTORY.getString()));
    assertNotNull(node.getProperty(JcrLexicon.PREDECESSORS.getString()));

    node.removeMixin(JcrMixLexicon.VERSIONABLE.getString());
    session.save();

    // mix:referenceable
    assertPropertyIsAbsent(node, JcrLexicon.UUID.getString());
    // mix:simpleVersionable
    assertPropertyIsAbsent(node, JcrLexicon.IS_CHECKED_OUT.getString());
    // mix:versionable
    assertPropertyIsAbsent(node, JcrLexicon.VERSION_HISTORY.getString());
    assertPropertyIsAbsent(node, JcrLexicon.BASE_VERSION.getString());
    assertPropertyIsAbsent(node, JcrLexicon.PREDECESSORS.getString());
  }
Пример #2
0
  @Test
  @FixFor("MODE-1912")
  public void shouldRelinkVersionablePropertiesWhenRemovingAndReaddingMixVersionable()
      throws Exception {
    JcrVersionManager jcrVersionManager = (JcrVersionManager) versionManager;

    Node node = session.getRootNode().addNode("testNode");
    node.addMixin(JcrMixLexicon.VERSIONABLE.getString());
    session.save();
    // create a new version
    jcrVersionManager.checkin("/testNode");
    jcrVersionManager.checkout("/testNode");
    jcrVersionManager.checkin("/testNode");

    JcrVersionHistoryNode originalVersionHistory = jcrVersionManager.getVersionHistory("/testNode");
    Version originalBaseVersion = jcrVersionManager.getBaseVersion("/testNode");

    // remove the mixin
    jcrVersionManager.checkout("/testNode");
    node.removeMixin(JcrMixLexicon.VERSIONABLE.getString());
    session.save();

    // re-create the mixin and check the previous version history & versionable properties have been
    // relinked.
    node.addMixin(JcrMixLexicon.VERSIONABLE.getString());
    session.save();

    // mix:referenceable
    assertNotNull(node.getProperty(JcrLexicon.UUID.getString()));
    // mix:simpleVersionable
    assertTrue(node.getProperty(JcrLexicon.IS_CHECKED_OUT.getString()).getBoolean());
    // mix:versionable
    assertNotNull(node.getProperty(JcrLexicon.BASE_VERSION.getString()));
    assertNotNull(node.getProperty(JcrLexicon.VERSION_HISTORY.getString()));
    assertNotNull(node.getProperty(JcrLexicon.PREDECESSORS.getString()));

    JcrVersionHistoryNode versionHistory = jcrVersionManager.getVersionHistory("/testNode");
    Version baseVersion = jcrVersionManager.getBaseVersion("/testNode");

    // check the actual
    assertEquals(originalVersionHistory.key(), versionHistory.key());
    assertEquals(originalBaseVersion.getCreated(), baseVersion.getCreated());
    assertEquals(originalBaseVersion.getPath(), baseVersion.getPath());
  }