jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1855563 - in /jackrabbit/commons/filevault/trunk/vault-core: ./ src/main/java/org/apache/jackrabbit/vault/util/xml/serialize/ src/test/java/org/apache/jackrabbit/vault/fs/impl/io/ src/test/java/org/apache/jackrabbit/vault/fs/io/ src/test/r...
Date Fri, 15 Mar 2019 00:55:05 GMT
Author: tripod
Date: Fri Mar 15 00:55:05 2019
New Revision: 1855563

URL: http://svn.apache.org/viewvc?rev=1855563&view=rev
Log:
JCRVLT-334 Regression of JCRVLT-271: Property names mixed case problem

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/formatted.xml
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/.ratignore
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/util/xml/serialize/AttributeNameComparator.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSaxFormatterTest.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/DocViewFormatTest.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/malformed.xml

Modified: jackrabbit/commons/filevault/trunk/vault-core/.ratignore
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/.ratignore?rev=1855563&r1=1855562&r2=1855563&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/.ratignore (original)
+++ jackrabbit/commons/filevault/trunk/vault-core/.ratignore Fri Mar 15 00:55:05 2019
@@ -1,2 +1,3 @@
 .ratignore
-src/test/resources/org/apache/jackrabbit/vault/fs/filter/workspacefilters/complex-expected.xml
\ No newline at end of file
+src/test/resources/org/apache/jackrabbit/vault/fs/filter/workspacefilters/complex-expected.xml
+src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/formatted.xml
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/util/xml/serialize/AttributeNameComparator.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/util/xml/serialize/AttributeNameComparator.java?rev=1855563&r1=1855562&r2=1855563&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/util/xml/serialize/AttributeNameComparator.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/util/xml/serialize/AttributeNameComparator.java
Fri Mar 15 00:55:05 2019
@@ -26,25 +26,30 @@ public class AttributeNameComparator imp
     public static final AttributeNameComparator INSTANCE = new AttributeNameComparator();
 
     @Override
-    public int compare(String o1, String o2) {
-        String n1 = o1.toLowerCase();
-        String n2 = o2.toLowerCase();
+    public int compare(final String o1, final String o2) {
+        final String n1 = o1.toLowerCase();
+        final String n2 = o2.toLowerCase();
         // order xmlns(:<prefix>)? attributes always to the front
-        boolean isXmlNs1 = n1.startsWith(XMLSymbols.PREFIX_XMLNS);
-        boolean isXmlNs2 = n2.startsWith(XMLSymbols.PREFIX_XMLNS);
+        final boolean isXmlNs1 = n1.startsWith(XMLSymbols.PREFIX_XMLNS);
+        final boolean isXmlNs2 = n2.startsWith(XMLSymbols.PREFIX_XMLNS);
         if (isXmlNs1 && !isXmlNs2) {
             return -1;
         } else if (!isXmlNs1 && isXmlNs2) {
             return 1;
         }
-        int i1 = n1.indexOf(':');
-        int i2 = n2.indexOf(':');
+        final int i1 = n1.indexOf(':');
+        final int i2 = n2.indexOf(':');
         if (i1 >=0 && i2 < 0) {
             return -1;
         } else if (i1 < 0 && i2 >=0) {
             return 1;
         } else {
-            return n1.compareTo(n2);
+            // if the lowercase versions are equal, they could differ in case (see JCRVLT-334)
+            final int c = n1.compareTo(n2);
+            if (c == 0) {
+                return o1.compareTo(o2);
+            }
+            return c;
         }
     }
 }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSaxFormatterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSaxFormatterTest.java?rev=1855563&r1=1855562&r2=1855563&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSaxFormatterTest.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSaxFormatterTest.java
Fri Mar 15 00:55:05 2019
@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import javax.jcr.GuestCredentials;
+import javax.jcr.Node;
 import javax.jcr.PropertyType;
 import javax.jcr.Session;
 import javax.jcr.Value;
@@ -114,4 +115,32 @@ public class DocViewSaxFormatterTest ext
                 "    jcr:primaryType=\"nt:unstructured\"/>\n", out.toString("utf-8"));
     }
 
+    /**
+     * Tests export of mixed case named properties serialization
+     */
+    @Test
+    public void testMixedCaseSerialization() throws Exception {
+        Node node = JcrUtils.getOrCreateByPath("/testroot", NodeType.NT_UNSTRUCTURED, admin);
+        node.setProperty("testproperty", "lowercase");
+        node.setProperty("TestProperty", "MixedCase");
+        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" +
+                "    TestProperty=\"MixedCase\"\n" +
+                "    testproperty=\"lowercase\"/>\n", out.toString("utf-8"));
+    }
+
 }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/DocViewFormatTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/DocViewFormatTest.java?rev=1855563&r1=1855562&r2=1855563&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/DocViewFormatTest.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/DocViewFormatTest.java
Fri Mar 15 00:55:05 2019
@@ -17,6 +17,7 @@
 
 package org.apache.jackrabbit.vault.fs.io;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
@@ -30,6 +31,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.regex.Pattern;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.util.ISO8601;
 import org.junit.After;
@@ -79,5 +81,10 @@ public class DocViewFormatTest {
         assertFalse("malformed.xml is expected to be malformed", format.format(dir, patterns,
true).isEmpty());
         format.format(dir, patterns, false);
         assertTrue("malformed.xml is expected to be formatted", format.format(dir, patterns,
true).isEmpty());
+
+        final String expected = IOUtils.toString(this.getClass().getClassLoader()
+                .getResourceAsStream("org/apache/jackrabbit/vault/fs/io/DocViewFormat/formatted.xml"),
"utf-8");
+        final String result = FileUtils.readFileToString(docViewFile, "utf-8");
+        assertEquals(expected, result);
     }
 }

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/formatted.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/formatted.xml?rev=1855563&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/formatted.xml
(added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/formatted.xml
Fri Mar 15 00:55:05 2019
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0"
+    jcr:primaryType="nt:unstructured"
+    jcr:title="Test node">
+    <testChild
+        jcr:primaryType="nt:unstructured"
+        foo="bar"
+        TestProperty="test"
+        testProperty="test"/>
+</jcr:root>

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/malformed.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/malformed.xml?rev=1855563&r1=1855562&r2=1855563&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/malformed.xml
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/fs/io/DocViewFormat/malformed.xml
Fri Mar 15 00:55:05 2019
@@ -19,5 +19,7 @@
           jcr:primaryType="nt:unstructured"
           jcr:title="Test node">
     <testChild jcr:primaryType="nt:unstructured"
-               foo="bar"/>
+                  testProperty="test"
+TestProperty="test"
+               foo="bar"></testChild>
 </jcr:root>



Mime
View raw message