jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r158034 - in incubator/jackrabbit/trunk: applications/test/ src/test/org/apache/jackrabbit/test/api/version/
Date Fri, 18 Mar 2005 08:11:56 GMT
Author: mreutegg
Date: Fri Mar 18 00:11:53 2005
New Revision: 158034

URL: http://svn.apache.org/viewcvs?view=rev&rev=158034
Log:
Added test cases for version storage path and enabled other version test cases which were
commented out.

Added:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java
  (with props)
Modified:
    incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RestoreTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java

Modified: incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties?view=diff&r1=158033&r2=158034
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties (original)
+++ incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties Fri Mar 18
00:11:53 2005
@@ -354,6 +354,11 @@
 javax.jcr.tck.OnParentVersionIgnoreTest.propertyname1=test:ignoreOnParentVersionProp
 javax.jcr.tck.OnParentVersionInitializeTest.propertyname1=test:initializeOnParentVersionProp
 
+# Test class: RestoreTest
+# Test method: testRestoreWithUUIDConflict
+# nodename4 must be the name of a child node with a OPV definition COPY or VERSION
+javax.jcr.tck.RestoreTest.testRestoreWithUUIDConflict.nodename4=test:versionOnParentVersion
+
 # config for nodes that show the indicated OPV behaviour:
 # nodes are added in order to test the versioning behaviour indicated by the test-class name.
 # NOTE:

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RestoreTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RestoreTest.java?view=diff&r1=158033&r2=158034
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RestoreTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RestoreTest.java
Fri Mar 18 00:11:53 2005
@@ -22,6 +22,7 @@
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.OnParentVersionAction;
+import javax.jcr.version.VersionIterator;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.InvalidItemStateException;
@@ -155,10 +156,20 @@
      * @throws RepositoryException
      */
     public void testRestoreInvalidVersion2() throws RepositoryException {
-        Version vNode2 = versionableNode2.checkin();
-        try {
-            versionableNode.restore(vNode2.getName(), true);
+        String invalidName = null;
+        do {
+            invalidName = createRandomString(3);
+            for (VersionIterator it = versionableNode.getVersionHistory().getAllVersions();
it.hasNext();) {
+                Version v = it.nextVersion();
+                if (invalidName.equals(v.getName())) {
+                    invalidName = null;
+                    break;
+                }
+            }
+        } while (invalidName == null);
 
+        try {
+            versionableNode.restore(invalidName, true);
             fail("VersionException expected on Node.restore(String, boolean) if the specified
version is not part of this node's version history.");
         } catch (VersionException e) {
             // ok
@@ -226,21 +237,6 @@
     }
 
     /**
-     * Test if restoring a node with an invalid version name throws a VersionException
-     *
-     * @throws RepositoryException
-     */
-    public void testRestoreWithInvalidVersionName() throws RepositoryException {
-        Version invalidVersion = versionableNode2.checkin();
-        try {
-            versionableNode.restore(invalidVersion.getName(), true);
-            fail("Node.restore(Version, boolean): A VersionException must be thrown if the
specified version does not exists in this node's version history.");
-        } catch (VersionException e) {
-            // success
-        }
-    }
-
-    /**
      * Tests if restoring the <code>Version</code> of an existing node throws
an
      * <code>ItemExistsException</code> if removeExisting is set to FALSE.
      */
@@ -249,16 +245,16 @@
             Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
             // Verify that nodes used for the test have proper opv behaviour
             NodeDef nd = naa.getDefinition();
-            if ( nd.getOnParentVersion() != OnParentVersionAction.COPY || nd.getOnParentVersion()
!= OnParentVersionAction.VERSION ) {
-                throw new NotExecutableException( "Child nodes must have OPV COPY or VERSION
in order to be able to test Node.restore with uuid conflict." );
+            if (nd.getOnParentVersion() != OnParentVersionAction.COPY || nd.getOnParentVersion()
!= OnParentVersionAction.VERSION) {
+                throw new NotExecutableException("Child nodes must have OPV COPY or VERSION
in order to be able to test Node.restore with uuid conflict.");
             }
 
             Version v = versionableNode.checkin();
-            superuser.move( naa.getPath(), versionableNode2.getPath() + "/" + naa.getName()
);
-            versionableNode.restore( v, false );
+            superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
+            versionableNode.restore(v, false);
 
-            fail( "Node.restore( Version, boolean ): An ItemExistsException must be thrown
if the node to be restored already exsits and removeExisting was set to false." );
-        } catch (ItemExistsException e ) {
+            fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown
if the node to be restored already exsits and removeExisting was set to false.");
+        } catch (ItemExistsException e) {
             // success
         }
     }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java?view=diff&r1=158033&r2=158034
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java
Fri Mar 18 00:11:53 2005
@@ -38,18 +38,19 @@
 
         suite.addTestSuite(VersionTest.class);
         suite.addTestSuite(VersionHistoryTest.class);
+        suite.addTestSuite(VersionStorageTest.class);
         suite.addTestSuite(VersionLabelTest.class);
         suite.addTestSuite(CheckoutTest.class);
         suite.addTestSuite(CheckinTest.class);
         suite.addTestSuite(VersionGraphTest.class);
         suite.addTestSuite(RemoveVersionTest.class);
-        //suite.addTestSuite(RestoreTest.class);
-        //suite.addTestSuite(WorkspaceRestoreTest.class);
-        //suite.addTestSuite(OnParentVersionAbortTest.class);
-        //suite.addTestSuite(OnParentVersionComputeTest.class);
-        //suite.addTestSuite(OnParentVersionCopyTest.class);
-        //suite.addTestSuite(OnParentVersionIgnoreTest.class);
-        //suite.addTestSuite(OnParentVersionInitializeTest.class);
+        suite.addTestSuite(RestoreTest.class);
+        suite.addTestSuite(WorkspaceRestoreTest.class);
+        suite.addTestSuite(OnParentVersionAbortTest.class);
+        suite.addTestSuite(OnParentVersionComputeTest.class);
+        suite.addTestSuite(OnParentVersionCopyTest.class);
+        suite.addTestSuite(OnParentVersionIgnoreTest.class);
+        suite.addTestSuite(OnParentVersionInitializeTest.class);
         suite.addTestSuite(GetReferencesNodeTest.class);
         suite.addTestSuite(GetPredecessorsTest.class);
         suite.addTestSuite(GetCreatedTest.class);

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java?view=auto&rev=158034
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java
Fri Mar 18 00:11:53 2005
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api.version;
+
+import java.util.GregorianCalendar;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+/**
+ * <code>VersionStorageTest</code> provides tests regarding {@link
+ * javax.jcr.version.VersionHistory#addVersionLabel(String, String, boolean)}
+ *
+ * @test
+ * @sources VersionStorageTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.VersionStorageTest
+ * @keywords versioning
+ */
+public class VersionStorageTest extends AbstractVersionTest {
+
+    // path to version storage
+    protected String versionStoragePath;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // get versionStorage path
+        versionStoragePath = superuser.getNamespacePrefix(NS_JCR_URI) + ":system/" + superuser.getNamespacePrefix(NS_JCR_URI)
+ ":versionStorage";
+    }
+
+    /**
+     * Entire subtree is protected.
+     */
+    public void testVersionStorageProtected() throws RepositoryException {
+        try {
+            versionableNode.getBaseVersion().setProperty(jcrCreated, GregorianCalendar.getInstance());
+            fail("It should not be possible to modify a subnode/version in version storage.");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+    }
+
+    /**
+     * The full set of version histories in the version storage, though stored
+     * in a single location in the repository, must be reflected in each
+     * workspace as a subtree below the node /jcr:system/jcr:versionStorage.
+     * Entire subtree must be identical across all workspaces and is protected.
+     */
+    public void testVersionStorageIdenticalAcrossAllWorkspaces() throws RepositoryException
{
+        // The superuser session for the second workspace
+        Session superuserW2 = helper.getSuperuserSession(workspaceName);
+
+        // check path to version storage
+        assertTrue("Version strorage must be reflected as a subtree below the node '" + versionStoragePath
+ "'", superuserW2.getRootNode().hasNode(versionStoragePath));
+
+        // check if subnodes in versionStorage are protected
+        try {
+            // try to create a version node
+            Node versionStorageNodeW2 = superuserW2.getRootNode().getNode(versionStoragePath);
+            versionStorageNodeW2.addNode(nodeName1, ntVersion);
+            fail("It should not be possible to add a subnode/version in version storage.");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionStorageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java?view=diff&r1=158033&r2=158034
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java
Fri Mar 18 00:11:53 2005
@@ -54,7 +54,7 @@
         try {
             wSuperuser = helper.getSuperuserSession(workspaceName);
         } catch (RepositoryException e) {
-            fail("Failed to retrieve superuser session for second workspace '"+workspaceName+"':
"+e.getMessage());
+            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
@@ -82,7 +82,7 @@
         try {
             // set node-fields (wTestRoot, wVersionableNode, wVersionableNode2)
             // and check versionable nodes out.
-            wTestRoot = wSuperuser.getNodeByUUID(testRootNode.getUUID());
+            wTestRoot = (Node) wSuperuser.getItem(testRootNode.getPath());
 
             wVersionableNode = wSuperuser.getNodeByUUID(versionableNode.getUUID());
             wVersionableNode.checkout();
@@ -91,7 +91,7 @@
             wVersionableNode2.checkout();
 
         } catch (RepositoryException e) {
-            fail("Failed to setup test environment in workspace: "+e.getMessage());
+            fail("Failed to setup test environment in workspace: " + e.toString());
         }
 
         // create persistent versionable CHILD-node below wVersionableNode in workspace 2



Mime
View raw message