@SuppressWarnings("serial")
@Test
public void testEventQueueMillis() throws InterruptedException {
Thread.sleep(100);
final Event e = new EventImpl("test".getBytes());
EventQueue q = new EventQueue(10) {
{
add(e);
System.out.println("insert " + e.getTimestamp() + " " + e.getNanos()
+ " " + e);
add(e4);
System.out.println("insert " + e4.getTimestamp() + " " + e4.getNanos()
+ " " + e4);
add(e2);
System.out.println("insert " + e2.getTimestamp() + " " + e2.getNanos()
+ " " + e2);
add(e1);
System.out.println("insert " + e1.getTimestamp() + " " + e1.getNanos()
+ " " + e1);
add(e3);
System.out.println("insert " + e3.getTimestamp() + " " + e3.getNanos()
+ " " + e3);
}
};
Event[] ordered = { e1, e2, e3, e4, e };
for (int i = 0; i < ordered.length; i++) {
Event qe = q.take();
System.out.println("take " + qe.getTimestamp() + " " + qe.getNanos()
+ " " + qe);
Assert.assertEquals(ordered[i], qe);
}
}