assertEquals("HelloMINAWorld", toString(cba));
}
public void testCompositeCursor() throws Exception {
IMocksControl mc = createStrictControl();
ByteArray ba1 = getByteArrayFactory().create(10);
ByteArray ba2 = getByteArrayFactory().create(10);
ByteArray ba3 = getByteArrayFactory().create(10);
CompositeByteArray cba = new CompositeByteArray();
cba.addLast(ba1);
cba.addLast(ba2);
cba.addLast(ba3);
CursorListener cl = mc.createMock(CursorListener.class);
mc.reset();
mc.replay();
Cursor cursor = cba.cursor(cl);
mc.verify();
mc.reset();
cl.enteredFirstComponent(0, ba1);
mc.replay();
cursor.get();
mc.verify();
mc.reset();
mc.replay();
cursor.setIndex(10);
mc.verify();
mc.reset();
cl.enteredNextComponent(10, ba2);
mc.replay();
cursor.put((byte) 55);
mc.verify();
mc.reset();
mc.replay();
cursor.setIndex(9);
mc.verify();
mc.reset();
cl.enteredPreviousComponent(0, ba1);
cl.enteredNextComponent(10, ba2);
mc.replay();
cursor.putInt(66);
mc.verify();
mc.reset();
cl.enteredNextComponent(20, ba3);
mc.replay();
cursor.setIndex(29);
cursor.get();
mc.verify();
cba.removeLast(); // Force cursor to relocate itself.
mc.reset();
cl.enteredLastComponent(10, ba2);
mc.replay();
cursor.setIndex(15);
cursor.get();
mc.verify();
mc.reset();
cl.enteredPreviousComponent(0, ba1);
mc.replay();
cursor.setIndex(0);
cursor.get();
mc.verify();
}