jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r738422 [3/3] - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/lock/ main/java/org/apache/jackrabbit/core/retention/ main/java/org/apache/jackrabbit/core/security/authori...
Date Wed, 28 Jan 2009 09:50:51 GMT
Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyEffectTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyEffectTest.java?rev=738422&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyEffectTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyEffectTest.java Wed Jan 28 09:50:50 2009
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.api.jsr283.retention;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.RepositoryStub;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import javax.jcr.Value;
+
+/**
+ * <code>RetentionPolicyEffectTest</code>...
+ */
+public class RetentionPolicyEffectTest extends AbstractRetentionTest {
+
+    private Node childN;
+    private Property childP;
+    private Session otherS;
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        childN = testRootNode.addNode(nodeName2);
+        Value v = getJcrValue(superuser, RepositoryStub.PROP_PROP_VALUE1, RepositoryStub.PROP_PROP_TYPE1, "test");
+        childP = testRootNode.setProperty(propertyName1, v);
+        superuser.save();
+
+        otherS = helper.getSuperuserSession();
+    }
+
+    protected void tearDown() throws Exception {
+        if (otherS != null) {
+            otherS.logout();
+        }
+        superuser.refresh(false);
+        RetentionPolicy rp = retentionMgr.getRetentionPolicy(testNodePath);
+        if (rp != null) {
+            retentionMgr.removeRetentionPolicy(testNodePath);
+            superuser.save();
+        }
+        super.tearDown();
+    }
+
+    // TODO: test importXML (session/wsp) / move (session/wsp) / copy ...
+    // TODO: test effect on child items
+    
+    public void testTransientRententionPolicy() throws RepositoryException, NotExecutableException {
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+
+        assertNoEffect(testRootNode, nodeName3, propertyName2);
+        assertNoEffect(childN, nodeName3, propertyName2);
+        assertNoEffect(childP);
+    }
+
+    public void testTransientRententionPolicy2() throws RepositoryException, NotExecutableException {
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+
+        assertNoEffect((Node) otherS.getItem(testNodePath), nodeName3, propertyName2);
+        assertNoEffect((Node) otherS.getItem(childN.getPath()), nodeName3, propertyName2);
+        assertNoEffect((Property) otherS.getItem(childP.getPath()));
+    }
+
+    public void testRententionPolicy() throws RepositoryException, NotExecutableException {
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+        superuser.save();
+
+        // check for superuser
+        assertEffect(testRootNode, childN.getName(), childP.getName(), nodeName3, propertyName2);
+    }
+
+    public void testRententionPolicy2() throws RepositoryException, NotExecutableException {
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+        superuser.save();
+
+        // check for other session
+        assertEffect((Node) otherS.getItem(testNodePath), childN.getName(), childP.getName(), nodeName3, propertyName2);
+    }
+
+    private void assertEffect(Node targetNode, String childName,
+                                        String propName, String childName2,
+                                        String propName2) throws RepositoryException {
+        Session s = targetNode.getSession();
+        try {
+            Node child = targetNode.getNode(childName);
+            child.remove();
+            s.save();
+            fail("Retention policy present must prevent a child node from being removed.");
+        } catch (RepositoryException e) {
+            // success
+            s.refresh(false);
+        }
+        try {
+            Property p = targetNode.getProperty(propName);
+            p.remove();
+            s.save();
+            fail("Retention policy present must prevent a child property from being removed.");
+        } catch (RepositoryException e) {
+            // success
+            s.refresh(false);
+        }
+        try {
+            Property p = targetNode.getProperty(propName);
+            p.setValue("test2");
+            s.save();
+            fail("Retention policy present must prevent the child property from being modified.");
+        } catch (RepositoryException e) {
+            // success
+            s.refresh(false);
+        }
+        try {
+            targetNode.addNode(childName2);
+            s.save();
+            fail("Retention policy present must prevent the target node from having new nodes added.");
+        } catch (RepositoryException e) {
+            // success
+            s.refresh(false);
+        }
+        try {
+            Value v = getJcrValue(s, RepositoryStub.PROP_PROP_VALUE2, RepositoryStub.PROP_PROP_TYPE2, "test");
+            targetNode.setProperty(propName2, v);
+            s.save();
+            fail("Retention policy present must prevent the target node from having new properties set.");
+        } catch (RepositoryException e) {
+            // success
+            s.refresh(false);
+        }
+        try {
+            targetNode.remove();
+            s.save();
+            fail("Hold present must prevent the target node from being removed.");
+        } catch (RepositoryException e) {
+            // success
+            s.refresh(false);
+        }
+    }
+
+    private void assertNoEffect(Node target, String childName, String propName) throws RepositoryException {
+        Session s = target.getSession();
+
+        Node n = target.addNode(childName);
+        Value v = getJcrValue(s, RepositoryStub.PROP_PROP_VALUE2, RepositoryStub.PROP_PROP_TYPE2, "test");
+        Property p = target.setProperty(propName, v);
+
+        n.remove();
+        p.remove();
+    }
+
+    private void assertNoEffect(Property target) throws RepositoryException {
+        Session s = target.getSession();
+        target.setValue("test3");
+        target.remove();
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyEffectTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyEffectTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyTest.java?rev=738422&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyTest.java Wed Jan 28 09:50:50 2009
@@ -0,0 +1,438 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.api.jsr283.retention;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.PropertyIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.lock.LockException;
+import javax.jcr.version.VersionException;
+
+/**
+ * <code>RetentionPolicyTest</code>...
+ */
+public class RetentionPolicyTest extends AbstractRetentionTest {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // make sure there is no retention policy defined at testNodePath.
+        RetentionPolicy p = retentionMgr.getRetentionPolicy(testNodePath);
+        if (p != null) {
+            retentionMgr.removeRetentionPolicy(testNodePath);
+            superuser.save();
+        }
+    }
+    
+    public void testGetRetentionPolicy() throws RepositoryException, NotExecutableException {
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+        
+        RetentionPolicy policy = retentionMgr.getRetentionPolicy(testNodePath);
+        assertNotNull("RetentionManager.getRetentionPolicy must return the policy set before.", policy);
+    }
+
+    public void testGetRetentionPolicyOnChild() throws RepositoryException, NotExecutableException {
+        String childPath = testRootNode.addNode(nodeName2, testNodeType).getPath();
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+        
+        assertNull("RetentionManager.getRetentionPolicy called on child must not return the policy set before.",
+                retentionMgr.getRetentionPolicy(childPath));
+    }
+
+    public void testRetentionPolicyGetName() throws RepositoryException, NotExecutableException {
+        RetentionPolicy p = getApplicableRetentionPolicy();
+        retentionMgr.setRetentionPolicy(testNodePath, p);
+
+        RetentionPolicy policy = retentionMgr.getRetentionPolicy(testNodePath);
+        assertEquals("RetentionPolicy.getName() must match the name of the policy set before.", p.getName(), policy.getName());
+    }
+
+    public void testSetRetentionPolicyIsTransient() throws RepositoryException, NotExecutableException {
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+        superuser.refresh(false);
+
+        assertNull("Reverting transient changes must remove the pending retention policy.",
+                retentionMgr.getRetentionPolicy(testNodePath));
+    }
+
+    public void testRemovePendingRetentionPolicy() throws RepositoryException, NotExecutableException {
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+        retentionMgr.removeRetentionPolicy(testNodePath);
+
+        assertNull("Removing pending retention policy must succeed.", retentionMgr.getRetentionPolicy(testNodePath));
+    }
+
+    public void testRemoveRetentionPolicy() throws RepositoryException, NotExecutableException {
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+        superuser.save();
+
+        retentionMgr.removeRetentionPolicy(testNodePath);
+        assertNull("Removing persisted retention policy must succeed.", retentionMgr.getRetentionPolicy(testNodePath));
+        superuser.save();
+        assertNull("Removing persisted retention policy must succeed.", retentionMgr.getRetentionPolicy(testNodePath));
+    }
+
+    public void testRemoveRetentionPolicyIsTransient() throws RepositoryException, NotExecutableException {
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+        superuser.save();
+
+        try {
+            retentionMgr.removeRetentionPolicy(testNodePath);
+            superuser.refresh(false);
+            assertNotNull("Reverting transient removal must re-add the retention policy.",
+                    retentionMgr.getRetentionPolicy(testNodePath));
+        } finally {
+            retentionMgr.removeRetentionPolicy(testNodePath);
+            superuser.save();
+        }
+    }
+
+    public void testRemoveRetentionPolicyFromChild() throws RepositoryException, NotExecutableException {
+        String childPath = testRootNode.addNode(nodeName2, testNodeType).getPath();
+        retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+
+        try {
+            retentionMgr.removeRetentionPolicy(childPath);
+            fail("Removing retention policy from another node must fail");
+        } catch (RepositoryException e) {
+            // success
+            assertNull(retentionMgr.getRetentionPolicy(childPath));
+        }
+
+        // check again with persisted policy
+        superuser.save();
+        try {
+            retentionMgr.removeRetentionPolicy(childPath);
+            fail("Removing retention policy from another node must fail");
+        } catch (RepositoryException e) {
+            // success
+            assertNull(retentionMgr.getRetentionPolicy(childPath));
+        } finally {
+            // rm the policy that was permanently added before.
+            retentionMgr.removeRetentionPolicy(testNodePath);
+            superuser.save();
+        }
+    }
+
+    public void testInvalidPath() throws RepositoryException, NotExecutableException {
+        String invalidPath = testPath; // not an absolute path
+        try {
+            retentionMgr.getRetentionPolicy(invalidPath);
+            fail("Accessing retention policy for an invalid path must throw RepositoryException.");
+        } catch (RepositoryException e) {
+            // success
+        }
+        try {
+            retentionMgr.setRetentionPolicy(invalidPath, getApplicableRetentionPolicy());
+            fail("Setting retention policy with an invalid path must throw RepositoryException.");
+        } catch (RepositoryException e) {
+            // success
+        }
+        try {
+            retentionMgr.removeRetentionPolicy(invalidPath);
+            fail("Removing retention policy with an invalid path must throw RepositoryException.");
+        } catch (RepositoryException e) {
+            // success
+        }
+    }
+
+    public void testNonExistingNodePath() throws RepositoryException, NotExecutableException {
+        String invalidPath = testNodePath + "/nonexisting";
+        int cnt = 0;
+        while (getJsr283Session(superuser).nodeExists(invalidPath)) {
+            invalidPath += cnt++;
+        }
+
+        try {
+            retentionMgr.getRetentionPolicy(invalidPath);
+            fail("Accessing retention policy from non-existing node must throw PathNotFoundException.");
+        } catch (PathNotFoundException e) {
+            // success
+        }
+        try {
+            retentionMgr.setRetentionPolicy(invalidPath, getApplicableRetentionPolicy());
+            fail("Setting retention policy for a non-existing node must throw PathNotFoundException.");
+        } catch (PathNotFoundException e) {
+            // success
+        }
+        try {
+            retentionMgr.removeRetentionPolicy(invalidPath);
+            fail("Removing retention policy at a non-existing node must throw PathNotFoundException.");
+        } catch (PathNotFoundException e) {
+            // success
+        }
+    }
+
+    public void testPropertyPath() throws RepositoryException, NotExecutableException {
+        String propPath = null;
+        for (PropertyIterator it = testRootNode.getProperties(); it.hasNext();) {
+            String path = it.nextProperty().getPath();
+            if (!getJsr283Session(superuser).nodeExists(path)) {
+                propPath = path;
+                break;
+            }
+        }
+        if (propPath == null) {
+            throw new NotExecutableException();
+        }
+        try {
+            retentionMgr.getRetentionPolicy(propPath);
+            fail("Accessing retention policy from property must throw PathNotFoundException.");
+        } catch (PathNotFoundException e) {
+            // success
+        }
+        try {
+            retentionMgr.setRetentionPolicy(propPath, getApplicableRetentionPolicy());
+            fail("Setting retention policy for property must throw PathNotFoundException.");
+        } catch (PathNotFoundException e) {
+            // success
+        }
+        try {
+            retentionMgr.removeRetentionPolicy(propPath);
+            fail("Removing retention policy at property path must throw PathNotFoundException.");
+        } catch (PathNotFoundException e) {
+            // success
+        }
+    }
+
+    public void testInvalidName() {
+        try {
+            RetentionPolicy rp = new RetentionPolicy() {
+                public String getName() throws RepositoryException {
+                    return "*.[y]";
+                }
+            };
+            retentionMgr.setRetentionPolicy(testNodePath, rp);
+            fail("Setting a policy with an invalid JCR name must fail.");
+        } catch (RepositoryException e) {
+            // success
+        } catch (IllegalArgumentException e) {
+            // fine as well.
+        }
+    }
+
+    public void testReadOnlySession() throws NotExecutableException, RepositoryException {
+        javax.jcr.Session s = helper.getReadOnlySession();
+        try {
+            RetentionManager rmgr = getRetentionManager(s);
+            try {
+                rmgr.getRetentionPolicy(testNodePath);
+                fail("Read-only session doesn't have sufficient privileges to retrieve retention policy.");
+            } catch (AccessDeniedException e) {
+                // success
+            }
+            try {
+                rmgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+                fail("Read-only session doesn't have sufficient privileges to retrieve retention policy.");
+            } catch (AccessDeniedException e) {
+                // success
+            }
+        } finally {
+            s.logout();
+        }
+    }
+
+    public void testSetRetentionPolicyOnLockedNode() throws NotExecutableException, RepositoryException {
+        String childPath = getLockedChildNode().getPath();
+
+        // get another session.
+        javax.jcr.Session otherS = helper.getSuperuserSession();
+        try {
+            RetentionManager rmgr = getRetentionManager(otherS);
+            rmgr.setRetentionPolicy(childPath, getApplicableRetentionPolicy());
+            otherS.save();
+
+            fail("Setting a retention policy on a locked node must throw LockException.");
+        } catch (LockException e) {
+            // success
+        } finally {
+            otherS.logout();
+
+            if (retentionMgr.getRetentionPolicy(childPath) != null) {
+                retentionMgr.removeRetentionPolicy(childPath);
+            }
+            superuser.save();
+        }
+    }
+
+    public void testRemoveRetentionPolicyOnLockedNode() throws NotExecutableException, RepositoryException {
+        String childPath = getLockedChildNode().getPath();
+        retentionMgr.setRetentionPolicy(childPath, getApplicableRetentionPolicy());
+        testRootNode.save();
+
+        javax.jcr.Session otherS = helper.getSuperuserSession();
+        try {
+            RetentionManager rmgr = getRetentionManager(otherS);
+            rmgr.removeRetentionPolicy(childPath);
+            fail("Removing a retention policy on a locked node must throw LockException.");
+        } catch (LockException e) {
+            // success
+        } finally {
+            otherS.logout();
+
+            // clear  retention policy added before
+            try {
+                retentionMgr.removeRetentionPolicy(childPath);
+                superuser.save();
+            } catch (RepositoryException e) {
+                // should not get here if test is correctly executed.
+            }
+        }
+    }
+
+    private Node getLockedChildNode() throws NotExecutableException, RepositoryException {
+        checkSupportedOption(superuser, Repository.OPTION_LOCKING_SUPPORTED);
+        Node child = testRootNode.addNode(nodeName2, testNodeType);
+        if (!child.isNodeType(mixLockable)) {
+            if (child.canAddMixin(mixLockable)) {
+                child.addMixin(mixLockable);
+            } else {
+                throw new NotExecutableException();
+            }
+        }
+        testRootNode.save();
+        child.lock(false, true); // session-scoped lock clean upon superuser-logout.
+        return child;
+    }
+
+    public void testSetRetentionPolicyOnCheckedInNode() throws NotExecutableException, RepositoryException {
+        Node child = getVersionableChildNode();
+        child.checkout();
+        child.checkin();
+        String childPath = child.getPath();
+
+        // get another session.
+        javax.jcr.Session otherS = helper.getSuperuserSession();
+        try {
+            RetentionManager rmgr = getRetentionManager(otherS);
+            rmgr.setRetentionPolicy(childPath, getApplicableRetentionPolicy());
+            otherS.save();
+
+            fail("Setting a retention policy on a checked-in node must throw VersionException.");
+        } catch (VersionException e) {
+            // success
+        } finally {
+            otherS.logout();
+
+            // clear policies (in case of test failure)
+            try {
+                retentionMgr.removeRetentionPolicy(childPath);
+                superuser.save();
+            } catch (RepositoryException e) {
+                // ignore.
+            }
+        }
+    }
+
+    public void testRemoveRetentionPolicyOnCheckedInNode() throws NotExecutableException, RepositoryException {
+        Node child = getVersionableChildNode();
+        child.checkout();
+        retentionMgr.setRetentionPolicy(child.getPath(), getApplicableRetentionPolicy());
+        superuser.save();
+        child.checkin();
+
+        javax.jcr.Session otherS = helper.getSuperuserSession();
+        try {
+            RetentionManager rmgr = getRetentionManager(otherS);
+            rmgr.removeRetentionPolicy(child.getPath());
+            otherS.save();
+            fail("Removing a retention policy on a checked-in node must throw VersionException.");
+        } catch (VersionException e) {
+            // success
+        } finally {
+            otherS.logout();
+
+            // clear policy added before
+            child.checkout();
+            try {
+                retentionMgr.removeRetentionPolicy(child.getPath());
+                superuser.save();
+            } catch (RepositoryException e) {
+                // should not get here if test is correctly executed.
+            }
+        }
+    }
+
+    private Node getVersionableChildNode() throws NotExecutableException, RepositoryException {
+        checkSupportedOption(superuser, Repository.OPTION_VERSIONING_SUPPORTED);
+        Node child = testRootNode.addNode(nodeName2, testNodeType);
+        if (!child.isNodeType(mixVersionable)) {
+            if (child.canAddMixin(mixVersionable)) {
+                child.addMixin(mixVersionable);
+            } else {
+                throw new NotExecutableException();
+            }
+        }
+        testRootNode.save();
+        return child;
+    }
+
+
+    public void testSetRetentionPolicyBelow() throws RepositoryException, NotExecutableException {
+        Node childN = testRootNode.addNode(nodeName2);
+        superuser.save();
+
+        try {
+            retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+            retentionMgr.setRetentionPolicy(childN.getPath(), getApplicableRetentionPolicy());
+            superuser.save();
+        } finally {
+            superuser.refresh(false);
+            if (retentionMgr.getRetentionPolicy(testNodePath) != null) {
+                retentionMgr.removeRetentionPolicy(testNodePath);
+            }
+            if (retentionMgr.getRetentionPolicy(childN.getPath()) != null) {
+                retentionMgr.removeRetentionPolicy(childN.getPath());
+            }
+            superuser.save();
+        }
+    }
+
+    public void testOtherSessionSetsRetentionPolicyBelow() throws RepositoryException, NotExecutableException {
+        Node childN = testRootNode.addNode(nodeName2);
+        superuser.save();
+
+        Session otherS = helper.getSuperuserSession();
+        try {
+            retentionMgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
+            superuser.save();
+
+            getRetentionManager(otherS).setRetentionPolicy(childN.getPath(), getApplicableRetentionPolicy());
+            otherS.save();
+        } finally {
+            // logout the other session
+            otherS.logout();
+
+            // remove the retention policies again.
+            superuser.refresh(false);
+            if (retentionMgr.getRetentionPolicy(testNodePath) != null) {
+                retentionMgr.removeRetentionPolicy(testNodePath);
+            }
+            if (retentionMgr.getRetentionPolicy(childN.getPath()) != null) {
+                retentionMgr.removeRetentionPolicy(childN.getPath());
+            }
+            superuser.save();
+        }
+    }
+
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/RetentionPolicyTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/TestAll.java?rev=738422&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/TestAll.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/TestAll.java Wed Jan 28 09:50:50 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.api.jsr283.retention;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite that includes all testcases for package org.apache.jackrabbit.api.jsr283.retention.
+ */
+public class TestAll extends TestCase {
+
+    /**
+     * Returns a <code>Test</code> suite that executes all tests inside this
+     * package.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite("org.apache.jackrabbit.api.jsr283.retention tests");
+
+        suite.addTestSuite(HoldTest.class);
+        suite.addTestSuite(HoldEffectTest.class);
+        suite.addTestSuite(RetentionPolicyTest.class);
+        suite.addTestSuite(RetentionPolicyEffectTest.class);
+
+        return suite;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/TestAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/TestAll.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/RSessionAccessControlTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/RSessionAccessControlTest.java?rev=738422&r1=738421&r2=738422&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/RSessionAccessControlTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/RSessionAccessControlTest.java Wed Jan 28 09:50:50 2009
@@ -19,12 +19,14 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.RepositoryStub;
 
 import javax.jcr.Node;
 import javax.jcr.Property;
 import javax.jcr.Session;
 import javax.jcr.RepositoryException;
 import javax.jcr.AccessDeniedException;
+import javax.jcr.Value;
 
 /** <code>RSessionAccessControlTest</code>... */
 public class RSessionAccessControlTest extends AbstractJCRTest {
@@ -39,7 +41,8 @@
         super.setUp();
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         testNodePath = n.getPath();
-        Property p = n.setProperty(propertyName1, "value");
+        Value v = getJcrValue(superuser, RepositoryStub.PROP_PROP_VALUE1, RepositoryStub.PROP_PROP_TYPE1, "test");
+        Property p = n.setProperty(propertyName1, v);
         testPropertyPath = p.getPath();
         testRootNode.save();
 

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/RetentionRegistryImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/RetentionRegistryImplTest.java?rev=738422&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/RetentionRegistryImplTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/RetentionRegistryImplTest.java Wed Jan 28 09:50:50 2009
@@ -0,0 +1,348 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.core;
+
+import org.apache.jackrabbit.api.jsr283.retention.AbstractRetentionTest;
+import org.apache.jackrabbit.api.jsr283.retention.Hold;
+import org.apache.jackrabbit.core.retention.RetentionRegistryImpl;
+import org.apache.jackrabbit.core.retention.RetentionRegistry;
+import org.apache.jackrabbit.core.fs.FileSystem;
+import org.apache.jackrabbit.core.fs.FileSystemResource;
+import org.apache.jackrabbit.core.fs.FileSystemException;
+import org.apache.jackrabbit.core.fs.mem.MemoryFileSystem;
+import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.RepositoryStub;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.io.IOException;
+
+/**
+ * <code>RetentionEvaluatorImplTest</code>...
+ */
+public class RetentionRegistryImplTest extends AbstractRetentionTest {
+
+    private static Logger log = LoggerFactory.getLogger(RetentionRegistryImplTest.class);
+
+    private Node childN;
+    private String childNPath;
+    private Node childN2;
+    private Node childN3;
+    private Property childP;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        if (!(superuser instanceof SessionImpl)) {
+            throw new NotExecutableException();
+        }
+
+        childN = testRootNode.addNode(nodeName1);
+        childNPath = childN.getPath();
+        childN2 = testRootNode.addNode(nodeName2);
+        childN3 = childN.addNode(nodeName3);
+
+        Value v = getJcrValue(superuser, RepositoryStub.PROP_PROP_VALUE1, RepositoryStub.PROP_PROP_TYPE1, "test");
+        childP = testRootNode.setProperty(propertyName1, v);
+        testRootNode.save();
+
+        retentionMgr.addHold(childNPath, getHoldName(), true);
+        retentionMgr.setRetentionPolicy(childNPath, getApplicableRetentionPolicy("test"));
+        
+        superuser.save();
+    }
+
+    protected void tearDown() throws Exception {        
+        try {
+            Hold[] hs = retentionMgr.getHolds(childNPath);
+            for (int i = 0; i < hs.length; i++) {
+                retentionMgr.removeHold(childNPath, hs[i]);
+            }
+            superuser.save();
+        } catch (RepositoryException e) {
+            log.error(e.getMessage());
+        }
+        try {
+            if (retentionMgr.getRetentionPolicy(childNPath) != null) {
+                retentionMgr.removeRetentionPolicy(childNPath);
+            }
+            superuser.save();
+        } catch (RepositoryException e) {
+            log.error(e.getMessage());
+        }
+        super.tearDown();
+    }
+
+    private FileSystem createFileSystem() {
+        FileSystem fs = new MemoryFileSystem();
+        BufferedWriter writer = null;        
+        try {
+            fs.createFolder("/");
+            FileSystemResource file = new FileSystemResource(fs, "/retention");
+
+            writer = new BufferedWriter(new OutputStreamWriter(file.getOutputStream()));
+            writer.write(((NodeImpl) childN).getNodeId().toString());
+        } catch (FileSystemException e) {
+            log.error(e.getMessage());
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        } finally {
+            IOUtils.closeQuietly(writer);
+        }
+        return fs;
+    }
+    
+    public void testReadHoldFromFile() throws RepositoryException {
+        PathResolver resolver = (SessionImpl) superuser;
+        RetentionRegistryImpl re = new RetentionRegistryImpl((SessionImpl) superuser, createFileSystem());
+        try {
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), false));
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childN3.getPath()), false));
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/somechild"), false));
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/hold/is/deep"), false));
+
+            assertFalse(re.hasEffectiveHold(resolver.getQPath(testNodePath), false));
+            assertFalse(re.hasEffectiveHold(resolver.getQPath(childN2.getPath()), false));
+
+        } finally {
+            re.close();
+        }
+    }
+
+    public void testReadRetentionFromFile() throws RepositoryException {
+        SessionImpl s = (SessionImpl) helper.getSuperuserSession();
+        RetentionRegistryImpl re = new RetentionRegistryImpl(s, createFileSystem());
+        try {
+            assertTrue(re.hasEffectiveRetention(s.getQPath(childNPath), false));
+            assertTrue(re.hasEffectiveRetention(s.getQPath(childNPath + "/somechild"), true));
+
+            assertFalse(re.hasEffectiveRetention(s.getQPath(testNodePath), false));
+            assertFalse(re.hasEffectiveRetention(s.getQPath(childNPath + "/somechild"), false));
+            assertFalse(re.hasEffectiveRetention(s.getQPath(childNPath + "/somechild/deepchild"), true));
+            assertFalse(re.hasEffectiveRetention(s.getQPath(childP.getPath()), false));
+
+        } finally {
+            re.close();
+            s.logout();
+        }
+    }
+
+    public void testWriteFile() throws RepositoryException {
+        PathResolver resolver = (SessionImpl) superuser;
+        FileSystem fs = createFileSystem();
+        RetentionRegistryImpl re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
+
+        try {
+            // write the changes to the fs
+            re.close();
+
+            // create a new dummy registry again.
+            re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
+
+            // test holds
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), false));
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childN3.getPath()), false));
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/somechild"), false));
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/hold/is/deep"), false));
+
+            // test policies
+            assertTrue(re.hasEffectiveRetention(resolver.getQPath(childNPath), false));
+            assertTrue(re.hasEffectiveRetention(resolver.getQPath(childNPath + "/somechild"), true));
+        } finally {
+            re.close();
+        }
+    }
+
+    public void testWriteFileWithChanges() throws RepositoryException, NotExecutableException {
+        PathResolver resolver = (SessionImpl) superuser;
+        FileSystem fs = createFileSystem();
+        RetentionRegistryImpl re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
+        String childN3Path = childN3.getPath();
+        try {
+            retentionMgr.removeRetentionPolicy(childNPath);
+            retentionMgr.removeHold(childNPath, retentionMgr.getHolds(childNPath)[0]);
+            superuser.save();
+            
+            retentionMgr.setRetentionPolicy(childN3Path, getApplicableRetentionPolicy("retentionOnChild2"));
+            retentionMgr.addHold(childNPath, "holdOnChild", false);
+            superuser.save();
+
+            // write the changes to the fs
+            re.close();
+
+            // create a new dummy registry again.
+            re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
+
+            // test holds
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), false));
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), true));
+            assertTrue(re.hasEffectiveHold(resolver.getQPath(childN3Path), true));
+
+            assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path), false));
+            assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path + "/child"), false));
+            assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path + "/child"), true));
+
+            // test policies
+            assertTrue(re.hasEffectiveRetention(resolver.getQPath(childN3Path), false));
+            assertTrue(re.hasEffectiveRetention(resolver.getQPath(childN3Path + "/child"), true));
+
+            assertFalse(re.hasEffectiveRetention(resolver.getQPath(childN3Path + "/child/more"), true));
+            assertFalse(re.hasEffectiveRetention(resolver.getQPath(childNPath), true));
+            assertFalse(re.hasEffectiveRetention(resolver.getQPath(childNPath), false));
+        } finally {
+            re.close();
+            // remove the extra policy that is not cleared upon teardown
+            if (retentionMgr.getRetentionPolicy(childN3Path) != null) {
+                retentionMgr.removeRetentionPolicy(childN3.getPath());
+            }
+            superuser.save();
+        }
+    }
+
+    public void testRemoveHold() throws RepositoryException {
+        SessionImpl s = (SessionImpl) helper.getSuperuserSession();
+        RetentionRegistry re = s.getRetentionRegistry();
+        try {
+            Hold[] holds = retentionMgr.getHolds(childNPath);
+            for (int i = 0; i < holds.length; i++) {
+                retentionMgr.removeHold(childNPath, holds[i]);
+                // hold must still be in effect.
+                assertTrue(re.hasEffectiveHold(s.getQPath(childNPath), false));
+            }
+            superuser.save();
+            
+            assertFalse(re.hasEffectiveHold(s.getQPath(childNPath), false));
+
+        } finally {
+            s.logout();
+        }
+    }
+
+    public void testRemoveRetentionPolicy() throws RepositoryException {
+        SessionImpl s = (SessionImpl) helper.getSuperuserSession();
+        RetentionRegistry re = s.getRetentionRegistry();
+        try {
+            retentionMgr.removeRetentionPolicy(childNPath);
+            // retention must still be in effect.
+            assertTrue(re.hasEffectiveRetention(s.getQPath(childNPath), false));
+
+            superuser.save();
+
+            assertFalse(re.hasEffectiveRetention(s.getQPath(childNPath), false));
+
+        } finally {
+            s.logout();
+        }
+    }
+
+    public void testAddHold() throws RepositoryException, NotExecutableException {
+        SessionImpl s = (SessionImpl) helper.getSuperuserSession();
+        RetentionRegistry re = s.getRetentionRegistry();
+        Hold h = null;
+        try {
+            h = retentionMgr.addHold(childN2.getPath(), getHoldName(), false);
+            // hold must not be effective yet
+            assertFalse(re.hasEffectiveHold(s.getQPath(childN2.getPath()), false));
+
+            superuser.save();
+            assertTrue(re.hasEffectiveHold(s.getQPath(childN2.getPath()), false));
+
+        } finally {
+            s.logout();
+
+            if (h != null) {
+                retentionMgr.removeHold(childN2.getPath(), h);
+                superuser.save();
+            }
+        }
+    }
+
+    public void testAddMultipleHold() throws RepositoryException, NotExecutableException {
+        SessionImpl s = (SessionImpl) helper.getSuperuserSession();
+        RetentionRegistry re = s.getRetentionRegistry();
+        try {
+            retentionMgr.addHold(childN2.getPath(), getHoldName(), false);
+            superuser.save();
+
+            // hold is not deep -> only applies to childN2
+            assertTrue(re.hasEffectiveHold(s.getQPath(childN2.getPath()), false));
+            assertFalse(re.hasEffectiveHold(s.getQPath(childN2.getPath() + "/child"), false));
+
+            retentionMgr.addHold(childN2.getPath(), getHoldName(), true);
+            superuser.save();
+
+            // now deep hold must be taken into account
+            assertTrue(re.hasEffectiveHold(s.getQPath(childN2.getPath()), false));
+            assertTrue(re.hasEffectiveHold(s.getQPath(childN2.getPath() + "/child"), false));
+
+        } finally {
+            s.logout();
+
+            Hold[] hdls = retentionMgr.getHolds(childN2.getPath());
+            for (int i = 0; i < hdls.length; i++) {
+                retentionMgr.removeHold(childN2.getPath(), hdls[i]);
+            }
+            superuser.save();            
+        }
+    }
+
+    public void testSetRetentionPolicy() throws RepositoryException, NotExecutableException {
+        SessionImpl s = (SessionImpl) helper.getSuperuserSession();
+        RetentionRegistry re = s.getRetentionRegistry();
+        try {
+            retentionMgr.setRetentionPolicy(childN2.getPath(), getApplicableRetentionPolicy("test2"));
+            // retention must not be effective yet
+            assertFalse(re.hasEffectiveRetention(s.getQPath(childN2.getPath()), false));
+
+            superuser.save();
+            assertTrue(re.hasEffectiveRetention(s.getQPath(childN2.getPath()), false));
+
+        } finally {
+            s.logout();
+
+            retentionMgr.removeRetentionPolicy(childN2.getPath());
+            superuser.save();
+        }
+    }
+
+    public void testChangeRetentionPolicy() throws RepositoryException, NotExecutableException {
+        SessionImpl s = (SessionImpl) helper.getSuperuserSession();
+        RetentionRegistry re = s.getRetentionRegistry();
+        try {
+            retentionMgr.setRetentionPolicy(childN2.getPath(), getApplicableRetentionPolicy("test2"));
+            superuser.save();
+            retentionMgr.setRetentionPolicy(childN2.getPath(), getApplicableRetentionPolicy("test3"));
+            superuser.save();
+
+            assertTrue(re.hasEffectiveRetention(s.getQPath(childN2.getPath()), false));
+
+        } finally {
+            s.logout();
+
+            retentionMgr.removeRetentionPolicy(childN2.getPath());
+            superuser.save();
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/RetentionRegistryImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/RetentionRegistryImplTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java?rev=738422&r1=738421&r2=738422&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java Wed Jan 28 09:50:50 2009
@@ -38,6 +38,7 @@
         suite.addTestSuite(XATest.class);
         suite.addTestSuite(RestoreAndCheckoutTest.class);
         suite.addTestSuite(NodeImplTest.class);
+        suite.addTestSuite(RetentionRegistryImplTest.class);
 
         return suite;
     }

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/HoldTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/HoldTest.java?rev=738422&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/HoldTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/HoldTest.java Wed Jan 28 09:50:50 2009
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.core.retention;
+
+import org.apache.jackrabbit.api.jsr283.retention.AbstractRetentionTest;
+import org.apache.jackrabbit.api.jsr283.retention.Hold;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Implementation specific hold tests.
+ */
+public class HoldTest extends AbstractRetentionTest {
+
+    private static Logger log = LoggerFactory.getLogger(HoldTest.class);
+
+    protected void tearDown() throws Exception {
+        try {
+            superuser.refresh(false);
+            Hold[] holds = retentionMgr.getHolds(testNodePath);
+            for (int i = 0; i < holds.length; i++) {
+                retentionMgr.removeHold(testNodePath, holds[i]);
+            }
+            superuser.save();
+        } catch (RepositoryException e) {
+            log.error(e.getMessage());
+        }
+
+        super.tearDown();
+    }
+
+    public void testAddHoldTwice() throws RepositoryException, NotExecutableException {
+        Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
+
+        try {
+            retentionMgr.addHold(testNodePath, getHoldName(), true);
+            fail("cannot add the same hold twice");
+        } catch (RepositoryException e) {
+            // success
+        }
+
+        superuser.save();
+        try {
+            retentionMgr.addHold(testNodePath, getHoldName(), true);
+            fail("cannot add the same hold twice");
+        } catch (RepositoryException e) {
+            // success
+        }        
+    }
+    
+    public void testRemoveInvalidHold() throws RepositoryException, NotExecutableException {
+        final Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
+
+        try {
+            Hold invalidH = new Hold() {
+                public boolean isDeep() throws RepositoryException {
+                    return h.isDeep();
+                }
+                public String getName() throws RepositoryException {
+                    return h.getName();
+                }
+            };
+            retentionMgr.removeHold(testNodePath, invalidH);
+            fail("An invalid hold impl. should not be removable.");
+
+        } catch (RepositoryException e) {
+            // success
+        }
+    }
+
+    public void testRemoveInvalidHold2() throws RepositoryException, NotExecutableException {
+        final Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
+
+        try {
+            Hold invalidH = new Hold() {
+                public boolean isDeep() throws RepositoryException {
+                    return h.isDeep();
+                }
+                public String getName() throws RepositoryException {
+                    return "anyName";
+                }
+            };
+            retentionMgr.removeHold(testNodePath, invalidH);
+            fail("An invalid hold impl. should not be removable.");
+
+        } catch (RepositoryException e) {
+            // success
+        }
+    }
+
+    public void testRemoveInvalidHold3() throws RepositoryException, NotExecutableException {
+        final Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
+
+        try {
+            Hold invalidH = new Hold() {
+                public boolean isDeep() throws RepositoryException {
+                    return !h.isDeep();
+                }
+                public String getName() throws RepositoryException {
+                    return h.getName();
+                }
+            };
+            retentionMgr.removeHold(testNodePath, invalidH);
+            fail("An invalid hold impl. should not be removable.");
+
+        } catch (RepositoryException e) {
+            // success
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/HoldTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/HoldTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/RetentionPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/RetentionPolicyTest.java?rev=738422&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/RetentionPolicyTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/RetentionPolicyTest.java Wed Jan 28 09:50:50 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.core.retention;
+
+import org.apache.jackrabbit.api.jsr283.retention.AbstractRetentionTest;
+import org.apache.jackrabbit.api.jsr283.retention.RetentionPolicy;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>RetentionPolicyTest</code>...
+ */
+public class RetentionPolicyTest extends AbstractRetentionTest {
+
+    public void testSetInvalidRetentionPolicy() {
+        try {
+            RetentionPolicy invalidRPolicy = new RetentionPolicy() {
+                public String getName() throws RepositoryException {
+                    return "anyName";
+                }
+            };
+            retentionMgr.setRetentionPolicy(testNodePath, invalidRPolicy);
+            fail("Setting an invalid retention policy must fail.");
+        } catch (RepositoryException e) {
+            // success
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/RetentionPolicyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/RetentionPolicyTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/TestAll.java?rev=738422&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/TestAll.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/TestAll.java Wed Jan 28 09:50:50 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.core.retention;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite that includes all testcases for package org.apache.jackrabbit.core.retention.
+ */
+public class TestAll extends TestCase {
+
+    /**
+     * Returns a <code>Test</code> suite that executes all tests inside this
+     * package.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite("org.apache.jackrabbit.core.retention tests");
+
+        suite.addTestSuite(HoldTest.class);
+        suite.addTestSuite(RetentionPolicyTest.class);
+
+        return suite;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/TestAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/retention/TestAll.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/jackrabbit-core/src/test/resources/repositoryStubImpl.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/resources/repositoryStubImpl.properties?rev=738422&r1=738421&r2=738422&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/resources/repositoryStubImpl.properties (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/resources/repositoryStubImpl.properties Wed Jan 28 09:50:50 2009
@@ -43,12 +43,19 @@
 javax.jcr.tck.nodename4=node4
 javax.jcr.tck.propertyname1=prop1
 javax.jcr.tck.propertyname2=prop2
+javax.jcr.tck.propertyvalue1=value1
+javax.jcr.tck.propertyvalue2=value2
+#javax.jcr.tck.propertytype1=String
+#javax.jcr.tck.propertytype2=String
 javax.jcr.tck.workspacename=test
 
 # namespace configuration
 javax.jcr.tck.namespaces=test
 javax.jcr.tck.namespaces.test=http://www.apache.org/jackrabbit/test
 
+# retention and hold
+javax.jcr.tck.holdname=hold
+
 # sample for per test case config overriding
 # Test class: AddNodeText
 # Test method: testName



Mime
View raw message