### Question:
ReportEvent extends EventImpl { public void toJson(Writer o) throws IOException { PrintWriter pw = new PrintWriter(o); pw.print("{"); pw.print("\"host\" : \"" + StringEscapeUtils.escapeJava(getHost()) + "\""); for (String attr : getAttrs().keySet()) { String v = Attributes.toStringStrict(this, attr); Type t = Attributes.getType(attr); pw.print(", \"" + StringEscapeUtils.escapeJava(attr) + "\" : "); if (t != null && t == Type.STRING) { pw.print("\"" + StringEscapeUtils.escapeJava(v) + "\""); } else { pw.print(StringEscapeUtils.escapeJava(v)); } } for (Entry<String, String> entry : getAllStringMetrics().entrySet()) { pw.print(", \"" + StringEscapeUtils.escapeJava(entry.getKey()) + "\" : "); pw.print("\"" + StringEscapeUtils.escapeJava(entry.getValue()) + "\""); } for (Entry<String, Double> entry : getAllDoubleMetrics().entrySet()) { pw.print(", \"" + StringEscapeUtils.escapeJava(entry.getKey()) + "\" : "); pw.print(entry.getValue()); } for (Entry<String, Long> entry : getAllLongMetrics().entrySet()) { pw.print(", \"" + StringEscapeUtils.escapeJava(entry.getKey()) + "\" : "); pw.print(entry.getValue()); } pw.println("}"); } ReportEvent(ReportEvent e);  ReportEvent(String src);  ReportEvent(Map<String, Long> longMetrics,
      Map<String, String> stringMetrics, Map<String, Double> doubleMetrics); void setLongMetric(String name, long value); void setDoubleMetric(String name, double value); void setStringMetric(String name, String value); Long getLongMetric(String name); Double getDoubleMetric(String name); String getStringMetric(String name); Map<String, Double> getAllDoubleMetrics(); Map<String, String> getAllStringMetrics(); Map<String, Long> getAllLongMetrics(); long getNumMetrics(); void toJson(Writer o); void toHtml(Writer o); String toString(); void toText(Writer o); static ReportEvent createLegacyHtmlReport(String name, String data); void merge(ReportEvent e); void hierarchicalMerge(String prefix, ReportEvent e); String toText(); String toJson(); String toHtml(); final static String R_NAME; final static String A_COUNT; }### Answer:
@Test public void testReportJson() throws IOException { Writer w = new OutputStreamWriter(System.out); e.toJson(w); w.flush(); }