jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r424226 - in /jackrabbit/trunk/jackrabbit: ./ src/test/java/org/apache/jackrabbit/core/ src/test/java/org/apache/jackrabbit/core/xml/ src/test/java/org/apache/jackrabbit/test/ src/test/java/org/apache/jackrabbit/test/api/ src/test/java/org/...
Date Fri, 21 Jul 2006 08:25:09 GMT
Author: mreutegg
Date: Fri Jul 21 01:25:08 2006
New Revision: 424226

URL: http://svn.apache.org/viewvc?rev=424226&view=rev
Log:
JCR-485: TCK does not clean 2nd workspace during AbstractJCRTest.setUp()

Modified:
    jackrabbit/trunk/jackrabbit/project.properties
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/XATest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/DocumentViewTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/AbstractJCRTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/JCRTestResult.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/version/AbstractMergeTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/value/BinaryValueTest.java

Modified: jackrabbit/trunk/jackrabbit/project.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/project.properties?rev=424226&r1=424225&r2=424226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/project.properties (original)
+++ jackrabbit/trunk/jackrabbit/project.properties Fri Jul 21 01:25:08 2006
@@ -27,10 +27,11 @@
 maven.test.failure = false
 maven.junit.fork=true
 maven.junit.jvmargs=-Xmx128m -enableassertions
-maven.junit.sysproperties=derby.system.durability JCR-320 JCR-325
+maven.junit.sysproperties=derby.system.durability known.issues
 derby.system.durability=test
-JCR-320=false
-JCR-325=false
+# space separated list of test cases that are known issues and will
+# not yield failures in a test run
+known.issues=org.apache.jackrabbit.core.xml.DocumentViewTest#testMultiValue org.apache.jackrabbit.value.BinaryValueTest#testBinaryValueEquals
 
 #If you wish to skip tests when doing builds, uncomment
 #maven.test.skip = true

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/XATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/XATest.java?rev=424226&r1=424225&r2=424226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/XATest.java (original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/XATest.java Fri Jul
21 01:25:08 2006
@@ -23,16 +23,12 @@
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.Session;
 import javax.jcr.RepositoryException;
-import javax.jcr.SimpleCredentials;
 import javax.jcr.NodeIterator;
-import javax.jcr.observation.Event;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.Version;
 import javax.jcr.lock.Lock;
 import javax.transaction.UserTransaction;
 import javax.transaction.RollbackException;
-import java.io.PrintWriter;
-import java.io.PrintStream;
 import java.util.StringTokenizer;
 
 /**
@@ -96,7 +92,6 @@
      * Make sure that tested repository supports transactions
      */
     protected void runTest() throws Throwable {
-        Repository rep = helper.getRepository();
         if (isSupported(Repository.OPTION_TRANSACTIONS_SUPPORTED)) {
             super.runTest();
         }

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/DocumentViewTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/DocumentViewTest.java?rev=424226&r1=424225&r2=424226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/DocumentViewTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/DocumentViewTest.java
Fri Jul 21 01:25:08 2006
@@ -30,8 +30,13 @@
 
 import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
 import org.apache.jackrabbit.core.TestRepository;
+import org.apache.jackrabbit.test.JCRTestResult;
+import org.apache.jackrabbit.test.LogPrintWriter;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
 
 import junit.framework.TestCase;
+import junit.framework.TestResult;
 
 /**
  * Jackrabbit-specific test cases for the document view XML format.
@@ -41,15 +46,29 @@
  */
 public class DocumentViewTest extends TestCase {
 
+    /** Logger instance for this class. */
+    private static final Logger log = LoggerFactory.getLogger(DocumentViewTest.class);
+
     /** Test session. */
     private Session session;
 
     /**
+     * Use a {@link org.apache.jackrabbit.test.JCRTestResult} to suppress test
+     * case failures of known issues.
+     *
+     * @param testResult the test result.
+     */
+    public void run(TestResult testResult) {
+        super.run(new JCRTestResult(testResult, new LogPrintWriter(log)));
+    }
+
+    /**
      * Sets up the test fixture.
      *
      * @throws Exception if an unexpected error occurs
      */
     protected void setUp() throws Exception {
+        super.setUp();
         session = TestRepository.getInstance().login();
         JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)
             session.getWorkspace().getNodeTypeManager();
@@ -72,6 +91,7 @@
         // TODO: Unregister the MultiValueTestType node type once Jackrabbit
         // supports node type removal.
         session.logout();
+        super.tearDown();
     }
 
     /**
@@ -104,10 +124,6 @@
      * @throws Exception if an unexpected error occurs
      */
     public void testMultiValue() throws Exception {
-        if (!Boolean.getBoolean("JCR-325")) {
-            return;
-        }
-
         String message = "JCR-325: docview roundtripping does not work with"
             + " multivalue non-string properties";
 

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=424226&r1=424225&r2=424226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/AbstractJCRTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/AbstractJCRTest.java
Fri Jul 21 01:25:08 2006
@@ -345,28 +345,14 @@
                 testRootNode = superuser.getRootNode().getNode(testPath);
             }
         } else {
-            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();
-                }
-            } else {
-                // create nodes to testPath
-                StringTokenizer names = new StringTokenizer(testPath, "/");
-                Node currentNode = root;
-                while (names.hasMoreTokens()) {
-                    String name = names.nextToken();
-                    if (currentNode.hasNode(name)) {
-                        currentNode = currentNode.getNode(name);
-                    } else {
-                        currentNode = currentNode.addNode(name, testNodeType);
-                    }
-                }
-                testRootNode = currentNode;
+            testRootNode = cleanUpTestRoot(superuser);
+            // also clean second workspace
+            Session s = helper.getSuperuserSession(workspaceName);
+            try {
+                cleanUpTestRoot(s);
+            } finally {
+                s.logout();
             }
-            root.save();
         }
     }
 
