Author: mreutegg
Date: Fri Feb 21 21:38:19 2014
New Revision: 1570717

URL: http://svn.apache.org/r1570717
Log:
OAK-1385: Occasional ConcurrentFileOperationsTest failure
- dump tree when session save fails

Modified:
    
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentFileOperationsTest.java

Modified: 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentFileOperationsTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentFileOperationsTest.java?rev=1570717&r1=1570716&r2=1570717&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentFileOperationsTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentFileOperationsTest.java
 Fri Feb 21 21:38:19 2014
@@ -25,8 +25,12 @@ import java.util.Map;
 import java.util.Random;
 
 import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.util.TraversingItemVisitor;
 
 import org.apache.jackrabbit.commons.JcrUtils;
 import org.apache.jackrabbit.oak.commons.PathUtils;
@@ -103,7 +107,7 @@ public class ConcurrentFileOperationsTes
                         }
 
                     } catch (RepositoryException e) {
-                        exceptions.put(path, e);
+                        exceptions.put(path, new Exception(dumpTree(s, path), 
e));
                     }
                 }
             }));
@@ -123,6 +127,46 @@ public class ConcurrentFileOperationsTes
         }
     }
 
+    String dumpTree(Session s, String path) {
+        final StringBuilder msg = new StringBuilder();
+        try {
+            s.getNode(path).accept(new TraversingItemVisitor.Default() {
+                @Override
+                protected void entering(Node node, int level)
+                        throws RepositoryException {
+                    String indent = "";
+                    for (int i = 0; i < level; i++) {
+                        indent += "  ";
+                    }
+                    msg.append(indent).append(node.getName()).append("\n");
+                    PropertyIterator it = node.getProperties();
+                    indent += "  ";
+                    while (it.hasNext()) {
+                        Property p = it.nextProperty();
+                        msg.append(indent).append(p.getName()).append(": ");
+                        if (p.isMultiple()) {
+                            msg.append("[");
+                            String sep = "";
+                            Value[] values = p.getValues();
+                            for (Value value : values) {
+                                msg.append(sep);
+                                msg.append(value.getString());
+                                sep = ", ";
+                            }
+                            msg.append("]");
+                        } else {
+                            msg.append(p.getValue().getString());
+                        }
+                        msg.append("\n");
+                    }
+                }
+            });
+        } catch (RepositoryException e) {
+            msg.append(e.toString());
+        }
+        return msg.toString();
+    }
+
     @Test
     public void interleavingOperations1() throws Exception {
         Node folder1 = testRootNode.addNode("folder1", "nt:unstructured");


Reply via email to