jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r469440 - /jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java
Date Tue, 31 Oct 2006 10:34:44 GMT
Author: jukka
Date: Tue Oct 31 02:34:43 2006
New Revision: 469440

URL: http://svn.apache.org/viewvc?view=rev&rev=469440
Log:
JCR-569: Added a regression test that got broken by the recent WorkspaceImporter rewrite.

Added:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java
  (with props)

Added: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java?view=auto&rev=469440
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java
(added)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java
Tue Oct 31 02:34:43 2006
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.core.xml;
+
+import java.io.ByteArrayInputStream;
+
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.core.TestRepository;
+import org.apache.jackrabbit.uuid.UUID;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for the {@link WorkspaceImporter} class.
+ */
+public class WorkspaceImporterTest extends TestCase {
+
+    private Session session;
+
+    private Node root;
+
+    protected void setUp() throws Exception {
+        session = TestRepository.getInstance().login();
+        root = session.getRootNode().addNode("WorkspaceImporterTest");
+        session.save();
+    }
+
+    protected void tearDown() throws Exception {
+        root.remove();
+        session.save();
+        session.logout();
+    }
+
+    /**
+     * Tests that an XML document with an internal reference is correctly
+     * imported. This functionality got broken by JCR-569.
+     *
+     * @throws Exception if an unexpected error occurs
+     */
+    public void testReferenceImport() throws Exception {
+        try {
+            UUID uuid = UUID.randomUUID();
+            String xml =
+                "<sv:node sv:name=\"a\""
+                + " xmlns:jcr=\"http://www.jcp.org/jcr/1.0\""
+                + " xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\""
+                + " xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\">"
+                + "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">"
+                + "<sv:value>nt:unstructured</sv:value></sv:property>"
+                + "<sv:node sv:name=\"b\">"
+                + "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">"
+                + "<sv:value>nt:unstructured</sv:value></sv:property>"
+                + "<sv:property sv:name=\"jcr:mixinTypes\" sv:type=\"Name\">"
+                + "<sv:value>mix:referenceable</sv:value></sv:property>"
+                + "<sv:property sv:name=\"jcr:uuid\" sv:type=\"String\">"
+                + "<sv:value>" + uuid + "</sv:value></sv:property>"
+                + "</sv:node>"
+                + "<sv:node sv:name=\"c\">"
+                + "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">"
+                + "<sv:value>nt:unstructured</sv:value></sv:property>"
+                + "<sv:property sv:name=\"ref\" sv:type=\"Reference\">"
+                + "<sv:value>" + uuid + "</sv:value></sv:property>"
+                + "</sv:node>"
+                + "</sv:node>";
+            session.getWorkspace().importXML(
+                    root.getPath(),
+                    new ByteArrayInputStream(xml.getBytes("UTF-8")),
+                    ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+
+            Node b = root.getNode("a/b");
+            Node c = root.getNode("a/c");
+            assertTrue(
+                    "Imported reference points to the correct node",
+                    b.isSame(c.getProperty("ref").getNode()));
+        } catch (PathNotFoundException e) {
+            fail("Imported node or property not found");
+        } catch (RepositoryException e) {
+            fail("Failed to import an XML document with an internal reference");
+        }
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/xml/WorkspaceImporterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message