jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1346375 - in /jackrabbit/oak/trunk: oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/ oak-mk/src/test/java/org/apache/jackrabbit/mk/json/fast/ oak-mk/src/test/java/org/apache/jackrabbit/mk/store/
Date Tue, 05 Jun 2012 12:55:25 GMT
Author: stefan
Date: Tue Jun  5 12:55:24 2012
New Revision: 1346375

URL: http://svn.apache.org/viewvc?rev=1346375&view=rev
Log:
OAK-77: Consolidate Utilities

remove redundant json parser implementation in oak-mk test soruce tree

Removed:
    jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/json/fast/
Modified:
    jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java
    jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java

Modified: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java?rev=1346375&r1=1346374&r2=1346375&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java
(original)
+++ jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java
Tue Jun  5 12:55:24 2012
@@ -166,7 +166,7 @@ public abstract class AbstractMicroKerne
     }
 
     /**
-     * Parses the provided string into a {@code JSONObject}.
+     * Parses the provided string into a {@code JSONArray}.
      *
      * @param json string to be parsed
      * @return a {@code JSONArray}

Modified: jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java?rev=1346375&r1=1346374&r2=1346375&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
Tue Jun  5 12:55:24 2012
@@ -17,21 +17,21 @@
 package org.apache.jackrabbit.mk.store;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.blobs.MemoryBlobStore;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.mk.core.Repository;
-import org.apache.jackrabbit.mk.json.fast.Jsop;
-import org.apache.jackrabbit.mk.json.fast.JsopArray;
 import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.persistence.GCPersistence;
 import org.apache.jackrabbit.mk.persistence.InMemPersistence;
+import org.json.simple.JSONArray;
+import org.json.simple.parser.JSONParser;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -92,7 +92,7 @@ public class DefaultRevisionStoreTest {
         assertEquals(contents, mk.getNodes("/", headRevision, 1, 0, -1, null));
         
         String history = mk.getRevisionHistory(Long.MIN_VALUE, Integer.MIN_VALUE, null);
-        assertEquals(1, ((JsopArray) Jsop.parse(history)).size());
+        assertEquals(1, parseJSONArray(history).size());
     }
 
     /**
@@ -116,7 +116,7 @@ public class DefaultRevisionStoreTest {
         rs.gc();
 
         String history = mk.getRevisionHistory(Long.MIN_VALUE, Integer.MIN_VALUE, null);
-        assertEquals(1, ((JsopArray) Jsop.parse(history)).size());
+        assertEquals(1, parseJSONArray(history).size());
     }
     
     /**
@@ -187,4 +187,22 @@ public class DefaultRevisionStoreTest {
             gcExecutor.shutdown();
         }
     }
+
+    /**
+     * Parses the provided string into a {@code JSONArray}.
+     *
+     * @param json string to be parsed
+     * @return a {@code JSONArray}
+     * @throws {@code AssertionError} if the string cannot be parsed into a {@code JSONArray}
+     */
+    private JSONArray parseJSONArray(String json) throws AssertionError {
+        JSONParser parser = new JSONParser();
+        try {
+            Object obj = parser.parse(json);
+            assertTrue(obj instanceof JSONArray);
+            return (JSONArray) obj;
+        } catch (Exception e) {
+            throw new AssertionError("not a valid JSON array: " + e.getMessage());
+        }
+    }
 }



Mime
View raw message