Event e = new EventImpl(("attempt " + i).getBytes());
sink.append(e);
}
Assert.assertEquals(ok.get(), 100);
ReportEvent rpt = sink.getMetrics();
Writer out = new OutputStreamWriter(System.out);
rpt.toJson(out);
out.flush();
// 100 good messages. every 4th message fails -- 3 good 1 bad.
// 00 01 02 xx 03 04 05 xx 06 07 08 xx ...
// so 100 good msgs, 133 total messages, 33 bad msgs
Assert.assertEquals(new Long(100), rpt
.getLongMetric(StubbornAppendSink.A_SUCCESSES));
Assert.assertEquals(new Long(33), rpt
.getLongMetric(StubbornAppendSink.A_FAILS));
Assert.assertEquals(new Long(33), rpt
.getLongMetric(StubbornAppendSink.A_RECOVERS));
}