jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r149525 [1/2] - in incubator/jackrabbit/trunk: ./ applications/test/ applications/test/repository/ applications/test/repository/nodetypes/ applications/test/workspaces/ applications/test/workspaces/default/ applications/test/workspaces/test/ src/java/org/apache/jackrabbit/core/search/lucene/ src/test/org/apache/jackrabbit/test/ src/test/org/apache/jackrabbit/test/api/ src/test/org/apache/jackrabbit/test/api/version/ src/test/org/apache/jackrabbit/test/observation/ src/test/org/apache/jackrabbit/test/search/
Date Wed, 02 Feb 2005 15:58:33 GMT
Author: mreutegg
Date: Wed Feb  2 07:57:27 2005
New Revision: 149525

URL: http://svn.apache.org/viewcvs?view=rev&rev=149525
Log:
Initial checkin of test cases for versioning.

Added:
    incubator/jackrabbit/trunk/applications/test/repository/   (with props)
    incubator/jackrabbit/trunk/applications/test/repository/nodetypes/
    incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml   (with props)
    incubator/jackrabbit/trunk/applications/test/workspaces/
    incubator/jackrabbit/trunk/applications/test/workspaces/default/   (with props)
    incubator/jackrabbit/trunk/applications/test/workspaces/default/workspace.xml
    incubator/jackrabbit/trunk/applications/test/workspaces/test/   (with props)
    incubator/jackrabbit/trunk/applications/test/workspaces/test/workspace.xml
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractOnParentVersionTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckinTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckoutTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionAbortTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionComputeTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionCopyTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionIgnoreTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionInitializeTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RemoveVersionTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RestoreTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionGraphTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/VersionLabelTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceRestoreTest.java   (with props)
Modified:
    incubator/jackrabbit/trunk/applications/test/   (props changed)
    incubator/jackrabbit/trunk/applications/test/repository.xml
    incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
    incubator/jackrabbit/trunk/maven.xml
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/NodeIndexer.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/NodeRemovedTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyAddedTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyChangedTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/observation/PropertyRemovedTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/FulltextQueryTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SQLTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SelectClauseTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/search/SimpleQueryTest.java

Propchange: incubator/jackrabbit/trunk/applications/test/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Feb  2 07:57:27 2005
@@ -1,5 +1,3 @@
 repositories
-workspaces
-repository
 tx
 version

Propchange: incubator/jackrabbit/trunk/applications/test/repository/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Feb  2 07:57:27 2005
@@ -0,0 +1,2 @@
+meta
+namespaces

Modified: incubator/jackrabbit/trunk/applications/test/repository.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repository.xml?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repository.xml (original)
+++ incubator/jackrabbit/trunk/applications/test/repository.xml Wed Feb  2 07:57:27 2005
@@ -122,11 +122,7 @@
             persistence of the workspace:
             class: FQN of class implementing PersistenceManager interface
         -->
-        <PersistenceManager class="org.apache.jackrabbit.core.state.mem.InMemPersistenceManager">
-            <param name="initialCapacity" value="10000"/>
-            <param name="loadFactor" value="0.3"/>
-            <param name="persistent" value="false"/>
-        </PersistenceManager>
+        <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager"/>
         <!--
             Search index and the file system it uses.
         -->
@@ -155,16 +151,12 @@
         </FileSystem>
 
         <!--
-            Configures the perisistence manager to be used for persisting version state.
+            Configures the persistence manager to be used for persisting version state.
             Please note that the current versioning implementation is based on
             a 'normal' persistence manager, but this could change in future
             implementations.
         -->
-        <PersistenceManager class="org.apache.jackrabbit.core.state.mem.InMemPersistenceManager">
-            <param name="initialCapacity" value="10000"/>
-            <param name="loadFactor" value="0.3"/>
-            <param name="persistent" value="false"/>
-        </PersistenceManager>
+        <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager"/>
 
     </Versioning>
 

Added: incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml (added)
+++ incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml Wed Feb  2 07:57:27 2005
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * 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.
+ */
+ -->
+<nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:test="http://www.apache.org/jackrabbit/test" xmlns:mix="http://www.jcp.org/jcr/mix/1.0">
+  <nodeType name="test:versionable" mixin="false" orderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>mix:versionable</supertype>
+      <supertype>nt:base</supertype>
+    </supertypes>
+    <propertyDef name="*" type="String" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false" />
+    <propertyDef name="test:copyOnParentVersionProp" type="String" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false" />
+    <propertyDef name="test:versionOnParentVersionProp" type="String" autoCreate="false" mandatory="false" onParentVersion="VERSION" protected="false" multiple="false" />
+    <propertyDef name="test:initializeOnParentVersionProp" type="String" autoCreate="false" mandatory="false" onParentVersion="INITIALIZE" protected="false" multiple="false" />
+    <propertyDef name="test:computeOnParentVersionProp" type="String" autoCreate="false" mandatory="false" onParentVersion="COMPUTE" protected="false" multiple="false" />
+    <propertyDef name="test:ignoreOnParentVersionProp" type="String" autoCreate="false" mandatory="false" onParentVersion="IGNORE" protected="false" multiple="false" />
+    <propertyDef name="test:abortOnParentVersionProp" type="String" autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false" multiple="false" />
+    <childNodeDef name="*" defaultPrimaryType="" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>nt:base</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+    <childNodeDef name="test:copyOnParentVersion" defaultPrimaryType="nt:unstructured" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>nt:base</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+    <childNodeDef name="test:versionOnParentVersion" defaultPrimaryType="nt:unstructured" autoCreate="false" mandatory="false" onParentVersion="VERSION" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>nt:base</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+    <childNodeDef name="test:initializeOnParentVersion" defaultPrimaryType="nt:unstructured" autoCreate="false" mandatory="false" onParentVersion="INITIALIZE" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>nt:base</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+    <childNodeDef name="test:computeOnParentVersion" defaultPrimaryType="nt:unstructured" autoCreate="false" mandatory="false" onParentVersion="COMPUTE" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>nt:base</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+    <childNodeDef name="test:ignoreOnParentVersion" defaultPrimaryType="nt:unstructured" autoCreate="false" mandatory="false" onParentVersion="IGNORE" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>nt:base</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+    <childNodeDef name="test:abortOnParentVersion" defaultPrimaryType="nt:unstructured" autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>nt:base</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+  </nodeType>
+</nodeTypes>
+

Propchange: incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties (original)
+++ incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties Wed Feb  2 07:57:27 2005
@@ -8,7 +8,7 @@
 # credential configuration
 javax.jcr.tck.superuser.name=superuser
 javax.jcr.tck.superuser.pwd=
-javax.jcr.tck.readwrite.name=superuser
+javax.jcr.tck.readwrite.name=user
 javax.jcr.tck.readwrite.pwd=
 javax.jcr.tck.readonly.name=anonymous
 javax.jcr.tck.readonly.pwd=
