jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r772362 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version: GetVersionableUUIDTest.java VersionHistoryTest.java
Date Wed, 06 May 2009 17:04:34 GMT
Author: reschke
Date: Wed May  6 17:04:33 2009
New Revision: 772362

URL: http://svn.apache.org/viewvc?rev=772362&view=rev
Log:
JCR-2058: add TCK tests for more new VersionHistory methods

Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java?rev=772362&r1=772361&r2=772362&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java
Wed May  6 17:04:33 2009
@@ -18,10 +18,12 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionManager;
 
 /**
  * <code>GetVersionableUUIDTest</code> provides test methods covering {@link
- * javax.jcr.version.VersionHistory#getVersionableUUID()}.
+ * VersionHistory#getVersionableUUID()} and {@link VersionHistory#getVersionableIdentifier()}.
  *
  * @test
  * @sources GetVersionableUUIDTest.java
@@ -43,4 +45,19 @@
                 version.getContainingHistory().getVersionableUUID(),
                 versionableNode.getUUID());
     }
+
+    /**
+     * Tests if VersionHistory.getVersionableIdentifier() returns the ID of the
+     * corresponding versionable node.
+     * @since JCR 2.9
+     */
+    public void testGetVersionableIdentifier() throws RepositoryException {
+
+        VersionManager vm = versionableNode.getSession().getWorkspace().getVersionManager();
+        vm.checkpoint(versionableNode.getPath());
+        
+        assertEquals("Method getVersionableIdentifier() must return the identifier of the
corresponding Node.",
+                vm.getVersionHistory(versionableNode.getPath()).getVersionableIdentifier(),
+                versionableNode.getIdentifier());
+    }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java?rev=772362&r1=772361&r2=772362&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
Wed May  6 17:04:33 2009
@@ -16,28 +16,32 @@
  */
 package org.apache.jackrabbit.test.api.version;
 
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.version.Version;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.ItemVisitor;
 import javax.jcr.Node;
-import javax.jcr.RepositoryException;
+import javax.jcr.NodeIterator;
 import javax.jcr.Property;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.ItemNotFoundException;
 import javax.jcr.PropertyIterator;
-import javax.jcr.Value;
 import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
 import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionIterator;
-
-import java.util.HashMap;
-import java.util.GregorianCalendar;
-import java.util.Calendar;
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
+import javax.jcr.version.VersionManager;
 
 
 /**
@@ -159,6 +163,42 @@
     }
 
     /**
+     * Test that {@link VersionHistory#getAllFrozenNodes()} returns an iterator
+     * containing the frozen nodes of all versions that have been created by
+     * {@link VersionManager#checkpoint(String)}.
+     *
+     * @see javax.jcr.version.VersionHistory#getAllFrozenNodes()
+     * @since JCR 2.0
+     */
+    public void testGetAllFrozenNodes() throws RepositoryException {
+
+        VersionManager vm = versionableNode.getSession().getWorkspace().getVersionManager();
+        
+        String path = versionableNode.getPath();
+        int cnt = 2;
+        
+        for (int i = 0; i < cnt; i++) {
+            vm.checkpoint(path);
+        }
+
+        Set frozenIds = new HashSet();
+        for (VersionIterator it = vm.getVersionHistory(path).getAllVersions(); it.hasNext();
) {
+            Version v = it.nextVersion();
+            frozenIds.add(v.getFrozenNode().getIdentifier());
+        }
+        
+        Set test = new HashSet();
+        for (NodeIterator it = vHistory.getAllFrozenNodes(); it.hasNext(); ) {
+            Node n = it.nextNode();
+            assertTrue("Node " + n.getPath() + " must be of type frozen node",
+                 n.isNodeType("nt:frozenNode"));
+            test.add(n.getIdentifier());
+        }
+        
+        assertEquals("getAllFrozenNodes must return the IDs of all frozen nodes", frozenIds,
test);
+    }
+
+    /**
      * Test if UnsupportedRepositoryOperationException is thrown when calling
      * Node.getVersionHistory() on a non-versionable node.
      */



Mime
View raw message