Example #1
0
  protected void setUp() throws Exception {
    super.setUp();

    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    versionManager.checkout(path);
  }
  protected void setUp() throws Exception {
    super.setUp();

    // get versionStorage path
    versionStoragePath =
        superuser.getNamespacePrefix(NS_JCR_URI)
            + ":system/"
            + superuser.getNamespacePrefix(NS_JCR_URI)
            + ":versionStorage";
  }
 protected void tearDown() throws Exception {
   try {
     // remove all versionable nodes below the test
     versionableNode2.remove();
     wVersionableNode.remove();
     wVersionableNode2.remove();
     wTestRoot.save();
   } finally {
     if (wSuperuser != null) {
       wSuperuser.logout();
       wSuperuser = null;
     }
     version = null;
     version2 = null;
     rootVersion = null;
     versionableNode2 = null;
     wTestRoot = null;
     wVersionableNode = null;
     wVersionableNode2 = null;
     wVersionableChildNode = null;
     wChildVersion = null;
     super.tearDown();
   }
 }
  protected void setUp() throws Exception {
    super.setUp();

    VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
    String path = versionableNode.getPath();
    version = versionManager.checkin(path);
    versionManager.checkout(path);
    version2 = versionManager.checkin(path);
    versionManager.checkout(path);
    rootVersion = versionManager.getVersionHistory(path).getRootVersion();

    // build a second versionable node below the testroot
    try {
      versionableNode2 = createVersionableNode(testRootNode, nodeName2, versionableNodeType);
    } catch (RepositoryException e) {
      fail("Failed to create a second versionable node: " + e.getMessage());
    }
    try {
      wSuperuser = getHelper().getSuperuserSession(workspaceName);
    } catch (RepositoryException e) {
      fail(
          "Failed to retrieve superuser session for second workspace '"
              + workspaceName
              + "': "
              + e.getMessage());
    }

    // test if the required nodes exist in the second workspace if not try to clone them
    try {
      testRootNode.getCorrespondingNodePath(workspaceName);
    } catch (ItemNotFoundException e) {
      // clone testRoot
      wSuperuser.getWorkspace().clone(superuser.getWorkspace().getName(), testRoot, testRoot, true);
    }

    try {
      versionableNode.getCorrespondingNodePath(workspaceName);
    } catch (ItemNotFoundException e) {
      // clone versionable node
      wSuperuser
          .getWorkspace()
          .clone(
              superuser.getWorkspace().getName(),
              versionableNode.getPath(),
              versionableNode.getPath(),
              true);
    }

    try {
      versionableNode2.getCorrespondingNodePath(workspaceName);
    } catch (ItemNotFoundException e) {
      // clone second versionable node
      wSuperuser
          .getWorkspace()
          .clone(
              superuser.getWorkspace().getName(),
              versionableNode2.getPath(),
              versionableNode2.getPath(),
              true);
    }

    try {
      // set node-fields (wTestRoot, wVersionableNode, wVersionableNode2)
      // and check versionable nodes out.
      wTestRoot = (Node) wSuperuser.getItem(testRootNode.getPath());

      wVersionableNode = wSuperuser.getNodeByIdentifier(versionableNode.getIdentifier());
      wVersionableNode
          .getSession()
          .getWorkspace()
          .getVersionManager()
          .checkout(wVersionableNode.getPath());

      wVersionableNode2 = wSuperuser.getNodeByIdentifier(versionableNode2.getIdentifier());
      wVersionableNode2
          .getSession()
          .getWorkspace()
          .getVersionManager()
          .checkout(wVersionableNode2.getPath());

    } catch (RepositoryException e) {
      fail("Failed to setup test environment in workspace: " + e.toString());
    }

    // create persistent versionable CHILD-node below wVersionableNode in workspace 2
    // that is not present in the default workspace.
    try {
      wVersionableChildNode =
          createVersionableNode(wVersionableNode, nodeName4, versionableNodeType);
    } catch (RepositoryException e) {
      fail("Failed to create versionable child node in second workspace: " + e.getMessage());
    }

    // create a version of the versionable child node
    VersionManager wVersionManager =
        wVersionableChildNode.getSession().getWorkspace().getVersionManager();
    String wPath = wVersionableChildNode.getPath();
    wVersionManager.checkout(wPath);
    wChildVersion = wVersionManager.checkin(wPath);
    wVersionManager.checkout(wPath);
  }