@Test
public void messageReceivedInitiated() throws Exception {

    when(session.getAttribute(Socks5AcceptorHandler.STATE_KEY)).thenReturn(ProxyState.INITIATED);
    IoBuffer buffer = IoBuffer.wrap(new byte[]{5, 1, 0, 3, 9, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x68, 0x6F, 0x73, 0x74, 5, 6});
    
    handler.messageReceived(session, buffer);
    
    verify(session).setAttribute(Socks5AcceptorHandler.STATE_KEY, ProxyState.CONNECTED);
    
    IoBuffer expected = IoBuffer.wrap(new byte[]{5, 0, 0, 3, 9, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x68, 0x6F, 0x73, 0x74, 5, 6});
    verify(session).write(expected);
}