@@ -374,17 +360,7 @@
         if (superuser != null) {
             try {
                 if (!isReadOnly) {
-                    // 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();
-                    }
+                    cleanUpTestRoot(superuser);
                 }
             } catch (Exception e) {
                 log.println("Exception in tearDown: " + e.toString());
@@ -531,5 +507,43 @@
      */
     protected boolean isSupported(String descriptorKey) throws RepositoryException {
         return "true".equals(helper.getRepository().getDescriptor(descriptorKey));
+    }
+
+    /**
+     * Reverts any pending changes made by <code>s</code> and deletes any nodes
+     * under {@link #testRoot}. If there is no node at {@link #testRoot} then
+     * the necessary nodes are created.
+     *
+     * @param s the session to clean up.
+     * @return the {@link javax.jcr.Node} that represents the test root.
+     * @throws RepositoryException if an error occurs.
+     */
+    protected Node cleanUpTestRoot(Session s) throws RepositoryException {
+        // do a 'rollback'
+        s.refresh(false);
+        Node root = s.getRootNode();
+        Node testRootNode;
+        if (root.hasNode(testPath)) {
+            // clean test root
+            testRootNode = root.getNode(testPath);
+            for (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
+                children.nextNode().remove();
+            }
+        } else {
+            // create nodes to testPath
+            StringTokenizer names = new StringTokenizer(testPath, "/");
+            Node currentNode = root;
+            while (names.hasMoreTokens()) {
+                String name = names.nextToken();
+                if (currentNode.hasNode(name)) {
+                    currentNode = currentNode.getNode(name);
+                } else {
+                    currentNode = currentNode.addNode(name, testNodeType);
+                }
+            }
+            testRootNode = currentNode;
+        }
+        s.save();
+        return testRootNode;
     }
 }

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/JCRTestResult.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/JCRTestResult.java?rev=424226&r1=424225&r2=424226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/JCRTestResult.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/JCRTestResult.java
Fri Jul 21 01:25:08 2006
@@ -20,8 +20,12 @@
 import junit.framework.Test;
 import junit.framework.AssertionFailedError;
 import junit.framework.TestListener;
