From 755862e8f33c6abd98c5c1efacd6653cd7f82d76 Mon Sep 17 00:00:00 2001
From: Tudor Rogoz <rogoz@adobe.com>
Date: Wed, 17 Oct 2012 11:53:15 +0300
Subject: [PATCH] OAK-378 Added a unit test

---
 .../jackrabbit/mongomk/impl/MongoMKLimitsTest.java |   40 +++++++++++++++++---
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKLimitsTest.java b/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKLimitsTest.java
index 07fc015..e1450e5 100644
--- a/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKLimitsTest.java
+++ b/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKLimitsTest.java
@@ -1,5 +1,7 @@
 package org.apache.jackrabbit.mongomk.impl;
 
+import java.util.Arrays;
+
 import org.apache.jackrabbit.mongomk.BaseMongoMicroKernelTest;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.junit.Ignore;
@@ -7,15 +9,15 @@ import org.junit.Test;
 
 /**
  * FIXME - Look into these tests and see if we want to fix them somehow.
- *
+ * 
  * Tests for MongoMicroKernel limits.
  */
 public class MongoMKLimitsTest extends BaseMongoMicroKernelTest {
 
-
     /**
-     * This test currently fails due to 1000 char limit in property sizes in MongoDB
-     * which affects path property. It also slows down as the test progresses.
+     * This test currently fails due to 1000 char limit in property sizes in
+     * MongoDB which affects path property. It also slows down as the test
+     * progresses.
      */
     @Test
     @Ignore
@@ -36,4 +38,32 @@ public class MongoMKLimitsTest extends BaseMongoMicroKernelTest {
             path += baseNodeName + i;
         }
     }
-}
\ No newline at end of file
+
+    /**
+     * This currently fails due to 16MB DBObject size limitation from Mongo
+     * database.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void overMaxBSONLimit() throws Exception {
+        String path = "/";
+        String baseNodeName = "N";
+        StringBuilder jsonDiff = new StringBuilder();
+        String message;
+        // create a 1 MB property
+        char[] chars = new char[1024 * 1024];
+
+        Arrays.fill(chars, '0');
+        String content = new String(chars);
+        // create 16+ MB diff
+        for (int i = 0; i < 16; i++) {
+            jsonDiff.append("+\"" + baseNodeName + i + "\" : {\"key\":\""
+                    + content + "\"}\n");
+        }
+        String diff = jsonDiff.toString();
+        message = "Commit diff size " + diff.getBytes().length;
+        System.out.println(message);
+        mk.commit(path, diff, null, message);
+    }
+}
-- 
1.7.9.5

