From 99f8479f4556b95667682e6839c1c28eeddd1b5f Mon Sep 17 00:00:00 2001 From: Gregory Amerson Date: Fri, 30 Jun 2017 10:28:12 -0500 Subject: [PATCH] assert correct json responses Signed-off-by: Gregory Amerson --- cnf/central.xml | 5 +++++ osgi.enroute.examples.rest.test/bnd.bnd | 6 ++++-- .../examples/rest/test/RestExamplesTest.java | 17 +++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cnf/central.xml b/cnf/central.xml index 8f7ec9d..1cd9596 100644 --- a/cnf/central.xml +++ b/cnf/central.xml @@ -9,6 +9,11 @@ pom + + biz.aQute.bnd + aQute.libg + 3.3.0 + \ No newline at end of file diff --git a/osgi.enroute.examples.rest.test/bnd.bnd b/osgi.enroute.examples.rest.test/bnd.bnd index 2e4c80a..c5c2f4b 100644 --- a/osgi.enroute.examples.rest.test/bnd.bnd +++ b/osgi.enroute.examples.rest.test/bnd.bnd @@ -22,7 +22,8 @@ Test-Cases: ${test-cases} -buildpath: \ osgi.enroute.base.api;version=1.0,\ osgi.enroute.junit.wrapper;version=4.12,\ - biz.aQute.bndlib + biz.aQute.bndlib,\ + aQute.libg;version=3.3 -runrequires: \ osgi.identity;filter:='(osgi.identity=osgi.enroute.examples.rest.application)',\ @@ -52,4 +53,5 @@ Test-Cases: ${test-cases} osgi.enroute.stackexchange.pagedown.webresource;version='[1.1.1,1.1.2)',\ osgi.enroute.twitter.bootstrap.webresource;version='[3.3.5,3.3.6)',\ osgi.enroute.web.simple.provider;version='[2.0.0,2.0.1)',\ - biz.aQute.bndlib;version='[3.3.0,3.3.1)' + biz.aQute.bndlib;version='[3.3.0,3.3.1)',\ + aQute.libg;version='[3.3.0,3.3.1)' diff --git a/osgi.enroute.examples.rest.test/src/osgi/enroute/examples/rest/test/RestExamplesTest.java b/osgi.enroute.examples.rest.test/src/osgi/enroute/examples/rest/test/RestExamplesTest.java index f98f9fa..849efe7 100644 --- a/osgi.enroute.examples.rest.test/src/osgi/enroute/examples/rest/test/RestExamplesTest.java +++ b/osgi.enroute.examples.rest.test/src/osgi/enroute/examples/rest/test/RestExamplesTest.java @@ -16,6 +16,7 @@ import aQute.bnd.http.HttpClient; import aQute.bnd.http.HttpRequest; +import aQute.lib.json.JSONCodec; public class RestExamplesTest { @@ -135,13 +136,17 @@ public void testPostUpper4() throws Exception { Object result = request.go(url); - Assert.assertEquals("{\"input\":\"Sam\",\"output\":\"SAM\"}", result); + String jsonResult = new JSONCodec().enc().to().put(result).toString(); + + Assert.assertEquals("{\"input\":\"Sam\",\"output\":\"SAM\"}", jsonResult); url = new URI("http://localhost:8080/rest/upper4/Sam2"); result = request.go(url); - Assert.assertEquals("{\"input\":\"Sam2\",\"output\":\"SAM2\"}", result); + jsonResult = new JSONCodec().enc().to().put(result).toString(); + + Assert.assertEquals("{\"input\":\"Sam2\",\"output\":\"SAM2\"}", jsonResult); client.close(); } @@ -156,13 +161,17 @@ public void testPutUpper4() throws Exception { Object result = request.go(url); - Assert.assertEquals("{\"input\":\"Sam\",\"output\":\"SAM\"}", result); + String jsonResult = new JSONCodec().enc().to().put(result).toString(); + + Assert.assertEquals("{\"input\":\"Sam\",\"output\":\"SAM\"}", jsonResult); url = new URI("http://localhost:8080/rest/upper4/Sam2"); result = request.go(url); - Assert.assertEquals("{\"input\":\"Sam2\",\"output\":\"SAM2\"}", result); + jsonResult = new JSONCodec().enc().to().put(result).toString(); + + Assert.assertEquals("{\"input\":\"Sam2\",\"output\":\"SAM2\"}", jsonResult); client.close(); }