Java Code Examples for org.kurento.jsonrpc.JsonUtils#fromJsonResponse()
The following examples show how to use
org.kurento.jsonrpc.JsonUtils#fromJsonResponse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SessionIdMessageTest.java From kurento-java with Apache License 2.0 | 6 votes |
@Test public void noResultResponseTest() { Response<Void> response = new Response<Void>(1); response.setSessionId("xxxxxxx"); String responseJson = response.toString(); JsonParser parser = new JsonParser(); JsonObject expected = (JsonObject) parser .parse("{\"id\":1,\"result\":{\"sessionId\":\"xxxxxxx\"},\"jsonrpc\":\"2.0\"}"); JsonObject result = (JsonObject) parser.parse(responseJson); Assert.assertEquals(expected, result); log.debug(responseJson); Response<Void> newResponse = JsonUtils.fromJsonResponse(responseJson, Void.class); // Assert.assertEquals(null, newResponse.getResult()); Assert.assertEquals(newResponse.getSessionId(), "xxxxxxx"); }
Example 2
Source File: SessionIdMessageTest.java From kurento-java with Apache License 2.0 | 6 votes |
@Test public void responseTest() { Data data = new Data(); data.data1 = "Value1"; Response<Data> response = new Response<Data>(1, data); response.setSessionId("xxxxxxx"); String responseJson = response.toString(); Assert.assertEquals( "{\"id\":1,\"result\":{\"data1\":\"Value1\",\"sessionId\":\"xxxxxxx\"},\"jsonrpc\":\"2.0\"}", responseJson); log.debug(responseJson); Response<Data> newResponse = JsonUtils.fromJsonResponse(responseJson, Data.class); Assert.assertEquals(data.data1, newResponse.getResult().data1); Assert.assertEquals(newResponse.getSessionId(), "xxxxxxx"); }
Example 3
Source File: ProtocolManager.java From kurento-java with Apache License 2.0 | 5 votes |
private void processResponseMessage(JsonObject messagetJsonObject, String internalSessionId) { Response<JsonElement> response = JsonUtils.fromJsonResponse(messagetJsonObject, JsonElement.class); ServerSession session = sessionsManager.getByTransportId(internalSessionId); if (session != null) { session.handleResponse(response); } else { log.debug("Processing response {} for non-existent session {}", response.toString(), internalSessionId); } }
Example 4
Source File: GenericMessageTest.java From kurento-java with Apache License 2.0 | 4 votes |
@Test public void responseTest() { Data data = new Data(); data.data1 = "Value1"; data.data2 = "Value2"; Response<Data> request = new Response<Data>(1, data); String requestJson = JsonUtils.toJsonResponse(request); log.debug(requestJson); Response<Data> newRequest = JsonUtils.fromJsonResponse(requestJson, Data.class); Assert.assertEquals(data.data1, newRequest.getResult().data1); Assert.assertEquals(data.data2, newRequest.getResult().data2); }