manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iori...@apache.org
Subject svn commit: r1741248 - /manifoldcf/trunk/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java
Date Wed, 27 Apr 2016 12:59:37 GMT
Author: iorixxx
Date: Wed Apr 27 12:59:37 2016
New Revision: 1741248

URL: http://svn.apache.org/viewvc?rev=1741248&view=rev
Log:
CONNECTORS-1189 fix one of the failing tests using existing org.json dependency

Modified:
    manifoldcf/trunk/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java

Modified: manifoldcf/trunk/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java?rev=1741248&r1=1741247&r2=1741248&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java
(original)
+++ manifoldcf/trunk/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java
Wed Apr 27 12:59:37 2016
@@ -18,7 +18,7 @@ package org.apache.manifoldcf.agents.out
 
 import com.google.common.collect.Lists;
 
-//import junit.framework.TestCase;
+import org.json.*;
 
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
@@ -26,6 +26,8 @@ import org.apache.manifoldcf.agents.outp
 import org.apache.manifoldcf.agents.output.searchblox.SearchBloxDocument.DocumentAction;
 import org.apache.manifoldcf.agents.output.searchblox.SearchBloxDocument.IndexingFormat;
 import org.apache.manifoldcf.agents.output.searchblox.SearchBloxException;
+import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.Ignore;
 import static org.junit.Assert.*;
@@ -38,15 +40,10 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-/**
- * @author Alessandro Benedetti
- *         07/03/2015
- *         mcf-searchblox-connector
- */
-public class SearchBloxDocumentTest /*extends TestCase */ {
+public class SearchBloxDocumentTest {
     SearchBloxDocument toTest;
     RepositoryDocument rd;
-
+    @Before
    public void setUp() throws ManifoldCFException {
        Map<String, List<String>> args=initArgs();
        String apikey="apikey";
@@ -82,12 +79,31 @@ public class SearchBloxDocumentTest /*ex
     }
 
     @Test
-    @Ignore("fails on jdk 8 due to hash order")
-    public void deleteJsonString() throws SearchBloxException {
+    public void deleteJsonString() throws SearchBloxException, JSONException {
         String jsonGenerated=toTest.toString(IndexingFormat.JSON, DocumentAction.DELETE);
-        System.out.println(jsonGenerated);
-        String xmlExpected="{\"document\":{\"uid\":\"URI\",\"colname\":\"collection1\"},\"apikey\":\"apikey\"}";
-        assertEquals(xmlExpected,jsonGenerated);
+
+        JSONObject json = new JSONObject(jsonGenerated);
+        assertTrue(json.has("apikey"));
+        assertTrue(json.has("document"));
+
+        Object apiObject = json.get("apikey");
+        assertTrue(apiObject instanceof String);
+        assertEquals("apikey", apiObject);
+
+        Object documentObject = json.get("document");
+        assertTrue(documentObject instanceof JSONObject);
+        JSONObject document = (JSONObject) documentObject;
+
+        assertTrue(document.has("uid"));
+        assertTrue(document.has("colname"));
+
+        Object uidObject = document.get("uid");
+        assertTrue(uidObject instanceof String);
+        assertEquals("URI", uidObject);
+
+        Object colObject = document.get("colname");
+        assertTrue(colObject instanceof String);
+        assertEquals("collection1", colObject);
     }
 
     @Test



Mime
View raw message