int sequence = 0;
for (int pageNr = 0; pageNr < 2; pageNr++)
{
Page page = storeImpl.depage();
page.open();
List<PagedMessage> msg = page.read();
page.close();
Assert.assertEquals(5, msg.size());
for (int i = 0; i < 5; i++)
{
Assert.assertEquals(sequence++, msg.get(i).getMessage(null).getMessageID());
UnitTestCase.assertEqualsBuffers(18, buffers.get(pageNr * 5 + i), msg.get(i)
.getMessage(null)
.getBodyBuffer());
}
}
Assert.assertEquals(1, storeImpl.getNumberOfPages());
Assert.assertTrue(storeImpl.isPaging());
ServerMessage msg = createMessage(1, storeImpl, destination, buffers.get(0));
Assert.assertTrue(storeImpl.page(msg));
Page newPage = storeImpl.depage();
newPage.open();
Assert.assertEquals(1, newPage.read().size());
newPage.delete();
Assert.assertEquals(1, storeImpl.getNumberOfPages());
Assert.assertTrue(storeImpl.isPaging());
Assert.assertNull(storeImpl.depage());
Assert.assertFalse(storeImpl.isPaging());
Assert.assertFalse(storeImpl.page(msg));
storeImpl.startPaging();
Assert.assertTrue(storeImpl.page(msg));
Page page = storeImpl.depage();
page.open();
List<PagedMessage> msgs = page.read();
Assert.assertEquals(1, msgs.size());
Assert.assertEquals(1l, msgs.get(0).getMessage(null).getMessageID());
UnitTestCase.assertEqualsBuffers(18, buffers.get(0), msgs.get(0).getMessage(null).getBodyBuffer());
Assert.assertEquals(1, storeImpl.getNumberOfPages());
Assert.assertTrue(storeImpl.isPaging());
Assert.assertNull(storeImpl.depage());
Assert.assertEquals(0, storeImpl.getNumberOfPages());
page.open();
}