msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
Assert.assertTrue(pageStore.page(msg, ctx, ctx.getContextListing(ADDRESS)));
PagedReference readMessage = iterator.next();
assertNotNull(readMessage);
assertEquals(i, readMessage.getMessage().getIntProperty("key").intValue());
assertNull(iterator.next());
}
OperationContextImpl.clearContext();
ctx = generateCTX();
pageStore = lookupPageStore(ADDRESS);
cursor = this.server.getPagingManager().getPageStore(ADDRESS).getCursorProvier().getSubscription(queue.getID());
iterator = cursor.iterator();
for (int i = 0; i < NUM_MESSAGES * 2; i++)
{
if (i % 100 == 0)
System.out.println("Paged " + i);
if (i >= NUM_MESSAGES)
{
HornetQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1l);
ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
msg.putIntProperty("key", i);
msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
Assert.assertTrue(pageStore.page(msg, ctx, ctx.getContextListing(ADDRESS)));
}
PagedReference readMessage = iterator.next();
assertNotNull(readMessage);
assertEquals(i, readMessage.getMessage().getIntProperty("key").intValue());
}
OperationContextImpl.clearContext();
pageStore = lookupPageStore(ADDRESS);
cursor = this.server.getPagingManager().getPageStore(ADDRESS).getCursorProvier().getSubscription(queue.getID());
iterator = cursor.iterator();
for (int i = 0; i < NUM_MESSAGES * 3; i++)
{
if (i % 100 == 0)
System.out.println("Paged " + i);
if (i >= NUM_MESSAGES * 2 - 1)
{
HornetQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1l);
ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
msg.putIntProperty("key", i + 1);
msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
Assert.assertTrue(pageStore.page(msg, ctx, ctx.getContextListing(ADDRESS)));
}
PagedReference readMessage = iterator.next();
assertNotNull(readMessage);
cursor.ack(readMessage);
assertEquals(i, readMessage.getMessage().getIntProperty("key").intValue());
}
PagedReference readMessage = iterator.next();
assertEquals(NUM_MESSAGES * 3, readMessage.getMessage().getIntProperty("key").intValue());
cursor.ack(readMessage);
server.getStorageManager().waitOnOperations();