protected void testAdd(final SequentialFileFactory factory, final int numberOfElements) throws Exception
{
SequentialFile file = factory.createSequentialFile("00010.page", 1);
PageImpl impl = new PageImpl(new SimpleString("something"), new NullStorageManager(), factory, file, 10);
Assert.assertEquals(10, impl.getPageId());
impl.open();
Assert.assertEquals(1, factory.listFiles("page").size());
SimpleString simpleDestination = new SimpleString("Test");
ArrayList<HornetQBuffer> buffers = addPageElements(simpleDestination, impl, numberOfElements);
impl.sync();
impl.close();
file = factory.createSequentialFile("00010.page", 1);
file.open();
impl = new PageImpl(new SimpleString("something"), new NullStorageManager(), factory, file, 10);
List<PagedMessage> msgs = impl.read(new NullStorageManager());
Assert.assertEquals(numberOfElements, msgs.size());
Assert.assertEquals(numberOfElements, impl.getNumberOfMessages());