MemorySinkSource mss = new MemorySinkSource();
ReorderDecorator<EventSink> reorder =
new ReorderDecorator<EventSink>(mss, .5, .5, 0);
reorder.open();
for (int i = 0; i < 10; i++) {
Event e = new EventImpl(new byte[0]);
e.set("order", ByteBuffer.allocate(4).putInt(i).array());
reorder.append(e);
}
System.out.println("closing");
reorder.close();
int[] order = { 0, 2, 1, 4, 3, 5, 7, 6, 8, 9 };
for (int i = 0; i < order.length; i++) {
Event e = mss.next();
int j = ByteBuffer.wrap(e.get("order")).asIntBuffer().get();
assertEquals(j, order[i]);
}
}