You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2015/01/20 17:52:16 UTC

svn commit: r1653298 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java

Author: reschke
Date: Tue Jan 20 16:52:15 2015
New Revision: 1653298

URL: http://svn.apache.org/r1653298
Log:
OAK-1266 - add new tests that measures the max id length for non-ASCII ids as well.

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java?rev=1653298&r1=1653297&r2=1653298&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java Tue Jan 20 16:52:15 2015
@@ -70,7 +70,16 @@ public class BasicDocumentStoreTest exte
     }
 
     @Test
-    public void testMaxId() {
+    public void testMaxIdAscii() {
+        testMaxId(true);
+    }
+
+    @Test
+    public void testMaxIdNonAscii() {
+        testMaxId(false);
+    }
+
+    private void testMaxId(boolean ascii) {
         // TODO see OAK-1589
         Assume.assumeTrue(!(super.ds instanceof MongoDocumentStore));
         int min = 0;
@@ -79,7 +88,7 @@ public class BasicDocumentStoreTest exte
 
         while (max - min >= 2) {
             test = (max + min) / 2;
-            String id = generateString(test, true);
+            String id = generateId(test, ascii);
             UpdateOp up = new UpdateOp(id, true);
             up.set("_id", id);
             boolean success = super.ds.create(Collection.NODES, Collections.singletonList(up));
@@ -87,6 +96,7 @@ public class BasicDocumentStoreTest exte
                 // check that we really can read it
                 NodeDocument findme = super.ds.find(Collection.NODES, id, 0);
                 assertNotNull("failed to retrieve previously stored document", findme);
+                assertEquals(id, findme.getId());
                 super.ds.remove(Collection.NODES, id);
                 min = test;
             } else {
@@ -94,7 +104,7 @@ public class BasicDocumentStoreTest exte
             }
         }
 
-        LOG.info("max id length for " + super.dsname + " was " + test);
+        LOG.info("max " + (ascii ? "ASCII ('0')" : "non-ASCII (U+1F4A9)") + " id length for " + super.dsname + " was " + test);
     }
 
     @Test
@@ -619,6 +629,19 @@ public class BasicDocumentStoreTest exte
         return new String(s);
     }
 
+    private static String generateId(int length, boolean ascii) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < length; i++) {
+            if (ascii) {
+                sb.append("0");
+            }
+            else {
+                sb.append(Character.toChars(0x1F4A9));
+            }
+        }
+        return sb.toString();
+    }
+
     @Test
     public void testPerfUpdateLimit() throws SQLException, UnsupportedEncodingException {
         internalTestPerfUpdateLimit("testPerfUpdateLimit", "raw row update (set long)", 0);