WilmaHttpEntityUtils { public boolean isJsonMessage(final WilmaHttpEntity request) { boolean isJson; String body = null; try { body = request.getBody(); new JSONObject(body); isJson = true; } catch (JSONException ex) { logger.debug("Request (" + request.getWilmaMessageLoggerId() + ") body is not of JSON type or has invalid syntax: " + body, ex); isJson = false; } return isJson; }  boolean isJsonMessage(final WilmaHttpEntity request); boolean isXmlMessage(final WilmaHttpEntity request); boolean isSoapMessage(final WilmaHttpEntity request);  }
@Test public void testIsJsonMessage() throws Exception { boolean jsonResult = underTest.isJsonMessage(requestOf("{\"property\":\"value\"}")); boolean jsonArrayResult = underTest.isJsonMessage(requestOf("{\"list\":[{\"key\":\"value\"},{\"key\":\"value\"}]}")); boolean xmlResult = underTest.isJsonMessage(requestOf("<root><child></child></root>")); boolean emptyResult = underTest.isJsonMessage(requestOf("")); boolean textResult = underTest.isJsonMessage(requestOf("simple text")); assertTrue(jsonResult); assertTrue(jsonArrayResult); assertFalse(xmlResult); assertFalse(emptyResult); assertFalse(textResult); }