+import junit.framework.TestCase;
 
 import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
 
 /**
  * Extends the standard JUnit TestResult class. This class ignores test errors
@@ -36,6 +40,12 @@
     private final LogPrintWriter log;
 
     /**
+     * Set of Strings that identify the test methods that currently fails but
+     * are recognized as known issues. Those will not be reported as errors.
+     */
+    private final Set knownIssues = new HashSet();
+
+    /**
      * Creates a new JCRTestResult that delegates to <code>orig</code>.
      * @param orig the original TestResult this result wraps.
      * @param log the logger
@@ -43,28 +53,47 @@
     public JCRTestResult(TestResult orig, LogPrintWriter log) {
         this.orig = orig;
         this.log = log;
+        String propValue = System.getProperty("known.issues");
+        if (propValue != null) {
+            StringTokenizer tok = new StringTokenizer(propValue);
+            while (tok.hasMoreTokens()) {
+                knownIssues.add(tok.nextToken());
+            }
+        }
     }
 
     /**
      * Only add an error if <code>throwable</code> is not of type
-     * {@link NotExecutableException}.
+     * {@link NotExecutableException} and the test case is not a known issue.
      * @param test the test.
      * @param throwable the exception thrown by the test.
      */
     public synchronized void addError(Test test, Throwable throwable) {
         if (throwable instanceof NotExecutableException) {
             log.println("Test case: " + test.toString() + " not executable: " + throwable.getMessage());
+        } else if (isKnownIssue(test)) {
+            log.println("Known issue: " + test + ": " + throwable.getMessage());
         } else {
             orig.addError(test, throwable);
         }
     }
 
