Author: florent
Date: Mon Jul 25 22:03:41 2011
New Revision: 1150932

URL: http://svn.apache.org/viewvc?rev=1150932&view=rev
Log:
STANBOL-299
- add the subressource /sites/ to query
- add json parsing, more easy and accurate for testing result than string regex.

Modified:
    incubator/stanbol/trunk/integration-tests/pom.xml
    
incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/EntityHubTest.java

Modified: incubator/stanbol/trunk/integration-tests/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/pom.xml?rev=1150932&r1=1150931&r2=1150932&view=diff
==============================================================================
--- incubator/stanbol/trunk/integration-tests/pom.xml (original)
+++ incubator/stanbol/trunk/integration-tests/pom.xml Mon Jul 25 22:03:41 2011
@@ -88,6 +88,10 @@
       <groupId>com.sun.jersey</groupId>
       <artifactId>jersey-core</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.jettison</groupId>
+      <artifactId>jettison</artifactId>
+    </dependency>
   </dependencies>
 
   <build>

Modified: 
incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/EntityHubTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/EntityHubTest.java?rev=1150932&r1=1150931&r2=1150932&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/EntityHubTest.java
 (original)
+++ 
incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/EntityHubTest.java
 Mon Jul 25 22:03:41 2011
@@ -19,7 +19,11 @@ package org.apache.stanbol.entityhub.it;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.stanbol.commons.testing.http.RequestExecutor;
+import org.apache.stanbol.commons.web.base.writers.JsonLdSerializerProvider;
 import org.apache.stanbol.enhancer.it.EnhancerTestBase;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONObject;
+import org.junit.Assert;
 import org.junit.Test;
 
 //inherit from EnhancerTestBase, but we more care about the entityhub 
readiness than engine's one.
@@ -68,7 +72,7 @@ public class EntityHubTest extends Enhan
        for(String s:queryRequests){
                i += 1;
                RequestExecutor re = executor.execute(
-                               builder.buildPostRequest("/entityhub/query")
+                               
builder.buildPostRequest("/entityhub/sites/query")
                                .withHeader("Content-Type", "application/json")
                                .withHeader("Accept", "application/json")
                                .withContent(s)
@@ -77,22 +81,19 @@ public class EntityHubTest extends Enhan
                log.info("Test request number {}/{} : ",i,queryRequests.length);
                log.info(re.getContent());
        
-               re
-               //TODO : why this assert don't work ?
-            //.assertStatus(200)
-            .assertContentType("application/json")
-            //TODO : uncomment this assert when situation solved
-            //.assertContentRegexp("!\"results\": \\[\\]")
-            .assertContentRegexp("\"results\": \\[\\]")
-            ;
+               re.assertStatus(200)
+            .assertContentType("application/json");
+               
+               JSONObject jso = new JSONObject(re.getContent());
+               JSONArray result = jso.getJSONArray("results");
+               Assert.assertNotSame(0, result.length());
        }
     }
     
     @Test
     public void testSymbolFindEndpoint() throws Exception{
        RequestExecutor re = executor.execute(
-                       builder.buildPostRequest("/entityhub/symbol/find")
-                       //.withHeader("Content-Type", "application/json")
+                       builder.buildPostRequest("/entityhub/sites/find")
                        .withHeader("Accept", "application/json")
                        .withContent("name=Paris&lang=de")
                ) ;
@@ -100,12 +101,11 @@ public class EntityHubTest extends Enhan
                log.info("Test request : ");
                log.info(re.getContent());
        
-               re
-               //TODO : enable this assert when ok
-        //.assertStatus(200)
-        //.assertContentType("application/json")
-        //TODO : write a good assertion when solve
-        .assertContentRegexp("404")
-        ;
+               re.assertStatus(200)
+        .assertContentType("application/json");
+               
+               JSONObject jso = new JSONObject(re.getContent());
+               JSONArray result = jso.getJSONArray("results");
+               Assert.assertNotSame(0, result.length());
     }
 }


Reply via email to