public void testAddAndRemoveMessages()
{
long id1 = RandomUtil.randomLong();
long id2 = RandomUtil.randomLong();
PageTransactionInfo trans = new PageTransactionInfoImpl(id2);
trans.setRecordID(id1);
// anything between 2 and 100
int nr1 = RandomUtil.randomPositiveInt() % 98 + 2;
for (int i = 0; i < nr1; i++)
{
trans.increment(true);
}
Assert.assertEquals(nr1, trans.getNumberOfMessages());
HornetQBuffer buffer = HornetQBuffers.fixedBuffer(trans.getEncodeSize());
trans.encode(buffer);
PageTransactionInfo trans2 = new PageTransactionInfoImpl(id1);
trans2.decode(buffer);
Assert.assertEquals(id2, trans2.getTransactionID());
Assert.assertEquals(nr1, trans2.getNumberOfMessages());
}