raf.close();
ch.close();
Context ctx = ZMQ.context(1);
Socket router = ctx.socket(ZMQ.ROUTER);
router.bind("tcp://127.0.0.1:6003");
router.setEncoder(Persistence.PersistEncoder.class);
Socket dealer = ctx.socket(ZMQ.DEALER);
dealer.setIdentity("A".getBytes());
dealer.connect("tcp://127.0.0.1:6003");
Thread.sleep(1000);
router.sendMore("A");
router.sendMore(new byte[] {Persistence.MESSAGE_FILE});
router.sendMore(new byte[] {STATUS_OK});
router.sendMore(path);
router.sendMore(ByteBuffer.wrap(new byte[8]).putLong(0).array());
router.send(ByteBuffer.wrap(new byte[8]).putLong(329).array());
assertEquals(dealer.recv()[0], STATUS_OK);
ByteBuffer content = ByteBuffer.wrap(dealer.recv());
assertEquals(content.limit(), 329);
assertEquals(0, content.get());
int length = content.get();
assertEquals(5, length);
byte[] data = new byte[length];
content.get(data);
assertEquals("12345", new String(data));
assertEquals(1, content.get());
length = content.get();
assertEquals(11, length);
data = new byte[length];
content.get(data);
assertEquals("67890abcdef", new String(data));
assertEquals(2, content.get());
length = (int) content.getLong();
assertEquals(300, length);
data = new byte[length];
content.get(data);
assertEquals(longdata, new String(data));
assertEquals(false, content.hasRemaining());
dealer.close();
router.close();
ctx.term();
}