You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by tb...@apache.org on 2014/01/02 13:46:56 UTC

[09/47] git commit: [OLINGO-87] Fixed problem with json service document test

[OLINGO-87] Fixed problem with json service document test


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/eeee989a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/eeee989a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/eeee989a

Branch: refs/heads/ODataServlet
Commit: eeee989acf746d7c7cde8039e05b1abb457edfb2
Parents: 9a05b37
Author: Michael Bolz <mi...@apache.org>
Authored: Mon Dec 23 13:51:08 2013 +0100
Committer: Michael Bolz <mi...@apache.org>
Committed: Mon Dec 23 13:51:20 2013 +0100

----------------------------------------------------------------------
 .../processor/ref/ServiceJsonTest.java          | 30 +++++++++++++++-----
 1 file changed, 23 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/eeee989a/odata2-annotation-processor/annotation-processor-webref/src/test/java/org/apache/olingo/odata2/annotation/processor/ref/ServiceJsonTest.java
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-webref/src/test/java/org/apache/olingo/odata2/annotation/processor/ref/ServiceJsonTest.java b/odata2-annotation-processor/annotation-processor-webref/src/test/java/org/apache/olingo/odata2/annotation/processor/ref/ServiceJsonTest.java
index 9c0a049..4813690 100644
--- a/odata2-annotation-processor/annotation-processor-webref/src/test/java/org/apache/olingo/odata2/annotation/processor/ref/ServiceJsonTest.java
+++ b/odata2-annotation-processor/annotation-processor-webref/src/test/java/org/apache/olingo/odata2/annotation/processor/ref/ServiceJsonTest.java
@@ -19,11 +19,12 @@
 package org.apache.olingo.odata2.annotation.processor.ref;
 
 import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;
-import static org.junit.Assert.assertEquals;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import junit.framework.Assert;
+
 import org.apache.http.HttpResponse;
 import org.apache.olingo.odata2.api.commons.HttpContentType;
 import org.apache.olingo.odata2.api.commons.HttpHeaders;
@@ -42,17 +43,32 @@ public class ServiceJsonTest extends AbstractRefTest {
   public void serviceDocumentDollarFormatJson() throws Exception {
     final HttpResponse response = callUri("?$format=json");
     // checkMediaType(response, HttpContentType.APPLICATION_JSON);
-    assertEquals("{\"d\":{\"EntitySets\":["
-        + "\"Buildings\",\"Employees\",\"Managers\",\"Photos\",\"Rooms\",\"Teams\"]}}",
-        getBody(response));
+    String body = getBody(response);
+
+    Assert.assertTrue(jsonDataResponseContains(body, "Buildings"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Employees"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Managers"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Photos"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Rooms"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Teams"));
   }
 
+  private boolean jsonDataResponseContains(String content, String containingValue) {
+    return content.matches("\\{\"d\":\\{\"EntitySets\":\\[.*"
+        + containingValue + ".*\"\\]\\}\\}");
+  }
+  
   @Test
   public void serviceDocumentAcceptHeaderJson() throws Exception {
     final HttpResponse response = callUri("", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON);
-    assertEquals("{\"d\":{\"EntitySets\":["
-        + "\"Buildings\",\"Employees\",\"Managers\",\"Photos\",\"Rooms\",\"Teams\"]}}",
-        getBody(response));
+    String body = getBody(response);
+
+    Assert.assertTrue(jsonDataResponseContains(body, "Buildings"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Employees"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Managers"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Photos"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Rooms"));
+    Assert.assertTrue(jsonDataResponseContains(body, "Teams"));
   }
 
   @Test