@Test
public void testSendRequest() throws Exception
{

    remotePeer.sendRequest( REQUEST, RECIPIENT, TIMEOUT, headers );
    verify( messenger ).sendMessage( any( Peer.class ), eq( message ), anyString(), eq( TIMEOUT ), eq( headers ) );
    MessageResponse messageResponse = mock( MessageResponse.class );
    when( messageResponseListener.waitResponse( any( MessageRequest.class ), anyInt(), anyInt() ) )
            .thenReturn( messageResponse );
    remotePeer.sendRequest( REQUEST, RECIPIENT, TIMEOUT, Object.class, TIMEOUT, headers );
    verify( messageResponse ).getException();
    Payload payload = mock( Payload.class );
    when( messageResponse.getPayload() ).thenReturn( payload );
    remotePeer.sendRequest( REQUEST, RECIPIENT, TIMEOUT, Object.class, TIMEOUT, headers );
    verify( payload ).getMessage( any( Class.class ) );
    when( messageResponse.getException() ).thenReturn( "exception" );
    try
    {
        remotePeer.sendRequest( REQUEST, RECIPIENT, TIMEOUT, Object.class, TIMEOUT, headers );
        fail( "Expected PeerException" );
    }
    catch ( PeerException e )
    {
    }
}