JsonHttpResult extends HttpResult { @Override public void printContent(StringBuilder sb) { if (failedParsing) { super.printContent(sb); return; } if (json != null) { sb.append("JSON: "); try{ sb.append(json.toString(2)); } catch (JSONException e) { sb.append(json.toString()); } } else { super.printContent(sb); } } JsonHttpResult();  JsonHttpResult(HttpResult other); JsonHttpResult setJson(JSONObject o); JSONObject getJson(); @Override void printContent(StringBuilder sb);  }
@Test public void testNonJsonOutput() { JsonHttpResult result = new JsonHttpResult(); result.setContent("Foo"); StringBuilder sb = new StringBuilder(); result.printContent(sb); assertEquals("Foo", sb.toString()); }