@@ -19,12 +19,75 @@
 javax.jcr.tck.nodename1=foo
 javax.jcr.tck.nodename2=bar
 javax.jcr.tck.nodename3=foobar
-javax.jcr.tck.workspacename=default
+javax.jcr.tck.nodename4=myname
+javax.jcr.tck.propertyname1=prop1
+javax.jcr.tck.propertyname2=prop2
+javax.jcr.tck.workspacename=test
+
+# namespace configuration
+javax.jcr.tck.namespaces=test
+javax.jcr.tck.namespaces.test=http://www.apache.org/jackrabbit/test
 
 # sample for per test case config overriding
 # Test class: AddNodeText
 # Test method: testName
 javax.jcr.tck.AddNodeTest.testName.nodename1=myname
+
+# QUERY CONFIGURATION
+
+# Test class: SaveTest
+# Test method: testConstraintViolationException
+# Specified node type must not allow child nodes.
+javax.jcr.tck.SaveTest.testConstraintViolationException.nodetype=nt:query
+
+# VERSIONING CONFIGURATION
+
+# nodetye that is versionable. if it is not, an attempt is made to create versionable nodes
+# by adding a mix:versionable mixin-type.
+# NOTE: javax.jcr.tck.nodetype must define a non-versionable nodetype!
+javax.jcr.tck.version.versionableNodeType=test:versionable
+javax.jcr.tck.version.propertyValue=aPropertyValue
+
+# testroot for the version package
+# the test root must allow versionable and non-versionable nodes being created below
+javax.jcr.tck.version.testroot=/testroot
+
+# 3 nodes (nodeName1, nodeName2, nodeName3 with nt=versionableNodeType / nt=nonVersionableNodeType will be cloned to 2nd workspace
+# nodename1 > used to persistently create versionable node below testroot
+# nodename2 > used to create second versionable node below testroot (used for restore/workspace.restore with uuid-conflict)
+# nodename3 > used to persistently create non-versionable node below testroot
+javax.jcr.tck.version.nodename1=versionableNodeName1
+javax.jcr.tck.version.nodename2=versionableNodeName2
+javax.jcr.tck.version.nodename3=nonVersionableNodeName1
+
+# nodename 4: versionabel child-node of the first versionable node with nodeName1 and nodetype 'versionableNodeType'
+# used for:
+# + creation of a node in the 2nd workspace, that does not exist in the first workspace
+# + creation of a node in the 2nd workspace, in order to test uuid-conflicts with Workspace.restore.
+# + creation of a sub-node in the default workspace, in order to test uuid-conflicts with Node.restore.
+# + NOTE: the nodetype with 'versionableNodeType' must define its children nodes to either have COPY or VERSION
+#         OPV behaviour in order to successfully test Node.restore and Workspace.restore with uuid conflict.
+javax.jcr.tck.version.nodename4=childNodeName
+
+# path to existing String-properties and a new value for the property, that allows to test the indicated OPV behaviour
+javax.jcr.tck.OnParentVersionAbortTest.propertyname1=test:abortOnParentVersionProp
+javax.jcr.tck.OnParentVersionComputeTest.propertyname1=test:computeOnParentVersionProp
+javax.jcr.tck.OnParentVersionCopyTest.propertyname1=test:copyOnParentVersionProp
+javax.jcr.tck.OnParentVersionIgnoreTest.propertyname1=test:ignoreOnParentVersionProp
+javax.jcr.tck.OnParentVersionInitializeTest.propertyname1=test:initializeOnParentVersionProp
+
+# 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:
+# - nodename4 is uses as name for the childnode
+# - nodetype is used as nodetype name for the childnode
+# - the specified child node is created below nodename1 with versionableNodeType
+#   the versionableNodeType and/or nodename1 may be overwritten with the individual
+#   testclass below.
+javax.jcr.tck.OnParentVersionCopyTest.nodename4=test:copyOnParentVersion
+javax.jcr.tck.OnParentVersionCopyTest.nodetype=nt:unstructured
+javax.jcr.tck.OnParentVersionAbortTest.nodename4=test:abortOnParentVersion
+javax.jcr.tck.OnParentVersionAbortTest.nodetype=nt:unstructured
 
 # repository name
 org.apache.jackrabbit.repository.config=applications/test/repository.xml

Propchange: incubator/jackrabbit/trunk/applications/test/workspaces/default/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Feb  2 07:57:27 2005
@@ -0,0 +1,3 @@
+blobs
+data
+index

Added: incubator/jackrabbit/trunk/applications/test/workspaces/default/workspace.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/workspaces/default/workspace.xml?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/workspaces/default/workspace.xml (added)
+++ incubator/jackrabbit/trunk/applications/test/workspaces/default/workspace.xml Wed Feb  2 07:57:27 2005
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace name="default">
+  <!--
+      virtual file system of the workspace:
+      class: FQN of class implementing FileSystem interface
+  -->
+  <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+    <param name="path" value="${wsp.home}" />
+  </FileSystem>
+  <!--
+      persistence of the workspace:
+      class: FQN of class implementing PersistenceManager interface
+  -->
+  <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager"/>
+  <!--
+      Search index and the file system it uses.
+  -->
+  <SearchIndex class="org.apache.jackrabbit.core.search.lucene.SearchIndex">
+    <param name="useCompoundFile" value="true" />
+    <param name="minMergeDocs" value="1000" />
+    <param name="maxMergeDocs" value="10000" />
+    <param name="mergeFactor" value="10" />
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+      <param name="path" value="${wsp.home}/index" />
+    </FileSystem>
+  </SearchIndex>
+</Workspace>
+

Propchange: incubator/jackrabbit/trunk/applications/test/workspaces/test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Feb  2 07:57:27 2005
@@ -0,0 +1,3 @@
+blobs
+data
+index

Added: incubator/jackrabbit/trunk/applications/test/workspaces/test/workspace.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/workspaces/test/workspace.xml?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/workspaces/test/workspace.xml (added)
+++ incubator/jackrabbit/trunk/applications/test/workspaces/test/workspace.xml Wed Feb  2 07:57:27 2005
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace name="test">
+  <!--
+      virtual file system of the workspace:
+      class: FQN of class implementing FileSystem interface
+  -->
+  <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+    <param name="path" value="${wsp.home}" />
+  </FileSystem>
+  <!--
+      persistence of the workspace:
+      class: FQN of class implementing PersistenceManager interface
+  -->
+  <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager"/>
+  <!--
+      Search index and the file system it uses.
+  -->
+  <SearchIndex class="org.apache.jackrabbit.core.search.lucene.SearchIndex">
+    <param name="useCompoundFile" value="true" />
+    <param name="minMergeDocs" value="1000" />
+    <param name="maxMergeDocs" value="10000" />
+    <param name="mergeFactor" value="10" />
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+      <param name="path" value="${wsp.home}/index" />
+    </FileSystem>
+  </SearchIndex>
+</Workspace>
+

