Jian Li

Replace deprecated JsonObject.readFrom() with Json.parse().asObject

Change-Id: I9e6e5a83edfd2c6abc694c1cc1e939b0b826e980
...@@ -24,6 +24,7 @@ import static org.junit.Assert.assertThat; ...@@ -24,6 +24,7 @@ import static org.junit.Assert.assertThat;
24 import static org.onosproject.net.NetTestTools.device; 24 import static org.onosproject.net.NetTestTools.device;
25 import static org.onosproject.net.NetTestTools.did; 25 import static org.onosproject.net.NetTestTools.did;
26 26
27 +import com.eclipsesource.json.Json;
27 import org.junit.After; 28 import org.junit.After;
28 import org.junit.Before; 29 import org.junit.Before;
29 import org.junit.Test; 30 import org.junit.Test;
...@@ -93,7 +94,7 @@ public class ClassifierResourceTest extends VtnResourceTest { ...@@ -93,7 +94,7 @@ public class ClassifierResourceTest extends VtnResourceTest {
93 94
94 final WebResource rs = resource(); 95 final WebResource rs = resource();
95 final String response = rs.path("classifiers").get(String.class); 96 final String response = rs.path("classifiers").get(String.class);
96 - final JsonObject result = JsonObject.readFrom(response); 97 + final JsonObject result = Json.parse(response).asObject();
97 assertThat(result, notNullValue()); 98 assertThat(result, notNullValue());
98 } 99 }
99 } 100 }
......
...@@ -33,6 +33,7 @@ import java.util.Set; ...@@ -33,6 +33,7 @@ import java.util.Set;
33 33
34 import javax.ws.rs.core.MediaType; 34 import javax.ws.rs.core.MediaType;
35 35
36 +import com.eclipsesource.json.Json;
36 import org.junit.After; 37 import org.junit.After;
37 import org.junit.Before; 38 import org.junit.Before;
38 import org.junit.Test; 39 import org.junit.Test;
...@@ -238,7 +239,7 @@ public class FlowClassifierResourceTest extends VtnResourceTest { ...@@ -238,7 +239,7 @@ public class FlowClassifierResourceTest extends VtnResourceTest {
238 239
239 final WebResource rs = resource(); 240 final WebResource rs = resource();
240 final String response = rs.path("flow_classifiers/4a334cd4-fe9c-4fae-af4b-321c5e2eb051").get(String.class); 241 final String response = rs.path("flow_classifiers/4a334cd4-fe9c-4fae-af4b-321c5e2eb051").get(String.class);
241 - final JsonObject result = JsonObject.readFrom(response); 242 + final JsonObject result = Json.parse(response).asObject();
242 assertThat(result, notNullValue()); 243 assertThat(result, notNullValue());
243 } 244 }
244 245
......
...@@ -34,6 +34,7 @@ import java.util.Set; ...@@ -34,6 +34,7 @@ import java.util.Set;
34 34
35 import javax.ws.rs.core.MediaType; 35 import javax.ws.rs.core.MediaType;
36 36
37 +import com.eclipsesource.json.Json;
37 import org.junit.After; 38 import org.junit.After;
38 import org.junit.Before; 39 import org.junit.Before;
39 import org.junit.Test; 40 import org.junit.Test;
...@@ -184,7 +185,7 @@ public class PortChainResourceTest extends VtnResourceTest { ...@@ -184,7 +185,7 @@ public class PortChainResourceTest extends VtnResourceTest {
184 185
185 final WebResource rs = resource(); 186 final WebResource rs = resource();
186 final String response = rs.path("port_chains/1278dcd4-459f-62ed-754b-87fc5e4a6751").get(String.class); 187 final String response = rs.path("port_chains/1278dcd4-459f-62ed-754b-87fc5e4a6751").get(String.class);
187 - final JsonObject result = JsonObject.readFrom(response); 188 + final JsonObject result = Json.parse(response).asObject();
188 assertThat(result, notNullValue()); 189 assertThat(result, notNullValue());
189 } 190 }
190 191
......
...@@ -34,6 +34,7 @@ import java.util.Set; ...@@ -34,6 +34,7 @@ import java.util.Set;
34 34
35 import javax.ws.rs.core.MediaType; 35 import javax.ws.rs.core.MediaType;
36 36
37 +import com.eclipsesource.json.Json;
37 import org.junit.After; 38 import org.junit.After;
38 import org.junit.Before; 39 import org.junit.Before;
39 import org.junit.Test; 40 import org.junit.Test;
...@@ -171,7 +172,7 @@ public class PortPairGroupResourceTest extends VtnResourceTest { ...@@ -171,7 +172,7 @@ public class PortPairGroupResourceTest extends VtnResourceTest {
171 172
172 final WebResource rs = resource(); 173 final WebResource rs = resource();
173 final String response = rs.path("port_pair_groups/4512d643-24fc-4fae-af4b-321c5e2eb3d1").get(String.class); 174 final String response = rs.path("port_pair_groups/4512d643-24fc-4fae-af4b-321c5e2eb3d1").get(String.class);
174 - final JsonObject result = JsonObject.readFrom(response); 175 + final JsonObject result = Json.parse(response).asObject();
175 assertThat(result, notNullValue()); 176 assertThat(result, notNullValue());
176 } 177 }
177 178
......
...@@ -33,6 +33,7 @@ import java.util.Set; ...@@ -33,6 +33,7 @@ import java.util.Set;
33 33
34 import javax.ws.rs.core.MediaType; 34 import javax.ws.rs.core.MediaType;
35 35
36 +import com.eclipsesource.json.Json;
36 import org.junit.After; 37 import org.junit.After;
37 import org.junit.Before; 38 import org.junit.Before;
38 import org.junit.Test; 39 import org.junit.Test;
...@@ -174,7 +175,7 @@ public class PortPairResourceTest extends VtnResourceTest { ...@@ -174,7 +175,7 @@ public class PortPairResourceTest extends VtnResourceTest {
174 175
175 final WebResource rs = resource(); 176 final WebResource rs = resource();
176 final String response = rs.path("port_pairs/78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae").get(String.class); 177 final String response = rs.path("port_pairs/78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae").get(String.class);
177 - final JsonObject result = JsonObject.readFrom(response); 178 + final JsonObject result = Json.parse(response).asObject();
178 assertThat(result, notNullValue()); 179 assertThat(result, notNullValue());
179 } 180 }
180 181
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.rest; 16 package org.onosproject.rest;
17 17
18 +import com.eclipsesource.json.Json;
18 import com.eclipsesource.json.JsonArray; 19 import com.eclipsesource.json.JsonArray;
19 import com.eclipsesource.json.JsonObject; 20 import com.eclipsesource.json.JsonObject;
20 import com.google.common.collect.ImmutableList; 21 import com.google.common.collect.ImmutableList;
...@@ -227,7 +228,7 @@ public class ApplicationsResourceTest extends ResourceTest { ...@@ -227,7 +228,7 @@ public class ApplicationsResourceTest extends ResourceTest {
227 String response = rs.path("applications").get(String.class); 228 String response = rs.path("applications").get(String.class);
228 assertThat(response, containsString("{\"applications\":[")); 229 assertThat(response, containsString("{\"applications\":["));
229 230
230 - JsonObject result = JsonObject.readFrom(response); 231 + JsonObject result = Json.parse(response).asObject();
231 assertThat(result, notNullValue()); 232 assertThat(result, notNullValue());
232 233
233 assertThat(result.names(), hasSize(1)); 234 assertThat(result.names(), hasSize(1));
...@@ -253,7 +254,7 @@ public class ApplicationsResourceTest extends ResourceTest { ...@@ -253,7 +254,7 @@ public class ApplicationsResourceTest extends ResourceTest {
253 WebResource rs = resource(); 254 WebResource rs = resource();
254 String response = rs.path("applications/three").get(String.class); 255 String response = rs.path("applications/three").get(String.class);
255 256
256 - JsonObject result = JsonObject.readFrom(response); 257 + JsonObject result = Json.parse(response).asObject();
257 assertThat(result, notNullValue()); 258 assertThat(result, notNullValue());
258 259
259 assertThat(result, matchesApp(app3)); 260 assertThat(result, matchesApp(app3));
...@@ -324,7 +325,7 @@ public class ApplicationsResourceTest extends ResourceTest { ...@@ -324,7 +325,7 @@ public class ApplicationsResourceTest extends ResourceTest {
324 WebResource rs = resource(); 325 WebResource rs = resource();
325 String response = rs.path("applications").post(String.class, app4Json); 326 String response = rs.path("applications").post(String.class, app4Json);
326 327
327 - JsonObject result = JsonObject.readFrom(response); 328 + JsonObject result = Json.parse(response).asObject();
328 assertThat(result, notNullValue()); 329 assertThat(result, notNullValue());
329 330
330 assertThat(result, matchesApp(app4)); 331 assertThat(result, matchesApp(app4));
......
...@@ -17,6 +17,7 @@ package org.onosproject.rest; ...@@ -17,6 +17,7 @@ package org.onosproject.rest;
17 17
18 import java.util.List; 18 import java.util.List;
19 19
20 +import com.eclipsesource.json.Json;
20 import org.hamcrest.Description; 21 import org.hamcrest.Description;
21 import org.hamcrest.TypeSafeMatcher; 22 import org.hamcrest.TypeSafeMatcher;
22 import org.junit.After; 23 import org.junit.After;
...@@ -271,7 +272,7 @@ public class DevicesResourceTest extends ResourceTest { ...@@ -271,7 +272,7 @@ public class DevicesResourceTest extends ResourceTest {
271 String response = rs.path("devices").get(String.class); 272 String response = rs.path("devices").get(String.class);
272 assertThat(response, containsString("{\"devices\":[")); 273 assertThat(response, containsString("{\"devices\":["));
273 274
274 - JsonObject result = JsonObject.readFrom(response); 275 + JsonObject result = Json.parse(response).asObject();
275 assertThat(result, notNullValue()); 276 assertThat(result, notNullValue());
276 277
277 assertThat(result.names(), hasSize(1)); 278 assertThat(result.names(), hasSize(1));
...@@ -303,7 +304,7 @@ public class DevicesResourceTest extends ResourceTest { ...@@ -303,7 +304,7 @@ public class DevicesResourceTest extends ResourceTest {
303 304
304 WebResource rs = resource(); 305 WebResource rs = resource();
305 String response = rs.path("devices/" + deviceId).get(String.class); 306 String response = rs.path("devices/" + deviceId).get(String.class);
306 - JsonObject result = JsonObject.readFrom(response); 307 + JsonObject result = Json.parse(response).asObject();
307 assertThat(result, matchesDevice(device)); 308 assertThat(result, matchesDevice(device));
308 } 309 }
309 310
...@@ -335,7 +336,7 @@ public class DevicesResourceTest extends ResourceTest { ...@@ -335,7 +336,7 @@ public class DevicesResourceTest extends ResourceTest {
335 String response = 336 String response =
336 rs.path("devices/" + deviceId + "/ports") 337 rs.path("devices/" + deviceId + "/ports")
337 .get(String.class); 338 .get(String.class);
338 - JsonObject result = JsonObject.readFrom(response); 339 + JsonObject result = Json.parse(response).asObject();
339 assertThat(result, matchesDevice(device)); 340 assertThat(result, matchesDevice(device));
340 341
341 JsonArray jsonPorts = result.get("ports").asArray(); 342 JsonArray jsonPorts = result.get("ports").asArray();
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.rest; 16 package org.onosproject.rest;
17 17
18 +import com.eclipsesource.json.Json;
18 import com.eclipsesource.json.JsonObject; 19 import com.eclipsesource.json.JsonObject;
19 import com.sun.jersey.api.client.ClientResponse; 20 import com.sun.jersey.api.client.ClientResponse;
20 import com.sun.jersey.api.client.WebResource; 21 import com.sun.jersey.api.client.WebResource;
...@@ -134,7 +135,7 @@ public class FlowObjectiveResourceTest extends ResourceTest { ...@@ -134,7 +135,7 @@ public class FlowObjectiveResourceTest extends ResourceTest {
134 135
135 WebResource rs = resource(); 136 WebResource rs = resource();
136 final String response = rs.path("flowobjectives/next").get(String.class); 137 final String response = rs.path("flowobjectives/next").get(String.class);
137 - final JsonObject result = JsonObject.readFrom(response); 138 + final JsonObject result = Json.parse(response).asObject();
138 assertThat(result, notNullValue()); 139 assertThat(result, notNullValue());
139 140
140 assertThat(result.names(), hasSize(1)); 141 assertThat(result.names(), hasSize(1));
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.rest; 16 package org.onosproject.rest;
17 17
18 +import com.eclipsesource.json.Json;
18 import com.eclipsesource.json.JsonArray; 19 import com.eclipsesource.json.JsonArray;
19 import com.eclipsesource.json.JsonObject; 20 import com.eclipsesource.json.JsonObject;
20 import com.google.common.collect.ImmutableSet; 21 import com.google.common.collect.ImmutableSet;
...@@ -490,7 +491,7 @@ public class FlowsResourceTest extends ResourceTest { ...@@ -490,7 +491,7 @@ public class FlowsResourceTest extends ResourceTest {
490 replay(mockDeviceService); 491 replay(mockDeviceService);
491 final WebResource rs = resource(); 492 final WebResource rs = resource();
492 final String response = rs.path("flows").get(String.class); 493 final String response = rs.path("flows").get(String.class);
493 - final JsonObject result = JsonObject.readFrom(response); 494 + final JsonObject result = Json.parse(response).asObject();
494 assertThat(result, notNullValue()); 495 assertThat(result, notNullValue());
495 496
496 assertThat(result.names(), hasSize(1)); 497 assertThat(result.names(), hasSize(1));
...@@ -518,7 +519,7 @@ public class FlowsResourceTest extends ResourceTest { ...@@ -518,7 +519,7 @@ public class FlowsResourceTest extends ResourceTest {
518 replay(mockDeviceService); 519 replay(mockDeviceService);
519 final WebResource rs = resource(); 520 final WebResource rs = resource();
520 final String response = rs.path("flows/" + deviceId3).get(String.class); 521 final String response = rs.path("flows/" + deviceId3).get(String.class);
521 - final JsonObject result = JsonObject.readFrom(response); 522 + final JsonObject result = Json.parse(response).asObject();
522 assertThat(result, notNullValue()); 523 assertThat(result, notNullValue());
523 524
524 assertThat(result.names(), hasSize(1)); 525 assertThat(result.names(), hasSize(1));
...@@ -545,7 +546,7 @@ public class FlowsResourceTest extends ResourceTest { ...@@ -545,7 +546,7 @@ public class FlowsResourceTest extends ResourceTest {
545 final WebResource rs = resource(); 546 final WebResource rs = resource();
546 final String response = rs.path("flows/" + deviceId3 + "/" 547 final String response = rs.path("flows/" + deviceId3 + "/"
547 + Long.toString(flow5.id().value())).get(String.class); 548 + Long.toString(flow5.id().value())).get(String.class);
548 - final JsonObject result = JsonObject.readFrom(response); 549 + final JsonObject result = Json.parse(response).asObject();
549 assertThat(result, notNullValue()); 550 assertThat(result, notNullValue());
550 551
551 assertThat(result.names(), hasSize(1)); 552 assertThat(result.names(), hasSize(1));
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 16
17 package org.onosproject.rest; 17 package org.onosproject.rest;
18 18
19 +import com.eclipsesource.json.Json;
19 import com.eclipsesource.json.JsonArray; 20 import com.eclipsesource.json.JsonArray;
20 import com.eclipsesource.json.JsonObject; 21 import com.eclipsesource.json.JsonObject;
21 import com.google.common.collect.ImmutableSet; 22 import com.google.common.collect.ImmutableSet;
...@@ -410,7 +411,7 @@ public class GroupsResourceTest extends ResourceTest { ...@@ -410,7 +411,7 @@ public class GroupsResourceTest extends ResourceTest {
410 replay(mockDeviceService); 411 replay(mockDeviceService);
411 final WebResource rs = resource(); 412 final WebResource rs = resource();
412 final String response = rs.path("groups").get(String.class); 413 final String response = rs.path("groups").get(String.class);
413 - final JsonObject result = JsonObject.readFrom(response); 414 + final JsonObject result = Json.parse(response).asObject();
414 assertThat(result, notNullValue()); 415 assertThat(result, notNullValue());
415 416
416 assertThat(result.names(), hasSize(1)); 417 assertThat(result.names(), hasSize(1));
...@@ -438,7 +439,7 @@ public class GroupsResourceTest extends ResourceTest { ...@@ -438,7 +439,7 @@ public class GroupsResourceTest extends ResourceTest {
438 replay(mockDeviceService); 439 replay(mockDeviceService);
439 final WebResource rs = resource(); 440 final WebResource rs = resource();
440 final String response = rs.path("groups/" + deviceId3).get(String.class); 441 final String response = rs.path("groups/" + deviceId3).get(String.class);
441 - final JsonObject result = JsonObject.readFrom(response); 442 + final JsonObject result = Json.parse(response).asObject();
442 assertThat(result, notNullValue()); 443 assertThat(result, notNullValue());
443 444
444 assertThat(result.names(), hasSize(1)); 445 assertThat(result.names(), hasSize(1));
...@@ -460,7 +461,7 @@ public class GroupsResourceTest extends ResourceTest { ...@@ -460,7 +461,7 @@ public class GroupsResourceTest extends ResourceTest {
460 replay(mockGroupService); 461 replay(mockGroupService);
461 final WebResource rs = resource(); 462 final WebResource rs = resource();
462 final String response = rs.path("groups/" + deviceId3 + "/" + "111").get(String.class); 463 final String response = rs.path("groups/" + deviceId3 + "/" + "111").get(String.class);
463 - final JsonObject result = JsonObject.readFrom(response); 464 + final JsonObject result = Json.parse(response).asObject();
464 assertThat(result, notNullValue()); 465 assertThat(result, notNullValue());
465 466
466 assertThat(result.names(), hasSize(1)); 467 assertThat(result.names(), hasSize(1));
......
...@@ -21,6 +21,7 @@ import java.net.HttpURLConnection; ...@@ -21,6 +21,7 @@ import java.net.HttpURLConnection;
21 import java.util.HashSet; 21 import java.util.HashSet;
22 import java.util.Set; 22 import java.util.Set;
23 23
24 +import com.eclipsesource.json.Json;
24 import com.sun.jersey.api.client.ClientResponse; 25 import com.sun.jersey.api.client.ClientResponse;
25 import org.hamcrest.Description; 26 import org.hamcrest.Description;
26 import org.hamcrest.Matchers; 27 import org.hamcrest.Matchers;
...@@ -273,7 +274,7 @@ public class HostResourceTest extends ResourceTest { ...@@ -273,7 +274,7 @@ public class HostResourceTest extends ResourceTest {
273 String response = rs.path("hosts").get(String.class); 274 String response = rs.path("hosts").get(String.class);
274 assertThat(response, containsString("{\"hosts\":[")); 275 assertThat(response, containsString("{\"hosts\":["));
275 276
276 - final JsonObject result = JsonObject.readFrom(response); 277 + final JsonObject result = Json.parse(response).asObject();
277 assertThat(result, notNullValue()); 278 assertThat(result, notNullValue());
278 279
279 assertThat(result.names(), hasSize(1)); 280 assertThat(result.names(), hasSize(1));
...@@ -308,7 +309,7 @@ public class HostResourceTest extends ResourceTest { ...@@ -308,7 +309,7 @@ public class HostResourceTest extends ResourceTest {
308 309
309 WebResource rs = resource(); 310 WebResource rs = resource();
310 String response = rs.path("hosts/00:00:11:00:00:01%2F1").get(String.class); 311 String response = rs.path("hosts/00:00:11:00:00:01%2F1").get(String.class);
311 - final JsonObject result = JsonObject.readFrom(response); 312 + final JsonObject result = Json.parse(response).asObject();
312 assertThat(result, matchesHost(host1)); 313 assertThat(result, matchesHost(host1));
313 } 314 }
314 315
...@@ -334,7 +335,7 @@ public class HostResourceTest extends ResourceTest { ...@@ -334,7 +335,7 @@ public class HostResourceTest extends ResourceTest {
334 335
335 WebResource rs = resource(); 336 WebResource rs = resource();
336 String response = rs.path("hosts/00:00:11:00:00:01/1").get(String.class); 337 String response = rs.path("hosts/00:00:11:00:00:01/1").get(String.class);
337 - final JsonObject result = JsonObject.readFrom(response); 338 + final JsonObject result = Json.parse(response).asObject();
338 assertThat(result, matchesHost(host1)); 339 assertThat(result, matchesHost(host1));
339 } 340 }
340 341
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.rest; 16 package org.onosproject.rest;
17 17
18 +import com.eclipsesource.json.Json;
18 import com.eclipsesource.json.JsonArray; 19 import com.eclipsesource.json.JsonArray;
19 import com.eclipsesource.json.JsonObject; 20 import com.eclipsesource.json.JsonObject;
20 import com.eclipsesource.json.JsonValue; 21 import com.eclipsesource.json.JsonValue;
...@@ -294,7 +295,7 @@ public class IntentsResourceTest extends ResourceTest { ...@@ -294,7 +295,7 @@ public class IntentsResourceTest extends ResourceTest {
294 final String response = rs.path("intents").get(String.class); 295 final String response = rs.path("intents").get(String.class);
295 assertThat(response, containsString("{\"intents\":[")); 296 assertThat(response, containsString("{\"intents\":["));
296 297
297 - final JsonObject result = JsonObject.readFrom(response); 298 + final JsonObject result = Json.parse(response).asObject();
298 assertThat(result, notNullValue()); 299 assertThat(result, notNullValue());
299 300
300 assertThat(result.names(), hasSize(1)); 301 assertThat(result.names(), hasSize(1));
...@@ -341,13 +342,13 @@ public class IntentsResourceTest extends ResourceTest { ...@@ -341,13 +342,13 @@ public class IntentsResourceTest extends ResourceTest {
341 // Test get using key string 342 // Test get using key string
342 final String response = rs.path("intents/" + APP_ID.name() 343 final String response = rs.path("intents/" + APP_ID.name()
343 + "/0").get(String.class); 344 + "/0").get(String.class);
344 - final JsonObject result = JsonObject.readFrom(response); 345 + final JsonObject result = Json.parse(response).asObject();
345 assertThat(result, matchesIntent(intent)); 346 assertThat(result, matchesIntent(intent));
346 347
347 // Test get using numeric value 348 // Test get using numeric value
348 final String responseNumeric = rs.path("intents/" + APP_ID.name() 349 final String responseNumeric = rs.path("intents/" + APP_ID.name()
349 + "/0x0").get(String.class); 350 + "/0x0").get(String.class);
350 - final JsonObject resultNumeric = JsonObject.readFrom(responseNumeric); 351 + final JsonObject resultNumeric = Json.parse(responseNumeric).asObject();
351 assertThat(resultNumeric, matchesIntent(intent)); 352 assertThat(resultNumeric, matchesIntent(intent));
352 } 353 }
353 354
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.rest; 16 package org.onosproject.rest;
17 17
18 +import com.eclipsesource.json.Json;
18 import org.hamcrest.Description; 19 import org.hamcrest.Description;
19 import org.hamcrest.TypeSafeMatcher; 20 import org.hamcrest.TypeSafeMatcher;
20 import org.junit.After; 21 import org.junit.After;
...@@ -200,7 +201,7 @@ public class LinksResourceTest extends ResourceTest { ...@@ -200,7 +201,7 @@ public class LinksResourceTest extends ResourceTest {
200 String response = rs.path("links").get(String.class); 201 String response = rs.path("links").get(String.class);
201 assertThat(response, containsString("{\"links\":[")); 202 assertThat(response, containsString("{\"links\":["));
202 203
203 - JsonObject result = JsonObject.readFrom(response); 204 + JsonObject result = Json.parse(response).asObject();
204 assertThat(result, notNullValue()); 205 assertThat(result, notNullValue());
205 206
206 assertThat(result.names(), hasSize(1)); 207 assertThat(result.names(), hasSize(1));
...@@ -233,7 +234,7 @@ public class LinksResourceTest extends ResourceTest { ...@@ -233,7 +234,7 @@ public class LinksResourceTest extends ResourceTest {
233 .get(String.class); 234 .get(String.class);
234 assertThat(response, containsString("{\"links\":[")); 235 assertThat(response, containsString("{\"links\":["));
235 236
236 - JsonObject result = JsonObject.readFrom(response); 237 + JsonObject result = Json.parse(response).asObject();
237 assertThat(result, notNullValue()); 238 assertThat(result, notNullValue());
238 239
239 assertThat(result.names(), hasSize(1)); 240 assertThat(result.names(), hasSize(1));
...@@ -267,7 +268,7 @@ public class LinksResourceTest extends ResourceTest { ...@@ -267,7 +268,7 @@ public class LinksResourceTest extends ResourceTest {
267 .get(String.class); 268 .get(String.class);
268 assertThat(response, containsString("{\"links\":[")); 269 assertThat(response, containsString("{\"links\":["));
269 270
270 - JsonObject result = JsonObject.readFrom(response); 271 + JsonObject result = Json.parse(response).asObject();
271 assertThat(result, notNullValue()); 272 assertThat(result, notNullValue());
272 273
273 assertThat(result.names(), hasSize(1)); 274 assertThat(result.names(), hasSize(1));
...@@ -302,7 +303,7 @@ public class LinksResourceTest extends ResourceTest { ...@@ -302,7 +303,7 @@ public class LinksResourceTest extends ResourceTest {
302 .get(String.class); 303 .get(String.class);
303 assertThat(response, containsString("{\"links\":[")); 304 assertThat(response, containsString("{\"links\":["));
304 305
305 - JsonObject result = JsonObject.readFrom(response); 306 + JsonObject result = Json.parse(response).asObject();
306 assertThat(result, notNullValue()); 307 assertThat(result, notNullValue());
307 308
308 assertThat(result.names(), hasSize(1)); 309 assertThat(result.names(), hasSize(1));
...@@ -336,7 +337,7 @@ public class LinksResourceTest extends ResourceTest { ...@@ -336,7 +337,7 @@ public class LinksResourceTest extends ResourceTest {
336 .get(String.class); 337 .get(String.class);
337 assertThat(response, containsString("{\"links\":[")); 338 assertThat(response, containsString("{\"links\":["));
338 339
339 - JsonObject result = JsonObject.readFrom(response); 340 + JsonObject result = Json.parse(response).asObject();
340 assertThat(result, notNullValue()); 341 assertThat(result, notNullValue());
341 342
342 assertThat(result.names(), hasSize(1)); 343 assertThat(result.names(), hasSize(1));
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 16
17 package org.onosproject.rest; 17 package org.onosproject.rest;
18 18
19 +import com.eclipsesource.json.Json;
19 import com.eclipsesource.json.JsonArray; 20 import com.eclipsesource.json.JsonArray;
20 import com.eclipsesource.json.JsonObject; 21 import com.eclipsesource.json.JsonObject;
21 import com.google.common.collect.ImmutableSet; 22 import com.google.common.collect.ImmutableSet;
...@@ -385,7 +386,7 @@ public class MetersResourceTest extends ResourceTest { ...@@ -385,7 +386,7 @@ public class MetersResourceTest extends ResourceTest {
385 replay(mockDeviceService); 386 replay(mockDeviceService);
386 final WebResource rs = resource(); 387 final WebResource rs = resource();
387 final String response = rs.path("meters").get(String.class); 388 final String response = rs.path("meters").get(String.class);
388 - final JsonObject result = JsonObject.readFrom(response); 389 + final JsonObject result = Json.parse(response).asObject();
389 assertThat(result, notNullValue()); 390 assertThat(result, notNullValue());
390 391
391 assertThat(result.names(), hasSize(1)); 392 assertThat(result.names(), hasSize(1));
...@@ -415,7 +416,7 @@ public class MetersResourceTest extends ResourceTest { ...@@ -415,7 +416,7 @@ public class MetersResourceTest extends ResourceTest {
415 416
416 final WebResource rs = resource(); 417 final WebResource rs = resource();
417 final String response = rs.path("meters/" + deviceId1.toString()).get(String.class); 418 final String response = rs.path("meters/" + deviceId1.toString()).get(String.class);
418 - final JsonObject result = JsonObject.readFrom(response); 419 + final JsonObject result = Json.parse(response).asObject();
419 assertThat(result, notNullValue()); 420 assertThat(result, notNullValue());
420 421
421 assertThat(result.names(), hasSize(1)); 422 assertThat(result.names(), hasSize(1));
...@@ -441,7 +442,7 @@ public class MetersResourceTest extends ResourceTest { ...@@ -441,7 +442,7 @@ public class MetersResourceTest extends ResourceTest {
441 final WebResource rs = resource(); 442 final WebResource rs = resource();
442 final String response = rs.path("meters/" + deviceId3.toString() 443 final String response = rs.path("meters/" + deviceId3.toString()
443 + "/" + meter5.id().id()).get(String.class); 444 + "/" + meter5.id().id()).get(String.class);
444 - final JsonObject result = JsonObject.readFrom(response); 445 + final JsonObject result = Json.parse(response).asObject();
445 assertThat(result, notNullValue()); 446 assertThat(result, notNullValue());
446 447
447 assertThat(result.names(), hasSize(1)); 448 assertThat(result.names(), hasSize(1));
......
...@@ -19,6 +19,7 @@ import com.codahale.metrics.Counter; ...@@ -19,6 +19,7 @@ import com.codahale.metrics.Counter;
19 import com.codahale.metrics.Meter; 19 import com.codahale.metrics.Meter;
20 import com.codahale.metrics.Metric; 20 import com.codahale.metrics.Metric;
21 import com.codahale.metrics.Timer; 21 import com.codahale.metrics.Timer;
22 +import com.eclipsesource.json.Json;
22 import com.eclipsesource.json.JsonArray; 23 import com.eclipsesource.json.JsonArray;
23 import com.eclipsesource.json.JsonObject; 24 import com.eclipsesource.json.JsonObject;
24 import com.google.common.collect.ImmutableMap; 25 import com.google.common.collect.ImmutableMap;
...@@ -109,7 +110,7 @@ public class MetricsResourceTest extends ResourceTest { ...@@ -109,7 +110,7 @@ public class MetricsResourceTest extends ResourceTest {
109 String response = rs.path("metrics").get(String.class); 110 String response = rs.path("metrics").get(String.class);
110 assertThat(response, containsString("{\"metrics\":[")); 111 assertThat(response, containsString("{\"metrics\":["));
111 112
112 - JsonObject result = JsonObject.readFrom(response); 113 + JsonObject result = Json.parse(response).asObject();
113 assertThat(result, notNullValue()); 114 assertThat(result, notNullValue());
114 115
115 JsonArray jsonMetrics = result.get("metrics").asArray(); 116 JsonArray jsonMetrics = result.get("metrics").asArray();
......
...@@ -20,6 +20,7 @@ import java.net.URLEncoder; ...@@ -20,6 +20,7 @@ import java.net.URLEncoder;
20 import java.nio.charset.StandardCharsets; 20 import java.nio.charset.StandardCharsets;
21 import java.util.Set; 21 import java.util.Set;
22 22
23 +import com.eclipsesource.json.Json;
23 import org.hamcrest.Description; 24 import org.hamcrest.Description;
24 import org.hamcrest.TypeSafeDiagnosingMatcher; 25 import org.hamcrest.TypeSafeDiagnosingMatcher;
25 import org.junit.After; 26 import org.junit.After;
...@@ -179,7 +180,7 @@ public class PathsResourceTest extends ResourceTest { ...@@ -179,7 +180,7 @@ public class PathsResourceTest extends ResourceTest {
179 String response = rs.path(url).get(String.class); 180 String response = rs.path(url).get(String.class);
180 assertThat(response, containsString("{\"paths\":[")); 181 assertThat(response, containsString("{\"paths\":["));
181 182
182 - JsonObject result = JsonObject.readFrom(response); 183 + JsonObject result = Json.parse(response).asObject();
183 assertThat(result, notNullValue()); 184 assertThat(result, notNullValue());
184 185
185 assertThat(result.names(), hasSize(1)); 186 assertThat(result.names(), hasSize(1));
......
...@@ -18,6 +18,7 @@ package org.onosproject.rest; ...@@ -18,6 +18,7 @@ package org.onosproject.rest;
18 import java.util.HashMap; 18 import java.util.HashMap;
19 import java.util.stream.IntStream; 19 import java.util.stream.IntStream;
20 20
21 +import com.eclipsesource.json.Json;
21 import org.junit.Before; 22 import org.junit.Before;
22 import org.junit.Test; 23 import org.junit.Test;
23 import org.onlab.osgi.ServiceDirectory; 24 import org.onlab.osgi.ServiceDirectory;
...@@ -126,7 +127,7 @@ public class StatisticsResourceTest extends ResourceTest { ...@@ -126,7 +127,7 @@ public class StatisticsResourceTest extends ResourceTest {
126 .queryParam("port", "2") 127 .queryParam("port", "2")
127 .get(String.class); 128 .get(String.class);
128 129
129 - final JsonObject result = JsonObject.readFrom(response); 130 + final JsonObject result = Json.parse(response).asObject();
130 assertThat(result, notNullValue()); 131 assertThat(result, notNullValue());
131 132
132 assertThat(result.names(), hasSize(1)); 133 assertThat(result.names(), hasSize(1));
...@@ -148,7 +149,7 @@ public class StatisticsResourceTest extends ResourceTest { ...@@ -148,7 +149,7 @@ public class StatisticsResourceTest extends ResourceTest {
148 final WebResource rs = resource(); 149 final WebResource rs = resource();
149 final String response = rs.path("statistics/flows/link/").get(String.class); 150 final String response = rs.path("statistics/flows/link/").get(String.class);
150 151
151 - final JsonObject result = JsonObject.readFrom(response); 152 + final JsonObject result = Json.parse(response).asObject();
152 assertThat(result, notNullValue()); 153 assertThat(result, notNullValue());
153 154
154 assertThat(result.names(), hasSize(1)); 155 assertThat(result.names(), hasSize(1));
......
...@@ -17,6 +17,7 @@ package org.onosproject.rest; ...@@ -17,6 +17,7 @@ package org.onosproject.rest;
17 17
18 import java.util.Set; 18 import java.util.Set;
19 19
20 +import com.eclipsesource.json.Json;
20 import org.junit.Before; 21 import org.junit.Before;
21 import org.junit.Test; 22 import org.junit.Test;
22 import org.onlab.osgi.ServiceDirectory; 23 import org.onlab.osgi.ServiceDirectory;
...@@ -167,7 +168,7 @@ public class TopologyResourceTest extends ResourceTest { ...@@ -167,7 +168,7 @@ public class TopologyResourceTest extends ResourceTest {
167 public void getTopology() { 168 public void getTopology() {
168 WebResource rs = resource(); 169 WebResource rs = resource();
169 String response = rs.path("topology").get(String.class); 170 String response = rs.path("topology").get(String.class);
170 - JsonObject result = JsonObject.readFrom(response); 171 + JsonObject result = Json.parse(response).asObject();
171 assertThat(result, notNullValue()); 172 assertThat(result, notNullValue());
172 173
173 assertThat(result.names(), hasSize(4)); 174 assertThat(result.names(), hasSize(4));
...@@ -185,7 +186,7 @@ public class TopologyResourceTest extends ResourceTest { ...@@ -185,7 +186,7 @@ public class TopologyResourceTest extends ResourceTest {
185 public void getTopologyClusters() { 186 public void getTopologyClusters() {
186 WebResource rs = resource(); 187 WebResource rs = resource();
187 String response = rs.path("topology/clusters").get(String.class); 188 String response = rs.path("topology/clusters").get(String.class);
188 - JsonObject result = JsonObject.readFrom(response); 189 + JsonObject result = Json.parse(response).asObject();
189 assertThat(result, notNullValue()); 190 assertThat(result, notNullValue());
190 191
191 assertThat(result.names(), hasSize(1)); 192 assertThat(result.names(), hasSize(1));
...@@ -201,7 +202,7 @@ public class TopologyResourceTest extends ResourceTest { ...@@ -201,7 +202,7 @@ public class TopologyResourceTest extends ResourceTest {
201 public void getCluster() { 202 public void getCluster() {
202 WebResource rs = resource(); 203 WebResource rs = resource();
203 String response = rs.path("topology/clusters/0").get(String.class); 204 String response = rs.path("topology/clusters/0").get(String.class);
204 - JsonObject result = JsonObject.readFrom(response); 205 + JsonObject result = Json.parse(response).asObject();
205 assertThat(result, notNullValue()); 206 assertThat(result, notNullValue());
206 207
207 assertThat(result.get("id").asLong(), is(0L)); 208 assertThat(result.get("id").asLong(), is(0L));
...@@ -219,7 +220,7 @@ public class TopologyResourceTest extends ResourceTest { ...@@ -219,7 +220,7 @@ public class TopologyResourceTest extends ResourceTest {
219 public void getClusterDevices() { 220 public void getClusterDevices() {
220 WebResource rs = resource(); 221 WebResource rs = resource();
221 String response = rs.path("topology/clusters/0/devices").get(String.class); 222 String response = rs.path("topology/clusters/0/devices").get(String.class);
222 - JsonObject result = JsonObject.readFrom(response); 223 + JsonObject result = Json.parse(response).asObject();
223 assertThat(result, notNullValue()); 224 assertThat(result, notNullValue());
224 225
225 JsonArray devices = result.get("devices").asArray(); 226 JsonArray devices = result.get("devices").asArray();
...@@ -236,7 +237,7 @@ public class TopologyResourceTest extends ResourceTest { ...@@ -236,7 +237,7 @@ public class TopologyResourceTest extends ResourceTest {
236 public void getClusterLinks() { 237 public void getClusterLinks() {
237 WebResource rs = resource(); 238 WebResource rs = resource();
238 String response = rs.path("topology/clusters/1/links").get(String.class); 239 String response = rs.path("topology/clusters/1/links").get(String.class);
239 - JsonObject result = JsonObject.readFrom(response); 240 + JsonObject result = Json.parse(response).asObject();
240 assertThat(result, notNullValue()); 241 assertThat(result, notNullValue());
241 242
242 JsonArray links = result.get("links").asArray(); 243 JsonArray links = result.get("links").asArray();
...@@ -260,7 +261,7 @@ public class TopologyResourceTest extends ResourceTest { ...@@ -260,7 +261,7 @@ public class TopologyResourceTest extends ResourceTest {
260 public void getBroadcast() { 261 public void getBroadcast() {
261 WebResource rs = resource(); 262 WebResource rs = resource();
262 String response = rs.path("topology/broadcast/dev1:1").get(String.class); 263 String response = rs.path("topology/broadcast/dev1:1").get(String.class);
263 - JsonObject result = JsonObject.readFrom(response); 264 + JsonObject result = Json.parse(response).asObject();
264 assertThat(result, notNullValue()); 265 assertThat(result, notNullValue());
265 266
266 assertThat(result.get("broadcast").asBoolean(), is(true)); 267 assertThat(result.get("broadcast").asBoolean(), is(true));
...@@ -273,7 +274,7 @@ public class TopologyResourceTest extends ResourceTest { ...@@ -273,7 +274,7 @@ public class TopologyResourceTest extends ResourceTest {
273 public void getInfrastructure() { 274 public void getInfrastructure() {
274 WebResource rs = resource(); 275 WebResource rs = resource();
275 String response = rs.path("topology/infrastructure/dev2:1").get(String.class); 276 String response = rs.path("topology/infrastructure/dev2:1").get(String.class);
276 - JsonObject result = JsonObject.readFrom(response); 277 + JsonObject result = Json.parse(response).asObject();
277 assertThat(result, notNullValue()); 278 assertThat(result, notNullValue());
278 279
279 assertThat(result.get("infrastructure").asBoolean(), is(true)); 280 assertThat(result.get("infrastructure").asBoolean(), is(true));
......
...@@ -19,6 +19,7 @@ import java.net.HttpURLConnection; ...@@ -19,6 +19,7 @@ import java.net.HttpURLConnection;
19 import java.util.HashSet; 19 import java.util.HashSet;
20 import java.util.Set; 20 import java.util.Set;
21 21
22 +import com.eclipsesource.json.Json;
22 import org.junit.Assert; 23 import org.junit.Assert;
23 import org.junit.Before; 24 import org.junit.Before;
24 import org.junit.Test; 25 import org.junit.Test;
...@@ -269,7 +270,7 @@ public class NetworkConfigWebResourceTest extends ResourceTest { ...@@ -269,7 +270,7 @@ public class NetworkConfigWebResourceTest extends ResourceTest {
269 final WebResource rs = resource(); 270 final WebResource rs = resource();
270 final String response = rs.path("network/configuration").get(String.class); 271 final String response = rs.path("network/configuration").get(String.class);
271 272
272 - final JsonObject result = JsonObject.readFrom(response); 273 + final JsonObject result = Json.parse(response).asObject();
273 Assert.assertThat(result, notNullValue()); 274 Assert.assertThat(result, notNullValue());
274 275
275 Assert.assertThat(result.names(), hasSize(2)); 276 Assert.assertThat(result.names(), hasSize(2));
...@@ -296,7 +297,7 @@ public class NetworkConfigWebResourceTest extends ResourceTest { ...@@ -296,7 +297,7 @@ public class NetworkConfigWebResourceTest extends ResourceTest {
296 final WebResource rs = resource(); 297 final WebResource rs = resource();
297 final String response = rs.path("network/configuration/devices").get(String.class); 298 final String response = rs.path("network/configuration/devices").get(String.class);
298 299
299 - final JsonObject result = JsonObject.readFrom(response); 300 + final JsonObject result = Json.parse(response).asObject();
300 Assert.assertThat(result, notNullValue()); 301 Assert.assertThat(result, notNullValue());
301 302
302 Assert.assertThat(result.names(), hasSize(1)); 303 Assert.assertThat(result.names(), hasSize(1));
...@@ -322,7 +323,7 @@ public class NetworkConfigWebResourceTest extends ResourceTest { ...@@ -322,7 +323,7 @@ public class NetworkConfigWebResourceTest extends ResourceTest {
322 rs.path("network/configuration/devices/device1") 323 rs.path("network/configuration/devices/device1")
323 .get(String.class); 324 .get(String.class);
324 325
325 - final JsonObject result = JsonObject.readFrom(response); 326 + final JsonObject result = Json.parse(response).asObject();
326 Assert.assertThat(result, notNullValue()); 327 Assert.assertThat(result, notNullValue());
327 328
328 Assert.assertThat(result.names(), hasSize(1)); 329 Assert.assertThat(result.names(), hasSize(1));
...@@ -345,7 +346,7 @@ public class NetworkConfigWebResourceTest extends ResourceTest { ...@@ -345,7 +346,7 @@ public class NetworkConfigWebResourceTest extends ResourceTest {
345 rs.path("network/configuration/devices/device1/basic") 346 rs.path("network/configuration/devices/device1/basic")
346 .get(String.class); 347 .get(String.class);
347 348
348 - final JsonObject result = JsonObject.readFrom(response); 349 + final JsonObject result = Json.parse(response).asObject();
349 Assert.assertThat(result, notNullValue()); 350 Assert.assertThat(result, notNullValue());
350 351
351 Assert.assertThat(result.names(), hasSize(2)); 352 Assert.assertThat(result.names(), hasSize(2));
......