}
@Test
public void bigLoopTest() throws IOException {
bigArray = new BigArrayImpl(testDir, "big_loop_test");
assertNotNull(bigArray);
int loop = 1000000;
long lastAppendTime = System.currentTimeMillis();
for(int i = 0; i < loop; i++) {
bigArray.append(("" + i).getBytes());
assertTrue(bigArray.getTailIndex() == 0L);
assertTrue(bigArray.getHeadIndex() == i + 1L);
assertTrue(bigArray.size() == i + 1L);
assertTrue(!bigArray.isEmpty());
assertTrue(!bigArray.isFull());
long currentTime = System.currentTimeMillis();
long justAppendTime = bigArray.getTimestamp(i);
assertTrue(justAppendTime <= currentTime);
assertTrue(justAppendTime >=lastAppendTime);
lastAppendTime = justAppendTime;
}
try {
bigArray.get(loop);
fail("IndexOutOfBoundsException should be thrown here");
} catch (IndexOutOfBoundsException ex) {
}
assertTrue(bigArray.getTailIndex() == 0L);
assertTrue(bigArray.getHeadIndex() == loop);
assertTrue(bigArray.size() == loop);
assertTrue(!bigArray.isEmpty());
assertTrue(!bigArray.isFull());
bigArray.close();
// create a new instance on exiting array
bigArray = new BigArrayImpl(testDir, "big_loop_test");
assertTrue(bigArray.getTailIndex() == 0L);
assertTrue(bigArray.getHeadIndex() == loop);
assertTrue(bigArray.size() == loop);
assertTrue(!bigArray.isEmpty());
assertTrue(!bigArray.isFull());