jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r939290 - in /jackrabbit/sandbox/jackrabbit-test-harness/compatibility: base/src/main/java/org/apache/jackrabbit/harness/compatibility/AbstractRepositoryTest.java pom.xml verify/pom.xml
Date Thu, 29 Apr 2010 11:54:38 GMT
Author: jukka
Date: Thu Apr 29 11:54:37 2010
New Revision: 939290

URL: http://svn.apache.org/viewvc?rev=939290&view=rev
Log:
JCR-2433: NPE when copying nodes with Workspace.copy()

Add backwards compatibility tests that try to reproduce the reported problem. So far no success.

Modified:
    jackrabbit/sandbox/jackrabbit-test-harness/compatibility/base/src/main/java/org/apache/jackrabbit/harness/compatibility/AbstractRepositoryTest.java
    jackrabbit/sandbox/jackrabbit-test-harness/compatibility/pom.xml
    jackrabbit/sandbox/jackrabbit-test-harness/compatibility/verify/pom.xml

Modified: jackrabbit/sandbox/jackrabbit-test-harness/compatibility/base/src/main/java/org/apache/jackrabbit/harness/compatibility/AbstractRepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-test-harness/compatibility/base/src/main/java/org/apache/jackrabbit/harness/compatibility/AbstractRepositoryTest.java?rev=939290&r1=939289&r2=939290&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-test-harness/compatibility/base/src/main/java/org/apache/jackrabbit/harness/compatibility/AbstractRepositoryTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-test-harness/compatibility/base/src/main/java/org/apache/jackrabbit/harness/compatibility/AbstractRepositoryTest.java
Thu Apr 29 11:54:37 2010
@@ -26,6 +26,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.StringReader;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Random;
@@ -37,13 +38,16 @@ import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.xml.sax.InputSource;
 
 public class AbstractRepositoryTest {
 
@@ -147,6 +151,16 @@ public class AbstractRepositoryTest {
     }
 
     protected void createTestData(Session session) throws Exception {
+        JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)
+            session.getWorkspace().getNodeTypeManager();
+        String cnd =
+            "<nt='http://www.jcp.org/jcr/nt/1.0'>\n"
+            + "<mix='http://www.jcp.org/jcr/mix/1.0'>\n" 
+            + "[nt:myversionable] > nt:unstructured, mix:versionable\n";
+        manager.registerNodeTypes(
+                new ByteArrayInputStream(cnd.getBytes("UTF-8")),
+                JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
+
         Node root = session.getRootNode();
         Node test = root.addNode("test", "nt:unstructured");
         root.save();
@@ -164,12 +178,12 @@ public class AbstractRepositoryTest {
 
         Node versionable = verifyVersionable(test);
         verifyProperties(test, versionable);
+        verifyVersionableCopy(test, versionable);
         verifyUsers(session);
     }
 
     protected Node createVersionable(Node parent) throws RepositoryException {
-        Node versionable = parent.addNode("versionable", "nt:unstructured");
-        versionable.addMixin("mix:versionable");
+        Node versionable = parent.addNode("versionable", "nt:myversionable");
         versionable.setProperty("foo", "A");
         parent.save();
 
@@ -187,6 +201,7 @@ public class AbstractRepositoryTest {
     protected Node verifyVersionable(Node test) throws RepositoryException {
         assertTrue(test.hasNode("versionable"));
         Node versionable = test.getNode("versionable");
+        assertTrue(versionable.isNodeType("nt:myversionable"));
         assertTrue(versionable.isNodeType("nt:unstructured"));
         assertTrue(versionable.isNodeType("mix:versionable"));
         assertFalse(versionable.isCheckedOut());
@@ -259,6 +274,18 @@ public class AbstractRepositoryTest {
         }
     }
 
+    protected void verifyVersionableCopy(Node test, Node versionable)
+            throws RepositoryException, IOException {
+        // System.out.println(versionable.getProperty("jcr:isCheckedOut").getDefinition().getDeclaringNodeType().getName());
+        test.getSession().getWorkspace().copy(
+                versionable.getPath(),
+                versionable.getPath() + "-copy");
+        Node copy = test.getNode(versionable.getName() + "-copy");
+        // System.out.println(copy.getProperty("jcr:isCheckedOut").getDefinition().getDeclaringNodeType().getName());
+        copy.remove();
+        test.save();
+    }
+
     protected void createUsers(Session session) throws RepositoryException {
     }
 

Modified: jackrabbit/sandbox/jackrabbit-test-harness/compatibility/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-test-harness/compatibility/pom.xml?rev=939290&r1=939289&r2=939290&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-test-harness/compatibility/pom.xml (original)
+++ jackrabbit/sandbox/jackrabbit-test-harness/compatibility/pom.xml Thu Apr 29 11:54:37 2010
@@ -48,6 +48,7 @@
     <module>create14</module>
     <module>create15</module>
     <module>create16</module>
+    <module>verify16</module>
     <module>verify</module>
   </modules>
 

Modified: jackrabbit/sandbox/jackrabbit-test-harness/compatibility/verify/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-test-harness/compatibility/verify/pom.xml?rev=939290&r1=939289&r2=939290&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-test-harness/compatibility/verify/pom.xml (original)
+++ jackrabbit/sandbox/jackrabbit-test-harness/compatibility/verify/pom.xml Thu Apr 29 11:54:37
2010
@@ -97,7 +97,7 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-core</artifactId>
-      <version>2.0-SNAPSHOT</version>
+      <version>2.2-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
     <dependency>



Mime
View raw message