jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1336746 - in /jackrabbit/oak/trunk/oak-it/jcr: pom.xml src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java
Date Thu, 10 May 2012 15:31:16 GMT
Author: reschke
Date: Thu May 10 15:31:15 2012
New Revision: 1336746

URL: http://svn.apache.org/viewvc?rev=1336746&view=rev
Log:
OAK-6: add test content for export tests, update test exclusions

Modified:
    jackrabbit/oak/trunk/oak-it/jcr/pom.xml
    jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java

Modified: jackrabbit/oak/trunk/oak-it/jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/pom.xml?rev=1336746&r1=1336745&r2=1336746&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-it/jcr/pom.xml Thu May 10 15:31:15 2012
@@ -48,6 +48,11 @@ org.apache.jackrabbit.test.api.NodeReadM
 org.apache.jackrabbit.test.api.NodeReadMethodsTest#testGetUUID
 org.apache.jackrabbit.test.api.SessionReadMethodsTest#testGetNodeByUUIDFailure
 org.apache.jackrabbit.test.api.SessionReadMethodsTest#testGetNodeByUUID
+org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_handler_session_saveBinary_recurse
+org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_stream_session_skipBinary_recurse
+org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_stream_session_skipBinary_noRecurse
+org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_stream_session_saveBinary_noRecurse
+org.apache.jackrabbit.test.api.ExportSysViewTest#testExportSysView_stream_session_saveBinary_recurse
 org.apache.jackrabbit.test.api.PathTest#testGetItem
 org.apache.jackrabbit.test.api.PathTest#testCreatePathValue
 org.apache.jackrabbit.test.api.PathTest#testCreateMultiplePathValue

Modified: jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java?rev=1336746&r1=1336745&r2=1336746&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java
(original)
+++ jackrabbit/oak/trunk/oak-it/jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TestContentLoader.java
Thu May 10 15:31:15 2012
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.Calendar;
 
+import javax.jcr.Binary;
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.PropertyType;
@@ -28,6 +29,7 @@ import javax.jcr.Session;
 import javax.jcr.ValueFactory;
 
 import org.apache.jackrabbit.commons.JcrUtils;
+import org.apache.jackrabbit.value.BinaryValue;
 
 public class TestContentLoader {
 
@@ -42,6 +44,7 @@ public class TestContentLoader {
         addPropertyTestData(getOrAddNode(data, "property"));
         addQueryTestData(getOrAddNode(data, "query"));
         addNodeTestData(getOrAddNode(data, "node"));
+        addExportTestData(getOrAddNode(data, "docViewTest"));
 
         session.save();
     }
@@ -105,9 +108,7 @@ public class TestContentLoader {
         resource.addMixin("mix:referenceable");
         resource.setProperty("jcr:encoding", ENCODING);
         resource.setProperty("jcr:mimeType", "text/plain");
-        resource.setProperty(
-                "jcr:data",
-                new ByteArrayInputStream("Hello w\u00F6rld.".getBytes(ENCODING)));
+        resource.setProperty("jcr:data", new BinaryValue("Hello w\u00F6rld.".getBytes(ENCODING)));
         resource.setProperty("jcr:lastModified", Calendar.getInstance());
 
 
@@ -129,4 +130,72 @@ public class TestContentLoader {
                 node, "testFile", "text/plain",
                 new ByteArrayInputStream("Hello, World!".getBytes("UTF-8")));
     }
+
+    private  void addExportTestData(Node node) throws RepositoryException, IOException {
+        getOrAddNode(node, "invalidXmlName").setProperty("propName", "some text");
+
+        // three nodes which should be serialized as xml text in docView export
+        // separated with spaces
+        getOrAddNode(node, "jcr:xmltext").setProperty(
+                "jcr:xmlcharacters", "A text without any special character.");
+        getOrAddNode(node, "some-element");
+        getOrAddNode(node, "jcr:xmltext").setProperty(
+                "jcr:xmlcharacters",
+                " The entity reference characters: <, ', ,&, >,  \" should"
+                + " be escaped in xml export. ");
+        getOrAddNode(node, "some-element");
+        getOrAddNode(node, "jcr:xmltext").setProperty(
+                "jcr:xmlcharacters", "A text without any special character.");
+
+        Node big = getOrAddNode(node, "bigNode");
+        big.setProperty(
+                "propName0",
+                "SGVsbG8gd8O2cmxkLg==;SGVsbG8gd8O2cmxkLg==".split(";"),
+                PropertyType.BINARY);
+        big.setProperty("propName1", "text 1");
+        big.setProperty(
+                "propName2",
+                "multival text 1;multival text 2;multival text 3".split(";"));
+        big.setProperty("propName3", "text 1");
+
+        addExportValues(node, "propName");
+        addExportValues(node, "Prop<>prop");
+    }
+
+    /**
+     * create nodes with following properties
+     * binary & single
+     * binary & multival
+     * notbinary & single
+     * notbinary & multival
+     */
+    private  void addExportValues(Node node, String name)
+            throws RepositoryException, IOException {
+        String prefix = "valid";
+        if (name.indexOf('<') != -1) {
+            prefix = "invalid";
+        }
+        node = getOrAddNode(node, prefix + "Names");
+
+        String[] texts = new String[] {
+                "multival text 1", "multival text 2", "multival text 3" };
+        getOrAddNode(node, prefix + "MultiNoBin").setProperty(name, texts);
+
+        Node resource = getOrAddNode(node, prefix + "MultiBin");
+        resource.setProperty("jcr:encoding", ENCODING);
+        resource.setProperty("jcr:mimeType", "text/plain");
+        String[] values =
+            new String[] { "SGVsbG8gd8O2cmxkLg==", "SGVsbG8gd8O2cmxkLg==" };
+        resource.setProperty(name, values, PropertyType.BINARY);
+        resource.setProperty("jcr:lastModified", Calendar.getInstance());
+
+        getOrAddNode(node, prefix + "NoBin").setProperty(name,  "text 1");
+
+        resource = getOrAddNode(node, "invalidBin");
+        resource.setProperty("jcr:encoding", ENCODING);
+        resource.setProperty("jcr:mimeType", "text/plain");
+        byte[] bytes = "Hello w\u00F6rld.".getBytes(ENCODING);
+        resource.setProperty(name, new BinaryValue(bytes));
+        resource.setProperty("jcr:lastModified", Calendar.getInstance());
+    }
 }



Mime
View raw message