-    //-----------------------< default overwrites >-----------------------------
-
-    public synchronized void addFailure(Test test, AssertionFailedError assertionFailedError)
{
-        orig.addFailure(test, assertionFailedError);
+    /**
+     * Only adds a failure if <code>test</code> is not a known issue.
+     * @param test the test case that failed.
+     * @param assertionFailedError the assertion error.
+     */
+    public synchronized void addFailure(Test test,
+                                        AssertionFailedError assertionFailedError) {
+        if (isKnownIssue(test)) {
+            log.println("Known issue: " + test + ": " + assertionFailedError.getMessage());
+        } else {
+            orig.addFailure(test, assertionFailedError);
+        }
     }
 
+    //-----------------------< default overwrites >-----------------------------
+
     public synchronized void addListener(TestListener testListener) {
         orig.addListener(testListener);
     }
@@ -111,5 +140,21 @@
 
     public synchronized boolean wasSuccessful() {
         return orig.wasSuccessful();
+    }
+
+    //------------------------------< internal >--------------------------------
+
+    /**
+     * Returns <code>true</code> if <code>test</code> is a known
issue;
+     * <code>false</code> otherwise.
+     * @param test the test case to check.
+     * @return <code>true</code> if <code>test</code> is a known
issue.
+     */
+    private boolean isKnownIssue(Test test) {
+        String testName = "-";
+        if (test instanceof TestCase) {
+            testName = test.getClass().getName() + "#" + ((TestCase) test).getName();
+        }
+        return knownIssues.contains(testName);
     }
 }

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java?rev=424226&r1=424225&r2=424226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
Fri Jul 21 01:25:08 2006
@@ -76,17 +76,7 @@
             try {
                 if (!isReadOnly) {
                     // do a 'rollback'
-                    superuserW2.refresh(false);
-                    Node rootW2 = superuserW2.getRootNode();
-                    if (rootW2.hasNode(testPath)) {
-                        // clean test root
-                        testRootNodeW2 = rootW2.getNode(testPath);
-                        for (NodeIterator children = testRootNodeW2.getNodes(); children.hasNext();)
{
-                            Node n = children.nextNode();
-                            n.remove();
-                        }
-                        superuserW2.save();
-                    }
+                    cleanUpTestRoot(superuserW2);
                 }
             } finally {
                 superuserW2.logout();

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java?rev=424226&r1=424225&r2=424226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/NodeTest.java
Fri Jul 21 01:25:08 2006
@@ -22,7 +22,6 @@
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.Session;
 import javax.jcr.Node;
-import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.ItemNotFoundException;
@@ -31,7 +30,6 @@
 import javax.jcr.PathNotFoundException;
 import javax.jcr.Repository;
 import javax.jcr.lock.LockException;
-import java.util.StringTokenizer;
 
 /**
  * <code>NodeTest</code> contains all test cases for the
@@ -56,22 +54,6 @@
 
         // login to second workspace
         superuserW2 = helper.getSuperuserSession(workspaceName);
-        // create the test root node
-        Node root = superuserW2.getRootNode();
-        if (root.hasNode(testPath)) {
-            // clean test root
-            Node testNode = root.getNode(testPath);
-            for (NodeIterator children = testNode.getNodes(); children.hasNext();) {
-                children.nextNode().remove();
-            }
-        } else {
-            StringTokenizer names = new StringTokenizer(testPath, "/");
-            Node currentNode = superuserW2.getRootNode();
-            while (names.hasMoreTokens()) {
-                currentNode = currentNode.addNode(names.nextToken(), testNodeType);
-            }
-        }
-        superuserW2.save();
     }
 
     /**
@@ -79,13 +61,7 @@
      */
     public void tearDown() throws Exception {
         try {
-            // delete all children of test root node
-            Node rootNodeW2 = (Node) superuserW2.getItem(testRootNode.getPath());
-            for (NodeIterator children = rootNodeW2.getNodes(); children.hasNext();) {
-                children.nextNode().remove();
-            }
-            // save changes
-            superuserW2.save();
+            cleanUpTestRoot(superuserW2);
             // log out
             superuserW2.logout();
         } catch (RepositoryException e) {

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/version/AbstractMergeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/version/AbstractMergeTest.java?rev=424226&r1=424225&r2=424226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/version/AbstractMergeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/version/AbstractMergeTest.java
Fri Jul 21 01:25:08 2006
@@ -103,15 +103,7 @@
         workspaceW2 = superuserW2.getWorkspace();
 
         // get/create test root node on second workspace
-        if (testPath.length() == 0) {
-            // test root is the root node
-            testRootNodeW2 = superuserW2.getRootNode();
-        } else if (!superuserW2.getRootNode().hasNode(testPath)) {
-            testRootNodeW2 = superuserW2.getRootNode().addNode(testPath, testNodeType);
-            superuserW2.save();
-        } else {
-            testRootNodeW2 = superuserW2.getRootNode().getNode(testPath);
-        }
+        testRootNodeW2 = cleanUpTestRoot(superuserW2);
 
         // initialize test nodes
         initNodes();
@@ -127,17 +119,7 @@
         if (superuserW2 != null) {
             try {
                 if (!isReadOnly) {
-                    // do a 'rollback'
-                    superuserW2.refresh(false);
-                    Node rootW2 = superuserW2.getRootNode();
-                    if (rootW2.hasNode(testPath)) {
-                        // clean test root
-                        testRootNodeW2 = rootW2.getNode(testPath);
-                        for (NodeIterator children = testRootNodeW2.getNodes(); children.hasNext();)
{
-                            children.nextNode().remove();
-                        }
-                        rootW2.save();
-                    }
+                    cleanUpTestRoot(superuserW2);
                 }
             } finally {
                 superuserW2.logout();

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/value/BinaryValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/value/BinaryValueTest.java?rev=424226&r1=424225&r2=424226&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/value/BinaryValueTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/value/BinaryValueTest.java
Fri Jul 21 01:25:08 2006
@@ -18,12 +18,12 @@
 
 import java.io.ByteArrayInputStream;
 
-import junit.framework.TestCase;
+import org.apache.jackrabbit.test.AbstractJCRTest;
 
 /**
  * Test cases for binary values.
  */
-public class BinaryValueTest extends TestCase {
+public class BinaryValueTest extends AbstractJCRTest {
 
     private static final byte[] DATA = "abc".getBytes();
 
@@ -31,17 +31,15 @@
         assertFalse(new BinaryValue(DATA).equals(null));
         assertFalse(new BinaryValue(DATA).equals(new Object()));
 
-        if (Boolean.getBoolean("JCR-320")) {
-            assertTrue(new BinaryValue(DATA).equals(new BinaryValue(DATA)));
-            assertTrue(new BinaryValue(DATA).equals(
-                    new BinaryValue(new ByteArrayInputStream(DATA))));
-            assertTrue(new BinaryValue(new ByteArrayInputStream(DATA)).equals(
-                    new BinaryValue(DATA)));
-            assertTrue(new BinaryValue(DATA).equals(
-                    new BinaryValue(new String(DATA))));
-            assertTrue(new BinaryValue(new String(DATA)).equals(
-                    new BinaryValue(DATA)));
-        }
+        assertTrue(new BinaryValue(DATA).equals(new BinaryValue(DATA)));
+        assertTrue(new BinaryValue(DATA).equals(
+                new BinaryValue(new ByteArrayInputStream(DATA))));
+        assertTrue(new BinaryValue(new ByteArrayInputStream(DATA)).equals(
+                new BinaryValue(DATA)));
+        assertTrue(new BinaryValue(DATA).equals(
+                new BinaryValue(new String(DATA))));
+        assertTrue(new BinaryValue(new String(DATA)).equals(
+                new BinaryValue(DATA)));
     }
 
 }



Mime
View raw message