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 2014/06/26 16:39:31 UTC
svn commit: r1605800 -
/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
Author: reschke
Date: Thu Jun 26 14:39:30 2014
New Revision: 1605800
URL: http://svn.apache.org/r1605800
Log:
OAK-1914 - add tests for various property sizes, checking the cutoff between string and BLOB storage
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=1605800&r1=1605799&r2=1605800&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 Thu Jun 26 14:39:30 2014
@@ -68,7 +68,7 @@ public class BasicDocumentStoreTest exte
while (max - min >= 2) {
test = (max + min) / 2;
- String id = generateString(test);
+ String id = generateString(test, true);
UpdateOp up = new UpdateOp(id, true);
up.set("_id", id);
boolean success = super.ds.create(Collection.NODES, Collections.singletonList(up));
@@ -95,7 +95,7 @@ public class BasicDocumentStoreTest exte
while (max - min >= 256) {
test = (max + min) / 2;
String id = this.getClass().getName() + ".testMaxProperty-" + test;
- String pval = generateString(test);
+ String pval = generateString(test, true);
UpdateOp up = new UpdateOp(id, true);
up.set("_id", id);
up.set("foo", pval);
@@ -115,6 +115,23 @@ public class BasicDocumentStoreTest exte
}
@Test
+ public void testInterestingPropLengths() {
+ int lengths[] = {1, 10, 100, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 20000};
+
+ for (int test : lengths) {
+ String id = this.getClass().getName() + ".testInterestingPropLengths-" + test;
+ String pval = generateString(test, false);
+ UpdateOp up = new UpdateOp(id, true);
+ up.set("_id", id);
+ up.set("foo", pval);
+ super.ds.remove(Collection.NODES, id);
+ boolean success = super.ds.create(Collection.NODES, Collections.singletonList(up));
+ assertTrue("failed to insert a document with property of length " + test, success);
+ super.ds.remove(Collection.NODES, id);
+ }
+ }
+
+ @Test
public void testDeleteNonExisting() {
String id = this.getClass().getName() + ".testDeleteNonExisting-" + UUID.randomUUID();
// delete is best effort
@@ -275,7 +292,7 @@ public class BasicDocumentStoreTest exte
}
private void createPerf(int size, int amount) {
- String pval = generateString(size);
+ String pval = generateString(size, true);
long duration = 1000;
long end = System.currentTimeMillis() + duration;
long cnt = 0;
@@ -312,7 +329,7 @@ public class BasicDocumentStoreTest exte
}
private void updatePerf(int size) {
- String pval = generateString(size);
+ String pval = generateString(size, true);
long duration = 1000;
long end = System.currentTimeMillis() + duration;
long cnt = 0;
@@ -332,11 +349,16 @@ public class BasicDocumentStoreTest exte
+ (cnt / (duration / 1000f)) + "/s)");
}
- private static String generateString(int length) {
- StringBuffer buf = new StringBuffer(length);
- while (length-- > 0) {
- buf.append('A' + ((int) (26 * Math.random())));
+ private static String generateString(int length, boolean ascii) {
+ char[] s = new char[length];
+ for (int i = 0; i < length; i++) {
+ if (ascii) {
+ s[i] = (char)(32 + (int) (95 * Math.random()));
+ }
+ else {
+ s[i] = (char)(32 + (int) ((0xd7ff - 32) * Math.random()));
+ }
}
- return buf.toString();
- }
+ return new String(s);
+ }
}