### Question:
Messagizer implements SessionPacket, TransportMessage { public void transportMessage( Who recipient, Message msg ) throws Exception { synchronized (msgBuf) { try { msgBuf.skip( transport.headerSize(), true ); tdo.writeMessage( msg, msgBuf ); msgBuf.setIndex( 0 ); transport.transportPacket( recipient, msgBuf ); } finally { msgBuf.reset(); } } } Messagizer( TransportPacket transport, String uri, Resources resources );  Messagizer( TransportPacket transport, URL uri, Resources resources ); TransportPacket getTransport(); @Override String toString(); void sessionPacket( Who sender, FlexBuffer buf ); void transportMessage( Who recipient, Message msg ); Object sessionQuery( Object query ); void sessionControl( Object control, Object value ); void sessionNotify( Object event ); Object transportQuery( Object query ); void transportControl( Object control, Object value ); void transportNotify( Object event ); SessionMessage getSession(); void setSession( SessionMessage session ); static final String FORMAT; }### Answer:
@Test public void message1() throws Exception { Message msg = new Message( MyValueFactory.mt_add, vf ); transport.header_size = 0; assertNull( transport.what ); m.transportMessage( who, msg ); assertSame( What.TRANSPORT_PACKET, transport.what ); assertSame( who, transport.recipient ); assertNotNull( transport.buf ); assertEquals( 4, transport.buf.length ); assertEquals( VERSION, transport.buf[0] ); assertEquals( (byte) 1, transport.buf[1] ); assertEquals( (byte) 0, transport.buf[2] ); assertEquals( NONE, transport.buf[3] ); }
@Test public void message2() throws Exception { Message msg = new Message( MyValueFactory.mt_add_result, vf ); transport.header_size = 8; assertNull( transport.what ); m.transportMessage( who, msg ); assertSame( What.TRANSPORT_PACKET, transport.what ); assertSame( who, transport.recipient ); assertNotNull( transport.buf ); assertEquals( 12, transport.buf.length ); assertEquals( (byte) 0, transport.buf[0] ); assertEquals( (byte) 0, transport.buf[1] ); assertEquals( (byte) 0, transport.buf[2] ); assertEquals( (byte) 0, transport.buf[3] ); assertEquals( (byte) 0, transport.buf[4] ); assertEquals( (byte) 0, transport.buf[5] ); assertEquals( (byte) 0, transport.buf[6] ); assertEquals( (byte) 0, transport.buf[7] ); assertEquals( VERSION, transport.buf[8] ); assertEquals( (byte) 2, transport.buf[9] ); assertEquals( (byte) 0, transport.buf[10] ); assertEquals( NONE, transport.buf[11] ); }