jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r151143 - in incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test: AbstractJCRTest.java api/AddNodeTest.java api/GetAncestorTest.java api/RootNodeTest.java
Date Thu, 03 Feb 2005 11:16:16 GMT
Author: mreutegg
Date: Thu Feb  3 03:16:13 2005
New Revision: 151143

URL: http://svn.apache.org/viewcvs?view=rev&rev=151143
Log:
Make sure no content is created in a level 1 repository.

Modified:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/GetAncestorTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RootNodeTest.java

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=151142&r2=151143
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java Thu
Feb  3 03:16:13 2005
@@ -146,11 +146,17 @@
     protected String workspaceName;
 
     /**
-     * The superuser session
+     * The superuser session for the default workspace
      */
     protected Session superuser;
 
     /**
+     * Flag that indicates if the current test is a level1 test, that is
+     * the workspace is read-only.
+     */
+    protected boolean isLevel1Test = false;
+
+    /**
      * The root <code>Node</code> for testing
      */
     protected Node testRootNode;
@@ -226,29 +232,11 @@
             }
         }
 
-        Node root = superuser.getRootNode();
-        if (root.hasNode(testPath)) {
-            // clean test root
-            testRootNode = root.getNode(testPath);
-            for (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
-                children.nextNode().remove();
+        if (isLevel1Test) {
+            if (!superuser.getRootNode().hasNode(testPath)) {
+                fail("Workspace does not contain test data at: " + testRoot);
             }
         } else {
-            // create nodes to testPath
-            StringTokenizer names = new StringTokenizer(testPath, "/");
-            Node currentNode = root;
-            while (names.hasMoreTokens()) {
-                currentNode = currentNode.addNode(names.nextToken(), testNodeType);
-            }
-            testRootNode = currentNode;
-        }
-        root.save();
-    }
-
-    protected void tearDown() throws Exception {
-        if (superuser != null) {
-            // do a 'rollback'
-            superuser.refresh(false);
             Node root = superuser.getRootNode();
             if (root.hasNode(testPath)) {
                 // clean test root
@@ -256,9 +244,38 @@
                 for (NodeIterator children = testRootNode.getNodes(); children.hasNext();)
{
                     children.nextNode().remove();
                 }
-                root.save();
+            } else {
+                // create nodes to testPath
+                StringTokenizer names = new StringTokenizer(testPath, "/");
+                Node currentNode = root;
+                while (names.hasMoreTokens()) {
+                    currentNode = currentNode.addNode(names.nextToken(), testNodeType);
+                }
+                testRootNode = currentNode;
+            }
+            root.save();
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        if (superuser != null) {
+            try {
+                if (!isLevel1Test) {
+                    // do a 'rollback'
+                    superuser.refresh(false);
+                    Node root = superuser.getRootNode();
+                    if (root.hasNode(testPath)) {
+                        // clean test root
+                        testRootNode = root.getNode(testPath);
+                        for (NodeIterator children = testRootNode.getNodes(); children.hasNext();)
{
+                            children.nextNode().remove();
+                        }
+                        root.save();
+                    }
+                }
+            } finally {
+                superuser.logout();
             }
-            superuser.logout();
         }
     }
 

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=151142&r2=151143
==============================================================================
--- 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 Thu
Feb  3 03:16:13 2005
@@ -32,7 +32,7 @@
  * @test
  * @sources AddNodeTest.java
  * @executeClass org.apache.jackrabbit.test.api.AddNodeTest
- * @keywords level1
+ * @keywords level2
  */
 public class AddNodeTest extends AbstractJCRTest {
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/GetAncestorTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/GetAncestorTest.java?view=diff&r1=151142&r2=151143
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/GetAncestorTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/GetAncestorTest.java
Thu Feb  3 03:16:13 2005
@@ -33,6 +33,7 @@
     protected Item item;
 
     protected void setUp() throws Exception {
+        isLevel1Test = true;
         super.setUp();
         item = helper.getReadOnlySession().getRootNode();
     }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RootNodeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RootNodeTest.java?view=diff&r1=151142&r2=151143
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RootNodeTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/RootNodeTest.java Thu
Feb  3 03:16:13 2005
@@ -35,6 +35,7 @@
     Node rootNode;
 
     protected void setUp() throws Exception {
+        isLevel1Test = true;
         super.setUp();
         rootNode = helper.getReadOnlySession().getRootNode();
     }



Mime
View raw message