Modified: incubator/jackrabbit/trunk/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/maven.xml?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/maven.xml (original)
+++ incubator/jackrabbit/trunk/maven.xml Wed Feb  2 07:57:27 2005
@@ -56,10 +56,20 @@
    
    <!-- deletes the test data -->
    <goal name="test:clean">
-      <ant:delete dir="applications/test/repository"/>
+      <ant:delete includeEmptyDirs="true">
+         <ant:fileset dir="applications/test/repository">
+            <ant:include name="**/*"/>
+            <ant:exclude name="**/custom_nodetypes.xml"/>
+         </ant:fileset>
+      </ant:delete>
+      <ant:delete includeEmptyDirs="true">
+         <ant:fileset dir="applications/test/workspaces">
+            <ant:include name="**/*"/>
+            <ant:exclude name="**/workspace.xml"/>
+         </ant:fileset>
+      </ant:delete>      
       <ant:delete dir="applications/test/tx"/>
       <ant:delete dir="applications/test/version"/>
-      <ant:delete dir="applications/test/workspaces"/>
    </goal>
    
    <postGoal name="java:prepare-filesystem">

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/NodeIndexer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/NodeIndexer.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/NodeIndexer.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/NodeIndexer.java Wed Feb  2 07:57:27 2005
@@ -147,7 +147,10 @@
                     }
                 } else {
                     // single value
-                    addValue(doc, values[0], propState.getName(), false);
+                    // do we have a value at all?
+                    if (values.length == 1) {
+                        addValue(doc, values[0], propState.getName(), false);
+                    }
                 }
             } catch (NoSuchItemStateException e) {
                 throw new RepositoryException("Error while indexing node: " + node.getUUID(), e);

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java Wed Feb  2 07:57:27 2005
@@ -20,6 +20,9 @@
 import javax.jcr.Session;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Repository;
+import javax.jcr.NamespaceException;
 import java.util.StringTokenizer;
 
 /**
@@ -32,13 +35,65 @@
      */
     public static RepositoryHelper helper = new RepositoryHelper();
 
-    protected static final String JCR_PRIMARY_TYPE = "jcr:primaryType";
+    /**
+     * Namespace URI for jcr prefix.
+     */
+    public static final String NS_JCR_URI = "http://www.jcp.org/jcr/1.0";
+
+    /**
+     * Namespace URI for nt prefix.
+     */
+    public static final String NS_NT_URI = "http://www.jcp.org/jcr/nt/1.0";
+
+    /**
+     * Namespace URI for mix prefix.
+     */
+    public static final String NS_MIX_URI = "http://www.jcp.org/jcr/mix/1.0";
+
+    /**
+     * Namespace URI for sv prefix
+     */
+    public static final String NS_SV_URI = "http://www.jcp.org/jcr/sv/1.0";
+
+    /**
+     * JCR Name jcr:primaryType using the namespace resolver of the current session.
+     */
+    protected String jcrPrimaryType;
+
+    /**
+     * JCR Name jcr:predecessors using the namespace resolver of the current session.
+     */
+    protected String jcrPredecessors;
+
+    /**
+     * JCR Name jcr:baseVersion using the namespace resolver of the current session.
+     */
+    protected String jcrBaseVersion;
+
+    /**
+     * JCR Name nt:base using the namespace resolver of the current session.
+     */
+    protected String ntBase;
+
+    /**
+     * JCR Name mix:referenceable using the namespace resolver of the current session.
+     */
+    protected String mixReferenceable;
 
-    protected static final String NT_UNSTRUCTURED = "nt:unstructured";
+    /**
+     * JCR Name mix:versionable using the namespace resolver of the current session.
+     */
+    protected String mixVersionable;
 
-    protected static final String MIX_REFERENCABLE = "mix:referencable";
+    /**
+     * JCR Name mix:lockable using the namespace resolver of the current session.
+     */
+    protected String mixLockable;
 
-    protected static final String NT_BASE = "nt:base";
+    /**
+     * JCR Name nt:query using the namespace resolver of the current session.
+     */
+    protected String ntQuery;
 
     /**
      * Relative path to the test root node.
@@ -71,6 +126,21 @@
     protected String nodeName3;
 
     /**
+     * Name of a node that will be created during a test case.
+     */
+    protected String nodeName4;
+
+    /**
+     * Name of a property that will be used during a test case.
+     */
+    protected String propertyName1;
+
+    /**
+     * Name of a property that will be used during a test case.
+     */
+    protected String propertyName2;
+
+    /**
      * Name of a workspace to use instead of the default workspace.
      */
     protected String workspaceName;
@@ -107,12 +177,55 @@
         if (nodeName3 == null) {
             fail("Property '" + RepositoryStub.PROP_NODE_NAME3 + "' is not defined.");
         }
+        nodeName4 = getProperty(RepositoryStub.PROP_NODE_NAME4);
+        if (nodeName4 == null) {
+            fail("Property '" + RepositoryStub.PROP_NODE_NAME4 + "' is not defined.");
+        }
+        propertyName1 = getProperty(RepositoryStub.PROP_PROP_NAME1);
+        if (propertyName1 == null) {
+            fail("Property '" + RepositoryStub.PROP_PROP_NAME1 + "' is not defined.");
+        }
+        propertyName2 = getProperty(RepositoryStub.PROP_PROP_NAME2);
+        if (propertyName2 == null) {
+            fail("Property '" + RepositoryStub.PROP_PROP_NAME2 + "' is not defined.");
+        }
         workspaceName = getProperty(RepositoryStub.PROP_WORKSPACE_NAME);
         if (workspaceName == null) {
             fail("Property '" + RepositoryStub.PROP_WORKSPACE_NAME + "' is not defined.");
         }
 
         superuser = helper.getSuperuserSession();
+
+        // setup some common names
+        jcrPrimaryType = superuser.getNamespacePrefix(NS_JCR_URI) + ":primaryType";
+        jcrPredecessors = superuser.getNamespacePrefix(NS_JCR_URI) + ":predecessors";
+        jcrBaseVersion = superuser.getNamespacePrefix(NS_JCR_URI) + ":baseVersion";
+        ntBase = superuser.getNamespacePrefix(NS_NT_URI) + ":base";
+        mixReferenceable = superuser.getNamespacePrefix(NS_MIX_URI) + ":referenceable";
+        mixVersionable = superuser.getNamespacePrefix(NS_MIX_URI) + ":versionable";
+        mixLockable = superuser.getNamespacePrefix(NS_MIX_URI) + ":lockable";
+        ntQuery = superuser.getNamespacePrefix(NS_NT_URI) + ":query";
+
+        // setup custom namespaces
+        if (helper.getRepository().getDescriptor(Repository.LEVEL_2_SUPPORTED) != null) {
+            NamespaceRegistry nsReg = superuser.getWorkspace().getNamespaceRegistry();
+            String namespaces = getProperty(RepositoryStub.PROP_NAMESPACES);
+            if (namespaces != null) {
+                String[] prefixes = namespaces.split(" ");
+                for (int i = 0; i < prefixes.length; i++) {
+                    String uri = getProperty(RepositoryStub.PROP_NAMESPACES + "." + prefixes[i]);
+                    if (uri != null) {
+                        try {
+                            nsReg.getPrefix(uri);
+                        } catch (NamespaceException e) {
+                            // not yet registered
+                            nsReg.registerNamespace(prefixes[i], uri);
+                        }
+                    }
+                }
+            }
+        }
+
         Node root = superuser.getRootNode();
         if (root.hasNode(testPath)) {
             // clean test root

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java Wed Feb  2 07:57:27 2005
@@ -67,7 +67,15 @@
 
     public static final String PROP_NODE_NAME3 = "nodename3";
 
+    public static final String PROP_NODE_NAME4 = "nodename4";
+
+    public static final String PROP_PROP_NAME1 = "propertyname1";
+
+    public static final String PROP_PROP_NAME2 = "propertyname2";
+
     public static final String PROP_WORKSPACE_NAME = "workspacename";
+
+    public static final String PROP_NAMESPACES = "namespaces";
 
     protected final Properties environment;
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java?view=diff&r1=149524&r2=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java Wed Feb  2 07:57:27 2005
@@ -120,7 +120,7 @@
     public void testConstraintViolation() throws RepositoryException {
         try {
             Node rootNode = superuser.getRootNode();
-            String propPath = testPath + "/" + JCR_PRIMARY_TYPE;
+            String propPath = testPath + "/" + jcrPrimaryType;
             rootNode.addNode(propPath + "/" + nodeName1, testNodeType);
             fail("Expected ConstraintViolationException.");
         } catch (ConstraintViolationException e) {

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractOnParentVersionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractOnParentVersionTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractOnParentVersionTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractOnParentVersionTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,79 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.Property;
+import javax.jcr.Node;
+import javax.jcr.nodetype.PropertyDef;
+
+import javax.jcr.version.OnParentVersionAction;
+
+/**
+ * <code>AbstractOnParentVersionTest</code>: the abstract base class for
+ * all tests related to OnParentVersion issues.
+ */
+public abstract class AbstractOnParentVersionTest extends AbstractVersionTest {
+
+    protected int OPVAction;
+
+    protected Property p;
+    protected String initialPropValue = "initialValue";
+    protected String newPropValue = "anotherValue";   // New string value for the property
+
+    protected String childNodeTypeName;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        childNodeTypeName = getProperty("nodetype");
+
+        // set the property
+        p = versionableNode.setProperty(propertyName1, initialPropValue);
+
+        // assert that property has the proper opv-behaviour
+        PropertyDef pd = p.getDefinition();
+        if (pd.getOnParentVersion() != OPVAction) {
+            fail("JCR Property at '"+p.getPath()+"' does not have the required OnParentVersion "+OnParentVersionAction.nameFromValue(OPVAction)+" definition.");
+        }
+        testRootNode.save();
+    }
+
+    /**
+     * Add a child node to the versionable node created in the setup with the
+     * name and nodetype name defined in the corresponding configuration. After
+     * creation of the child node, an assertion is made for the proper onParentVersion
+     * behaviour.<p/>
+     * NOTE: the child node is removed together with the versionable node after
+     * each test.
+     *
+     * @param requiredOpvBehaviour
+     * @return
+     * @throws RepositoryException
+     */
+    protected Node addChildNode(int requiredOpvBehaviour) throws RepositoryException {
+        if (childNodeTypeName == null) {
+            fail("Undefined node type for the child node with OnParentVersion "+OnParentVersionAction.nameFromValue(requiredOpvBehaviour));
+        }
+
+        Node childNode = versionableNode.addNode(nodeName4, childNodeTypeName);
+        if (childNode.getDefinition().getOnParentVersion() != requiredOpvBehaviour) {
+            fail("The childnode "+childNode.getPath()+" does not provide the required OnParentVersion behaviour "+OnParentVersionAction.nameFromValue(requiredOpvBehaviour));
+        }
+        return childNode;
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,148 @@
+/*
+ * 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 org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionIterator;
+
+/**
+ * <code>AbstractVersionTest</code> is the abstract base class for all
+ * versioning related test classes.
+ */
+public class AbstractVersionTest extends AbstractJCRTest {
+
+    protected NodeType versionableNodeType;
+    protected NodeType nonVersionableNodeType;
+
+    protected Node versionableNode;
+    protected Node nonVersionableNode;
+
+    protected String propertyValue;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
+
+        // assert that this repository support versioning
+        try {
+            NodeType versionableNt = ntMgr.getNodeType(mixVersionable);
+            if (versionableNt == null) {
+               fail("Repository does not support Versioning: mixin nodetype 'mix:versionable' is missing.");
+            }
+        } catch (NoSuchNodeTypeException e) {
+            fail("Repository does not support Versioning: mixin nodetype 'mix:versionable' is missing.");
+        }
+
+        // retrieve versionable nodetype
+        String versionableNodeTypeName = getProperty("versionableNodeType");
+        try {
+            versionableNodeType = ntMgr.getNodeType(versionableNodeTypeName);
+            if (versionableNodeType == null) {
+               fail("Property 'versionableNodeType' does not define a valid nodetype: '"+versionableNodeTypeName+"'");
+            }
+        } catch (NoSuchNodeTypeException e) {
+            fail("Property 'versionableNodeType' does not define an existing nodetype: '"+versionableNodeTypeName+"'");
+        }
+
+        // make sure 'non-versionable' nodetype is properly defined
+        try {
+            nonVersionableNodeType = ntMgr.getNodeType(testNodeType);
+            if (nonVersionableNodeType == null || nonVersionableNodeType.isNodeType(mixVersionable)) {
+               fail("Property 'testNodeType' does define a versionable nodetype: '"+testNodeType+"'");
+            }
+        } catch (NoSuchNodeTypeException e) {
+            fail("Property 'testNodeType' does not define an existing nodetype: '"+testNodeType+"'");
+        }
+
+        // build persistent versionable and non-versionable nodes
+        try {
+            versionableNode = createVersionableNode(testRootNode, nodeName1, versionableNodeType);
+        } catch (RepositoryException e) {
+            fail("Failed to create versionable test node." + e.getMessage());
+        }
+        try {
+            nonVersionableNode = testRootNode.addNode(nodeName3, nonVersionableNodeType.getName());
+            testRootNode.save();
+        } catch (RepositoryException e) {
+            fail("Failed to create non-versionable test node." + e.getMessage());
+        }
+
+        propertyValue = getProperty("propertyValue");
+        if (propertyValue == null) {
+            fail("Property 'propertyValue' is not defined.");
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        // remove versionable nodes
+        try {
+            versionableNode.remove();
+            testRootNode.save();
+        } finally {
+            super.tearDown();
+        }
+    }
+
+    /**
+     * Retrieve the number of versions present in the given version history.
+     *
+     * @param vHistory
+     * @return number of versions
+     * @throws RepositoryException
+     */
+    protected long getNumberOfVersions(VersionHistory vHistory) throws RepositoryException {
+        VersionIterator vIter = vHistory.getAllVersions();
+        long numOfVersions = vIter.getSize();
+        if (numOfVersions == -1) {
+            numOfVersions = 0;
+            while (vIter.hasNext()) {
+                vIter.nextVersion();
+                numOfVersions++;
+            }
+        }
+        return numOfVersions;
+    }
+
+    /**
+     * Create a versionable node below the given parent node. If the specified
+     * nodetype name is not mix:versionable an attempt is made to add the
+     * mix:versionable mixin type to the created child node.
+     *
+     * @param parent
+     * @param name
+     * @param nodetype
+     * @return versionable node.
+     * @throws RepositoryException
+     */
+    protected Node createVersionableNode(Node parent, String name, NodeType nodetype) throws RepositoryException {
+        Node versionableNode = parent.addNode(name, nodetype.getName());
+        if (!nodetype.isNodeType(mixVersionable)) {
+            versionableNode.addMixin(mixVersionable);
+        }
+        parent.save();
+
+        return versionableNode;
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckinTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckinTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckinTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckinTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,170 @@
+/*
+ * 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 javax.jcr.version.Version;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ReferenceValue;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import java.util.Arrays;
+
+/**
+ * <code>CheckinTest</code> covers tests related to {@link javax.jcr.Node#checkin()}.
+ *
+ * @test
+ * @sources CheckinTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.CheckinTest
+ * @keywords versioning
+ */
+public class CheckinTest extends AbstractVersionTest {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        versionableNode.checkout();
+    }
+
+    /**
+     * Test if Node.isCheckedOut() return false after calling Node.checkin()
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testIsCheckedOut() throws RepositoryException {
+        versionableNode.checkin();
+        assertTrue("After calling Node.checkin() on a versionable node N, N.isCheckedOut() must return false", versionableNode.isCheckedOut() == false);
+    }
+
+    /**
+     * Test if the node's jcr:predecessors property contains an empty value array
+     * after checkin.
+     *
+     * @throws RepositoryException
+     */
+    public void testCheckinRemovesPredecessorProperty() throws RepositoryException {
+
+        versionableNode.checkin();
+        Value[] predecessorsValue = versionableNode.getProperty(jcrPredecessors).getValues();
+
+        assertTrue("Checkin must set the node's jcr:predecessors property to the empty array", predecessorsValue.length == 0);
+    }
+
+    /**
+     * Test if the nodes jcr:predecessors property is copied to the new version
+     * on Node.checkin().
+     *
+     * @throws RepositoryException
+     */
+    public void testPredecessorIsCopiedToNewVersion() throws RepositoryException {
+
+        Value[] nPredecessorsValue = versionableNode.getProperty(jcrPredecessors).getValues();
+
+        Version v = versionableNode.checkin();
+        Value[] vPredecessorsValue = v.getProperty(jcrPredecessors).getValues();
+
+        assertEquals("The versionable checked-out node’s jcr:predecessors property is copied to the new version on checkin.", Arrays.asList(nPredecessorsValue), Arrays.asList(vPredecessorsValue));
+    }
+
+    /**
+     * Test if Node.checkin() on a checked-in node has no effect.
+     *
+     * @throws RepositoryException
+     */
+    public void testMultipleCheckinHasNoEffect() throws RepositoryException {
+
+        Version v = versionableNode.checkin();
+        try {
+            Version v2 = versionableNode.checkin();
+
+            assertTrue("Calling checkin() on a node that is already checked-in must not have an effect.", v.equals(v2));
+        } catch (RepositoryException e) {
+            fail("Calling checkin() on a node that is already checked-in must not throw an exception.");
+        }
+    }
+
+    /**
+     * Test if versionable node N's jcr:baseVersion property is set to refer to
+     * the new version after checkin.
+     *
+     * @throws RepositoryException
+     */
+    public void testBaseVersionAfterCheckin() throws RepositoryException {
+        Version v = versionableNode.checkin();
+        ReferenceValue baseVersionRef = (ReferenceValue) versionableNode.getProperty(jcrBaseVersion).getValue();
+
+        assertEquals("Checked-in node's jcr:baseVersion property is set to refer to the version created on checkin.", new ReferenceValue(v), baseVersionRef);
+    }
+
+    /**
+     * Test if Node.checkin() throws InvalidItemStateException if the node
+     * has unsaved changes pending.
+     *
+     * @throws RepositoryException
+     */
+    public void testCheckinWithPendingChanges() throws RepositoryException {
+        try {
+            // modify node without calling save()
+            versionableNode.setProperty(propertyName1, propertyValue);
+            versionableNode.checkin();
+
+            fail("InvalidItemStateException must be thrown on attempt to checkin a node having any unsaved changes pending.");
+        } catch (InvalidItemStateException e) {
+            // ok
+        }
+    }
+
+    /**
+     * Test if Node.isCheckedOut() returns false after Node.checkin().
+     *
+     * @throws RepositoryException
+     */
+    public void testIsNotCheckedOut() throws RepositoryException {
+        versionableNode.checkin();
+        boolean isCheckedOut = versionableNode.isCheckedOut();
+
+        assertFalse("Node.isCheckedOut() must return false after Node.checkin().", isCheckedOut);
+    }
+
+    /**
+     * Test if Node.checkin() adds another version to the VersionHistory
+     *
+     * @throws RepositoryException
+     */
+    public void testCheckinCreatesNewVersion() throws RepositoryException {
+
+        long initialNumberOfVersions = getNumberOfVersions(versionableNode.getVersionHistory());
+        versionableNode.checkin();
+        long numberOfVersions = getNumberOfVersions(versionableNode.getVersionHistory());
+
+        assertTrue("Checkin must create a new Version in the VersionHistory.", numberOfVersions == initialNumberOfVersions + 1);
+    }
+
+    /**
+     * Test calling Node.checkin() on a non-versionable node.
+     *
+     * @throws RepositoryException
+     */
+    public void testCheckinNonVersionableNode() throws RepositoryException {
+        try {
+            nonVersionableNode.checkin();
+            fail("Node.checkin() on a non versionable node must throw UnsupportedRepositoryOperationException");
+        } catch (UnsupportedRepositoryOperationException e) {
+            //success
+        }
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckoutTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckoutTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckoutTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/CheckoutTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,96 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+/**
+ * <code>CheckoutTest</code> covers tests related to {@link javax.jcr.Node#checkout()}
+ * and {@link javax.jcr.Node#isCheckedOut()}.
+ *
+ * @test
+ * @sources CheckoutTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.CheckoutTest
+ * @keywords versioning
+ */
+public class CheckoutTest extends AbstractVersionTest {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        if (!versionableNode.isCheckedOut()) {
+            fail("A versionable node must be checked-out after persistent creation.");
+        }
+        versionableNode.checkin();
+    }
+
+    /**
+     * Test if Node.isCheckedOut() returns true, if the versionable node has
+     * been checked out before.
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testIsCheckedOut() throws RepositoryException {
+        versionableNode.checkout();
+        assertTrue("After calling Node.checkout() a versionable node N, N.isCheckedOut() must return true.", versionableNode.isCheckedOut());
+    }
+
+    /**
+     * Test calling Node.isCheckedOut() on a non-versionable.
+     *
+     * @throws RepositoryException
+     */
+    public void testIsCheckedOutNonVersionableNode() throws RepositoryException {
+        boolean isCheckedOut = nonVersionableNode.isCheckedOut();
+        Node vParent = null;
+        try {
+            vParent = nonVersionableNode.getParent();
+            while (!vParent.isNodeType(mixVersionable)) {
+                vParent = vParent.getParent();
+            }
+        } catch (ItemNotFoundException e) {
+            // root reached.
+        }
+
+        if (vParent != null && vParent.isNodeType(mixVersionable)) {
+            if (vParent.isCheckedOut()) {
+               assertTrue("Node.isCheckedOut() must return true if the node is non-versionable and its nearest versionable ancestor is checked-out.", isCheckedOut);
+            } else {
+               assertFalse("Node.isCheckedOut() must return false if the node is non-versionable and its nearest versionable ancestor is checked-in.", isCheckedOut);
+            }
+        } else {
+            assertTrue("Node.isCheckedOut() must return true if the node is non-versionable and has no versionable ancestor", isCheckedOut);
+        }
+    }
+
+    /**
+     * Test calling Node.checkout() on a non-versionable node.
+     * 
+     * @throws RepositoryException
+     */
+    public void testCheckoutNonVersionableNode() throws RepositoryException {
+        try {
+            nonVersionableNode.checkout();
+            fail("Node.checkout() on a non versionable node must throw UnsupportedRepositoryOperationException");
+        } catch (UnsupportedRepositoryOperationException e) {
+            //success
+        }
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionAbortTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionAbortTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionAbortTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionAbortTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,73 @@
+/*
+ * 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 org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.version.OnParentVersionAction;
+import javax.jcr.version.VersionException;
+
+/**
+ * <code>OnParentVersionAbortTest</code> tests the OnParentVersion {@link OnParentVersionAction#ABORT ABORT}
+ * behaviour.
+ *
+ * @test
+ * @sources OnParentVersionAbortTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.OnParentVersionComputeTest
+ * @keywords versioning
+ */
+public class OnParentVersionAbortTest extends AbstractOnParentVersionTest {
+
+    protected void setUp() throws Exception {
+        OPVAction = OnParentVersionAction.ABORT;
+        super.setUp();
+    }
+
+    /**
+     * Test the restore of a OnParentVersion-ABORT property
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestoreProp() throws RepositoryException {
+        try {
+            p.getParent().checkout();
+            p.getParent().checkin();
+            fail("On checkin of N which has a property with OnParentVersion ABORT defined, an UnsupportedRepositoryOperationException must be thrown.");
+        } catch (VersionException e) {
+            // success
+        }
+    }
+
+    /**
+     * Test the restore of a OnParentVersion-ABORT node
+     * 
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testRestoreNode() throws RepositoryException, NotExecutableException {
+        // create child node with OPV-ABORT behaviour
+        addChildNode(OPVAction);
+        testRootNode.save();
+        try {
+            versionableNode.checkin();
+            fail("On checkin of N which has a child node with OnParentVersion ABORT defined, an UnsupportedRepositoryOperationException must be thrown.");
+        } catch (VersionException e) {
+            // success
+        }
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionComputeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionComputeTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionComputeTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionComputeTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,59 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.version.OnParentVersionAction;
+import javax.jcr.version.Version;
+
+/**
+ * <code>OnParentVersionComputeTest</code> tests the OnParentVersion {@link OnParentVersionAction#COMPUTE COMPUTE}
+ * behaviour.
+ *
+ * @test
+ * @sources OnParentVersionComputeTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.OnParentVersionComputeTest
+ * @keywords versioning
+ */
+public class OnParentVersionComputeTest extends AbstractOnParentVersionTest {
+
+    protected void setUp() throws Exception {
+        OPVAction = OnParentVersionAction.COMPUTE;
+        super.setUp();
+    }
+
+    /**
+     * Test the restore of a OnParentVersion-COMPUTE property
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestoreProp() throws RepositoryException {
+
+        Node propParent = p.getParent();
+        propParent.checkout();
+        Version v = propParent.checkin();
+        propParent.checkout();
+
+        p.setValue(newPropValue);
+        p.save();
+
+        propParent.restore(v, false);
+
+        assertEquals("On restore of a OnParentVersion-COMPUTE property P, the current P in the workspace will be left unchanged.", p.getString(), newPropValue);
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionCopyTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionCopyTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionCopyTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionCopyTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,77 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.version.OnParentVersionAction;
+import javax.jcr.version.Version;
+
+/**
+ * <code>OnParentVersionCopyTest</code> tests the OnParentVersion {@link OnParentVersionAction#COPY COPY}
+ * behaviour.
+ *
+ * @test
+ * @sources OnParentVersionCopyTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.OnParentVersionCopyTest
+ * @keywords versioning
+ */
+public class OnParentVersionCopyTest extends AbstractOnParentVersionTest {
+
+    String initialNodePath;
+
+    protected void setUp() throws Exception {
+        OPVAction = OnParentVersionAction.COPY;
+        super.setUp();
+    }
+
+    /**
+     * Test the restore of a OnParentVersion-COPY property
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestoreProp() throws RepositoryException {
+        assertEquals("On restore of a OnParentVersion-COPY property P the copy of P stored will be restored, replacing the current P in the workspace.", p.getString(), initialPropValue);
+    }
+
+    /**
+     * Test the restore of a OnParentVersion-COPY node
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestoreNode() throws RepositoryException {
+        // prepare for node test
+        Node childNode = addChildNode(OPVAction);
+        Node nodeParent = childNode.getParent();
+        // todo: added next line. correct? -> angela
+        nodeParent.save();
+
+        nodeParent.checkout();
+        Version v = nodeParent.checkin();
+
+        initialNodePath = childNode.getPath();
+        childNode.remove();
+        nodeParent.save();
+
+        nodeParent.restore(v, false);
+
+        if (!superuser.itemExists(initialNodePath)) {
+            fail("On restore of a OnParentVersion-COPY child node, the node needs to be restored, replacing the current node in the workspace.");
+        }
+        assertEquals("On restore of a OnParentVersion-COPY child node, the node needs to be restored, replacing the current node in the workspace.", childNode, superuser.getItem(initialNodePath));
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionIgnoreTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionIgnoreTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionIgnoreTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionIgnoreTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,59 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.version.OnParentVersionAction;
+import javax.jcr.version.Version;
+
+/**
+ * <code>OnParentVersionIgnoreTest</code> tests the OnParentVersion {@link OnParentVersionAction#IGNORE IGNORE}
+ * behaviour.
+ *
+ * @test
+ * @sources OnParentVersionIgnoreTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.OnParentVersionIgnoreTest
+ * @keywords versioning
+ */
+public class OnParentVersionIgnoreTest extends AbstractOnParentVersionTest {
+
+    protected void setUp() throws Exception {
+        OPVAction = OnParentVersionAction.IGNORE;
+        super.setUp();
+    }
+
+    /**
+     * Test the restore of a OnParentVersion-IGNORE property
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestoreProp() throws RepositoryException {
+
+        Node propParent = p.getParent();
+        propParent.checkout();
+        Version v = propParent.checkin();
+        propParent.checkout();
+
+        p.setValue(newPropValue);
+        p.save();
+
+        propParent.restore(v, false);
+
+        assertEquals("On restore of a OnParentVersion-IGNORE property P, the current value of P must be left unchanged.", p.getString(), newPropValue);
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionInitializeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionInitializeTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionInitializeTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/OnParentVersionInitializeTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,59 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.version.OnParentVersionAction;
+import javax.jcr.version.Version;
+
+/**
+ * <code>OnParentVersionInitializeTest</code> tests the {@link OnParentVersionAction#INITIALIZE INITIALIZE}
+ * behaviour.
+ *
+ * @test
+ * @sources OnParentVersionInitializeTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.OnParentVersionInitializeTest
+ * @keywords versioning
+ */
+public class OnParentVersionInitializeTest extends AbstractOnParentVersionTest {
+
+    protected void setUp() throws Exception {
+        OPVAction = OnParentVersionAction.INITIALIZE;
+        super.setUp();
+    }
+
+    /**
+     * Test the restore of a OnParentVersion-INITIALIZE property
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestoreProp() throws RepositoryException {
+
+        Node propParent = p.getParent();
+        propParent.checkout();
+        Version v = propParent.checkin();
+        propParent.checkout();
+
+        p.setValue(newPropValue);
+        p.save();
+
+        propParent.restore(v, false);
+
+        assertEquals("On restore of a OnParentVersion-INITIALIZE property P, the current value of P must be left unchanged.", p.getString(), newPropValue);
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RemoveVersionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RemoveVersionTest.java?view=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RemoveVersionTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RemoveVersionTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,168 @@
+/*
+ * 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 org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Node;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.jcr.version.VersionHistory;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <code>RemoveVersionTest</code> provides test methods covering {@link VersionHistory#removeVersion(String)}.
+ * Please note, that removing versions is defined to be an optional feature in
+ * the JSR 170 specification. The setup therefore includes a initial removal,
+ * in order to test, whether removing versions is supported.
+ *
+ * @test
+ * @sources RemoveVersionTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.RemoveVersionTest
+ * @keywords versioning
+ */
+public class RemoveVersionTest extends AbstractVersionTest {
+
+    protected Node versionableNode2;
+    protected Version version;
+    protected Version version2;
+
+    protected VersionHistory vHistory;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        vHistory = versionableNode.getVersionHistory();
+
+        if (vHistory == null) {
+            fail("VersionHistory must be created on persistent creation of a versionable node.");
+        }
+
+        Version testV = versionableNode.checkin();
+        try {
+            vHistory.removeVersion(testV.getName());
+        } catch (UnsupportedRepositoryOperationException e) {
+            throw new NotExecutableException("Removing version is not supported: "+e.getMessage());
+        }
+
+        versionableNode.checkout();
+        version = versionableNode.checkin();
+        // create a second version
+        versionableNode.checkout();
+        version2 = versionableNode.checkin();
+
+        // 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());
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        try {
+            versionableNode2.remove();
+            testRootNode.save();
+        } finally {
+            super.tearDown();
+        }
+    }
+
+    /**
+     * Test if the predecessors of the removed version are made predecessor of
+     * its original successor version.
+     *
+     * @throws RepositoryException
+     */
+    public void testRemoveVersionAdjustPredecessorSet() throws RepositoryException {
+
+        // retrieve predecessors to test and remove the version
+        List predecList = new ArrayList(Arrays.asList(version.getPredecessors()));
+        vHistory.removeVersion(version.getName());
+
+        // new predecessors of the additional version
+        Version[] predec2 = version2.getPredecessors();
+        for (int i = 0; i < predec2.length; i++) {
+            if (!predecList.remove(predec2[i])) {
+                fail("All predecessors of the removed version must be made predecessors of it's original successor version.");
+            }
+        }
+
+        if (!predecList.isEmpty()) {
+            fail("All predecessors of the removed version must be made predecessors of it's original successor version.");
+        }
+    }
+
+     /**
+     * Test if the successors of the removed version are made successors of
+     * all predecessors of the the removed version.
+     *
+     * @throws RepositoryException
+     */
+    public void testRemoveVersionAdjustSucessorSet() throws RepositoryException {
+
+        // retrieve predecessors to test and remove the version
+        Version[] predec = version.getPredecessors();
+        vHistory.removeVersion(version.getName());
+
+        for (int i = 0; i < predec.length; i++) {
+            List successorList = Arrays.asList(predec[i].getSuccessors());
+            if (!successorList.contains(version2)) {
+                fail("Removing a version must make all it's successor version to successors of the removed version's predecessors.");
+            }
+        }
+    }
+
+    /**
+     * Test if removing a version from the version history throws a VersionException
+     * if the specified version does not exist.
+     *
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testRemoveInvalidVersion() throws RepositoryException, NotExecutableException {
+        Version invalidV = versionableNode2.checkin();
+        String invalidName = invalidV.getName();
+
+        // build a version name that is not present in the current history
+        boolean found = false;
+        for (int i = 0; i < 10 && !found; i++) {
+            try {
+                vHistory.getVersion(invalidName);
+                invalidName += i;
+            } catch (VersionException e) {
+                // ok > found a name that is invalid.
+                found = true;
+            }
+        }
+
+        if (!found) {
+            throw new NotExecutableException("Failed to create an invalid name in order to test the removal of versions.");
+        }
+
+        try {
+            vHistory.removeVersion(invalidName);
+            fail("Removing a version that does not exist must fail with a VersionException.");
+        } catch (VersionException e) {
+            // success
+        }
+    }
+}
\ No newline at end of file

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

Added: 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=auto&rev=149525
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RestoreTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/RestoreTest.java Wed Feb  2 07:57:27 2005
@@ -0,0 +1,265 @@
+/*
+ * 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 org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.nodetype.NodeDef;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionException;
+import javax.jcr.version.OnParentVersionAction;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ItemExistsException;
+
+/**
+ * <code>RestoreTest</code> covers tests related to the restore methods available
+ * on {@link javax.jcr.Node}:
+ * <ul>
+ * <li>{@link javax.jcr.Node#restore(String, boolean)}</li>
+ * <li>{@link javax.jcr.Node#restore(javax.jcr.version.Version, boolean)}</li>
+ * <li>{@link javax.jcr.Node#restore(javax.jcr.version.Version, String, boolean)}</li>
+ * </ul>
+ *
+ * @test
+ * @sources RestoreTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.RestoreTest
+ * @keywords versioning
+ */
+public class RestoreTest extends AbstractVersionTest {
+
+    Version version;
+    Version rootVersion;
+
+    Node versionableNode2;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        version = versionableNode.checkin();
+        versionableNode.checkout();
+        rootVersion = versionableNode.getVersionHistory().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());
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        try {
+            versionableNode2.remove();
+            testRootNode.save();
+        } finally {
+            super.tearDown();
+        }
+    }
+
+    /**
+     * Test if restoring a node works on checked-in node.
+     *
+     * @throws RepositoryException
+     */
+    public void testRestoreOnCheckedInNode() throws RepositoryException {
+        versionableNode.checkin();
+        versionableNode.restore(rootVersion, true);
+    }
+
+    /**
+     * Test if restoring a node works on checked-out node.
+     *
+     * @throws RepositoryException
+     */
+    public void testRestoreOnCheckedOutNode() throws RepositoryException {
+        versionableNode.restore(rootVersion, true);
+    }
+
+    /**
+     * Restoring a node set the jcr:isCheckedOut property to false.
+     *
+     * @throws RepositoryException
+     */
+    public void testRestoreSetsIsCheckedOutToFalse() throws RepositoryException {
+        versionableNode.restore(rootVersion, true);
+
+        assertFalse("Restoring a node sets the jcr:isCheckedOut property to false", versionableNode.isCheckedOut());
+    }
+
+    /**
+     * Test if restoring a node sets the jcr:baseVersion property correctly.
+     *
+     * @throws javax.jcr.RepositoryException
+     */
+    public void testRestoreSetsBaseVersion() throws RepositoryException {
+        versionableNode.restore(rootVersion, true);
+        Version baseV = versionableNode.getBaseVersion();
+
+        assertEquals("Restoring a node must set node's base version in order to point to the restored version.", baseV, rootVersion);
+    }
+
+    /**
+     * Test if InvalidItemStateException is thrown if the node has pending changes.
+     *
+     * @throws RepositoryException
+     */
+    public void testRestoreWithPendingChanges() throws RepositoryException {
+        // modify node without calling save()
+        try {
+            versionableNode.setProperty(propertyName1, propertyValue);
+            versionableNode.restore(rootVersion, true);
+
+            fail("InvalidItemStateException must be thrown on attempt to restore a node having any unsaved changes pending.");
+        } catch (InvalidItemStateException e) {
+            // ok
+        }
+    }
+
+    /**
+     * VersionException expected on Node.restore(Version, boolean) if the
+     * specified version is not part of this node's version history.
+     *
+     * @throws RepositoryException
+     */
+    public void testRestoreInvalidVersion() throws RepositoryException {
+        Version vNode2 = versionableNode2.checkin();
+        try {
+            versionableNode.restore(vNode2, true);
+
+            fail("VersionException expected on Node.restore(Version, boolean) if the specified version is not part of this node's version history.");
+        } catch (VersionException e) {
+            // ok
+        }
+    }
+
+    /**
+     * VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.
+     *
+     * @throws RepositoryException
+     */
+    public void testRestoreInvalidVersion2() throws RepositoryException {
+        Version vNode2 = versionableNode2.checkin();
+        try {
+            versionableNode.restore(vNode2.getName(), 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
+        }
+    }
+
+    /**
+     * Test calling Node.restore(String, boolean) on a non-versionable node.
+     *
+     * @throws javax.jcr.RepositoryException
+     * @see Node#restore(String, boolean)
+     */
+    public void testRestoreNonVersionableNode() throws RepositoryException {
+        try {
+            nonVersionableNode.restore("foo", true);
+            fail("Node.restore(String, boolean) on a non versionable node must throw UnsupportedRepositoryOperationException");
+        } catch (UnsupportedRepositoryOperationException e) {
+            //success
+        }
+    }
+
+    /**
+     * Test calling Node.restore(Version, String, boolean) on a non-versionable node.
+     *
+     * @throws javax.jcr.RepositoryException
+     * @see Node#restore(javax.jcr.version.Version, String, boolean)
+     */
+    public void testRestoreNonVersionableNode2() throws RepositoryException {
+        try {
+            nonVersionableNode.restore(rootVersion, "foo", true);
+            fail("Node.restore(Version, String, boolean) on a non versionable node must throw UnsupportedRepositoryOperationException");
+        } catch (UnsupportedRepositoryOperationException e) {
+            //success
+        }
+    }
+
+    /**
+     * Test calling Node.restore(Version, boolean) on a non-versionable node.
+     *
+     * @throws javax.jcr.RepositoryException
+     * @see Node#restore(Version, boolean)
+     */
+    public void testRestoreNonVersionableNode3() throws RepositoryException {
+        try {
+            nonVersionableNode.restore(rootVersion, true);
+            fail("Node.restore(Version, boolean) on a non versionable node must throw UnsupportedRepositoryOperationException");
+        } catch (UnsupportedRepositoryOperationException e) {
+            //success
+        }
+    }
+
+    /**
+     * Test if restoring a node with an invalid Version throws a VersionException
+     *
+     * @throws RepositoryException
+     */
+    public void testRestoreWithInvalidVersion() throws RepositoryException {
+        Version invalidVersion = versionableNode2.checkin();
+        try {
+            versionableNode.restore(invalidVersion, 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
+        }
+    }
+
+    /**
+     * 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.
+     */
+    public void testRestoreWithUUIDConflict() throws RepositoryException, NotExecutableException {
+        try {
+            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." );
+            }
+
+            Version v = versionableNode.checkin();
+            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 ) {
+            // success
+        }
+    }
+}
\ No newline at end of file

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

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=149524&r2=149525
==============================================================================
--- 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 Wed Feb  2 07:57:27 2005
@@ -36,7 +36,19 @@
     public static Test suite() {
         TestSuite suite = new TestSuite("javax.jcr.version tests");
 
-        // ADD TEST CLASSES HERE:
+        suite.addTestSuite(VersionHistoryTest.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);
 
         return suite;
     }



Mime
View raw message