You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2022/04/04 21:11:22 UTC

[jackrabbit-filevault] branch feature/add-ITs-for-DocViewSaxFormatter created (now 38f093d4)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a change to branch feature/add-ITs-for-DocViewSaxFormatter
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git


      at 38f093d4 releng: add integration tests for DocViewSAXFormatter for same-name siblings and ISO9075 encoding

This branch includes the following new commits:

     new 38f093d4 releng: add integration tests for DocViewSAXFormatter for same-name siblings and ISO9075 encoding

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[jackrabbit-filevault] 01/01: releng: add integration tests for DocViewSAXFormatter for same-name siblings and ISO9075 encoding

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch feature/add-ITs-for-DocViewSaxFormatter
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git

commit 38f093d4e37da1253c4680b602827228bc46c755
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Apr 4 23:11:14 2022 +0200

    releng: add integration tests for DocViewSAXFormatter for same-name
    siblings and ISO9075 encoding
---
 .../vault/fs/impl/io/DocViewSAXFormatter.java      |  2 +-
 .../vault/fs/impl/io/DocViewSaxFormatterIT.java    | 60 ++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXFormatter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXFormatter.java
index b5e40a7b..b52c646a 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXFormatter.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXFormatter.java
@@ -49,7 +49,7 @@ import org.apache.jackrabbit.vault.util.JcrConstants;
 import org.xml.sax.SAXException;
 
 /**
- * The docview sax formatter generates SAX events to a given ContentHandler based on the aggregate tree.
+ * Writes the enhanced docview XML based on the aggregate tree to a given {@link XMLStreamWriter}.
  */
 public class DocViewSAXFormatter implements AggregateWalkListener {
 
diff --git a/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSaxFormatterIT.java b/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSaxFormatterIT.java
index 98b3cc37..09da9d64 100644
--- a/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSaxFormatterIT.java
+++ b/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSaxFormatterIT.java
@@ -18,12 +18,15 @@
 package org.apache.jackrabbit.vault.fs.impl.io;
 
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.jcr.GuestCredentials;
 import javax.jcr.Node;
 import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.nodetype.NodeType;
@@ -143,4 +146,61 @@ public class DocViewSaxFormatterIT extends IntegrationTestBase {
                 "    testproperty=\"lowercase\"/>\n", out.toString("utf-8"));
     }
 
+    @Test
+    public void testSnsNodeNames() throws RepositoryException, URISyntaxException, IOException {
+        Assume.assumeFalse(isOak()); // same-name siblings are only supported by Jackrabbit2
+        Node node = JcrUtils.getOrCreateByPath("/testroot", NodeType.NT_UNSTRUCTURED, admin);
+        node.addNode("childnode",  NodeType.NT_UNSTRUCTURED);
+        node.addNode("childnode",  NodeType.NT_UNSTRUCTURED);
+        node.addNode("childnode",  NodeType.NT_UNSTRUCTURED);
+        admin.save();
+
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        filter.add(new PathFilterSet("/testroot"));
+        RepositoryAddress addr = new RepositoryAddress("/" + admin.getWorkspace().getName() + "/");
+        VaultFileSystem jcrfs = Mounter.mount(null, filter, addr, null, admin);
+        Aggregate a = jcrfs.getAggregateManager().getRoot().getAggregate("testroot");
+        DocViewSerializer s = new DocViewSerializer(a);
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        s.writeContent(out);
+
+        assertEquals("valid xml",
+                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+                "<jcr:root xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\"\n" +
+                "    jcr:primaryType=\"nt:unstructured\">\n" +
+                "    <childnode jcr:primaryType=\"nt:unstructured\"/>\n" +
+                "    <childnode_x005b_2_x005d_ jcr:primaryType=\"nt:unstructured\"/>\n" +
+                "    <childnode_x005b_3_x005d_ jcr:primaryType=\"nt:unstructured\"/>\n" +
+                "</jcr:root>\n", out.toString("utf-8"));
+    }
+
+    @Test
+    public void testSpecialNames() throws RepositoryException, URISyntaxException, IOException {
+        Node node = JcrUtils.getOrCreateByPath("/testroot", NodeType.NT_UNSTRUCTURED, admin);
+        node.addNode("1test",  NodeType.NT_UNSTRUCTURED);
+        Node childNode = node.addNode("test%test",  NodeType.NT_UNSTRUCTURED);
+        childNode.setProperty("_test&test", "test");
+        admin.save();
+
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        filter.add(new PathFilterSet("/testroot"));
+        RepositoryAddress addr = new RepositoryAddress("/" + admin.getWorkspace().getName() + "/");
+        VaultFileSystem jcrfs = Mounter.mount(null, filter, addr, null, admin);
+        Aggregate a = jcrfs.getAggregateManager().getRoot().getAggregate("testroot");
+        DocViewSerializer s = new DocViewSerializer(a);
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        s.writeContent(out);
+
+        assertEquals("valid xml",
+                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+                "<jcr:root xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\"\n" +
+                "    jcr:primaryType=\"nt:unstructured\">\n" +
+                "    <_x0031_test jcr:primaryType=\"nt:unstructured\"/>\n" +
+                "    <test_x0025_test\n" +
+                "        jcr:primaryType=\"nt:unstructured\"\n" +
+                "        _test_x0026_test=\"test\"/>\n" +
+                "</jcr:root>\n", out.toString("utf-8"));
+    }
 }