jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r164762 - in /incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api: NodeAddMixinTest.java version/SessionMoveVersionExceptionTest.java version/TestAll.java version/WorkspaceMoveVersionExceptionTest.java
Date Tue, 26 Apr 2005 07:46:55 GMT
Author: mreutegg
Date: Tue Apr 26 00:46:54 2005
New Revision: 164762

URL: http://svn.apache.org/viewcvs?rev=164762&view=rev
Log:
Add more test cases, contributed by Mirko Sagolj.

Added:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/SessionMoveVersionExceptionTest.java
  (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceMoveVersionExceptionTest.java
  (with props)
Modified:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java?rev=164762&r1=164761&r2=164762&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
Tue Apr 26 00:46:54 2005
@@ -26,6 +26,7 @@
 import javax.jcr.Node;
 import javax.jcr.Value;
 import javax.jcr.Repository;
+import javax.jcr.ValueFormatException;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 
@@ -206,4 +207,48 @@
         }
     }
 
-}
\ No newline at end of file
+    /**
+     * Tests if adding mix:referenceable automatically populates the jcr:uuid
+     * value.
+     */
+    public void testAddMixinReferencable()
+            throws NotExecutableException, RepositoryException {
+
+        // check if repository supports references
+        checkMixReferenceable();
+
+        // get session an create default node
+        Node node = testRootNode.addNode(nodeName1, testNodeType);
+
+        node.addMixin(mixReferenceable);
+
+        // test if jcr:uuid is not null, empty or throws a exception
+        // (format of value is not defined so we can only test if not empty)
+        try {
+            String uuid = node.getProperty(jcrUUID).getValue().getString();
+            // default value is null so check for null
+            assertNotNull("Acessing jcr:uuid after assginment of mix:referencable returned
null", uuid);
+            // check if it was not set to an empty string
+            assertTrue("Acessing jcr:uuid after assginment of mix:referencable returned an
empty String!", uuid.length() > 0);
+        } catch (ValueFormatException e) {
+            // trying to access the uuid caused an exception
+            fail("Acessing jcr:uuid after assginment of mix:referencable caused an ValueFormatException!");
+        }
+    }
+
+
+    /**
+     * Checks if the repository supports the mixin mix:Referenceable otherwise a
+     * {@link NotExecutableException} is thrown.
+     *
+     * @throws NotExecutableException if the repository does not support the
+     *                                mixin mix:referenceable.
+     */
+    private void checkMixReferenceable() throws RepositoryException, NotExecutableException
{
+        try {
+            superuser.getWorkspace().getNodeTypeManager().getNodeType(mixReferenceable);
+        } catch (NoSuchNodeTypeException e) {
+            throw new NotExecutableException("Repository does not support mix:referenceable");
+        }
+    }
+}

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/SessionMoveVersionExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/SessionMoveVersionExceptionTest.java?rev=164762&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/SessionMoveVersionExceptionTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/SessionMoveVersionExceptionTest.java
Tue Apr 26 00:46:54 2005
@@ -0,0 +1,76 @@
+/*
+ * 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.VersionException;
+
+/**
+ * <code>SessionMoveVersionExceptionTest</code> contains tests dealing with
+ * moving nodes using {@link javax.jcr.Session#move(String, String)}.
+ *
+ * @test
+ * @sources SessionMoveVersionExceptionTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.SessionMoveVersionExceptionTest
+ * @keywords versioning
+ */
+public class SessionMoveVersionExceptionTest extends AbstractVersionTest {
+
+    /**
+     * Tries to move a node using {@link javax.jcr.Session#move(String, String)}
+     * where the source parent is checked in. This should throw an {@link
+     * javax.jcr.version.VersionException}.
+     */
+    public void testSessionMoveSourceCheckedInVersionException() throws RepositoryException
{
+        // add a node under a versionable node
+        Node movingNode = versionableNode.addNode(nodeName1, nonVersionableNodeType.getName());
+        versionableNode.save();
+        // check the parent node in
+        versionableNode.checkin();
+        try {
+            // try to move the sub node this should throw an VersionException
+            // either instantly or upon save()
+            superuser.move(movingNode.getPath(), nonVersionableNode.getPath());
+            superuser.save();
+            fail("Moving a node using Session.move() where parent node is " +
+                    "versionable and checked in should throw a VersionException!");
+        } catch (VersionException e) {
+            // ok, works as expected
+        }
+    }
+
+    /**
+     * Tries to move a node using {@link javax.jcr.Session#move(String, String)}
+     * where the destination parent is checked in. This should throw an {@link
+     * javax.jcr.version.VersionException}.
+     */
+    public void testSessionMoveDestCheckedInVersionException() throws RepositoryException
{
+        // make sure versionable node is checked in
+        versionableNode.checkin();
+
+        try {
+            // try to move the sub node this should throw an VersionException either instantly
or upon save()
+            superuser.move(nonVersionableNode.getPath(), versionableNode.getPath() + "/"
+ nodeName1);
+            superuser.save();
+            fail("Moving a node using Session.save() where destination parent " +
+                    "node is versionable and checked in should throw a VersionException!");
+        } catch (VersionException e) {
+            // ok, works as expected
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/SessionMoveVersionExceptionTest.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?rev=164762&r1=164761&r2=164762&view=diff
==============================================================================
--- 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
Tue Apr 26 00:46:54 2005
@@ -56,6 +56,8 @@
         suite.addTestSuite(GetCreatedTest.class);
         suite.addTestSuite(GetContainingHistoryTest.class);
         suite.addTestSuite(GetVersionableUUIDTest.class);
+        suite.addTestSuite(SessionMoveVersionExceptionTest.class);
+        suite.addTestSuite(WorkspaceMoveVersionExceptionTest.class);
 
         return suite;
     }

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceMoveVersionExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceMoveVersionExceptionTest.java?rev=164762&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceMoveVersionExceptionTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/WorkspaceMoveVersionExceptionTest.java
Tue Apr 26 00:46:54 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 javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.version.VersionException;
+
+/**
+ * <code>WorkspaceMoveVersionExceptionTest</code> contains tests dealing with
+ * moving nodes using {@link javax.jcr.Workspace#move(String, String)}.
+ *
+ * @test
+ * @sources WorkspaceMoveVersionExceptionTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.WorkspaceMoveVersionExceptionTest
+ * @keywords versioning
+ */
+public class WorkspaceMoveVersionExceptionTest extends AbstractVersionTest {
+
+    /**
+     * Tries to move a node using {@link javax.jcr.Workspace#move(String, String)}
+     * where the source parent is checked in. This should throw an
+     * {@link javax.jcr.version.VersionException}.
+     */
+    public void testWorkspaceMoveSourceCheckedInVersionException() throws RepositoryException
{
+        // add a node under a versionable node
+        Node movingNode = versionableNode.addNode(nodeName1, nonVersionableNodeType.getName());
+        versionableNode.save();
+        // check the parent node in
+        versionableNode.checkin();
+        try {
+            // try to move the sub node this should throw an VersionException either instantly
or upon save()
+            superuser.getWorkspace().move(movingNode.getPath(), nonVersionableNode.getPath());
+            fail("Moving a node using Workspace.move() where parent node is " +
+                    "versionable and checked in should throw a VersionException!");
+        } catch (VersionException e) {
+            // ok, works as expected
+        }
+    }
+
+    /**
+     * Tries to move a node using {@link javax.jcr.Workspace#move(String, String)}
+     * where the destination parent is checked in. This should throw an
+     * {@link javax.jcr.version.VersionException}.
+     */
+    public void testWorkspaceMoveDestCheckedInVersionException() throws RepositoryException
{
+        // make sure versionable node is checked in
+        versionableNode.checkin();
+
+        try {
+            // try to move the sub node this should throw an VersionException either instantly
or upon save()
+            superuser.getWorkspace().move(nonVersionableNode.getPath(), versionableNode.getPath()
+ "/" + nodeName1);
+            fail("Moving a node using Workspace.move() where destination parent " +
+                    "node is versionable and checked in should throw a VersionException!");
+        } catch (VersionException e) {
+            // ok, works as expected
+        }
+    }
+}

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



Mime
View raw message