}
public void testUpdate() {
final int FIRST_VALUE = generateIntTestValue();
final int SECOND_VALUE = generateIntTestValue();
Pojo pojo1 = new Pojo(FIRST_VALUE);
Pojo pojo2 = new Pojo(SECOND_VALUE);
SerializationContext ctx = new SerializationContext();
DeserializationContext dctx = new DeserializationContext();
ByteBuffer buffer = ByteBuffer.allocate(4096);
ctx.serialize(pojo1, buffer);
ctx.serialize(pojo2, buffer);
pojo1.setValue(SECOND_VALUE);
pojo2.setValue(FIRST_VALUE);
ctx.update(pojo2, buffer);
ctx.update(pojo1, buffer);
buffer.flip();
Object obj = dctx.deserialize(buffer);
assertTrue("Object must be a Pojo", obj instanceof Pojo);
Pojo resp1 = (Pojo)obj;
obj = dctx.deserialize(buffer);
assertTrue("Object must be a Pojo", obj instanceof Pojo);
Pojo resp2 = (Pojo)obj;
assertEquals(FIRST_VALUE, resp1.getValue());
assertEquals(SECOND_VALUE, resp2.getValue());
obj = dctx.deserialize(buffer);
assertTrue("Object must be a Pojo", obj instanceof Pojo);
Pojo resp3 = (Pojo)obj;
obj = dctx.deserialize(buffer);
assertTrue("Object must be a Pojo", obj instanceof Pojo);
Pojo resp4 = (Pojo)obj;
assertEquals(FIRST_VALUE, resp3.getValue());
assertEquals(SECOND_VALUE, resp4.getValue());
assertEquals(SECOND_VALUE, resp1.getValue());
assertEquals(FIRST_VALUE, resp2.getValue());
assertSame(resp1, resp4);
assertSame(resp2, resp3);