int numMessages = 10;
for (int i = 0; i < numMessages; i++)
{
HornetQBuffer buffer = createRandomBuffer(i + 1l, 10);
buffers.add(buffer);
ServerMessage msg = createMessage(i, storeImpl, destination, buffer);
Assert.assertTrue(storeImpl.page(msg, new RoutingContextImpl(null)));
}
Assert.assertEquals(1, storeImpl.getNumberOfPages());
storeImpl.sync();
Page page = storeImpl.depage();
page.open();
List<PagedMessage> msg = page.read(new NullStorageManager());
Assert.assertEquals(numMessages, msg.size());
Assert.assertEquals(1, storeImpl.getNumberOfPages());
page = storeImpl.depage();
Assert.assertNull(page);
Assert.assertEquals(0, storeImpl.getNumberOfPages());
for (int i = 0; i < numMessages; i++)
{
HornetQBuffer horn1 = buffers.get(i);
HornetQBuffer horn2 = msg.get(i).getMessage().getBodyBuffer();
horn1.resetReaderIndex();
horn2.resetReaderIndex();
for (int j = 0; j < horn1.writerIndex(); j++)
{
Assert.assertEquals(horn1.readByte(), horn2.readByte());
}
}
}