@Test
public void testTestCountHistoryClocked() throws IOException, InterruptedException {
MockClock m = new MockClock(0);
Clock.setClock(m);
CountHistoryReporter r = new CountHistoryReporter("test timeline", 500, t);
r.open();
Event e = new EventImpl("Test message".getBytes());
// just a little forward to make things slighlty "out of sync"
// 3
r.append(e);
r.append(e);
r.append(e);
m.forward(501);
// 2
r.append(e);
r.append(e);
m.forward(501);
// 4
r.append(e);
r.append(e);
r.append(e);
r.append(e);
m.forward(501);
// 0 // this never registers!
m.forward(501);
// 1
r.append(e);
m.forward(501);
r.append(e);
long[] times = { 0, 501, 1002, 1503, 2004 };
long[] ans = { 3, 2, 4, 0, 1 };
int i = 0;
for (Pair<Long, CounterSink> p : r.getHistory()) {
System.out.printf("time: %8d count: %8d\n", p.getLeft(), p.getRight()
.getCount());
Assert.assertEquals(ans[i], p.getRight().getCount());
Assert.assertEquals((long) p.getLeft(), times[i]);
i++;
}
r.close();
}