@Test
public void testExecuteAsync() throws Exception
{

    remotePeer.executeAsync( requestBuilder, containerHost );
    verify( commandResponseListener )
            .addCallback( any( UUID.class ), any( CommandCallback.class ), anyInt(), any( Semaphore.class ) );
    remotePeer.executeAsync( requestBuilder, containerHost, commandCallback );
    verify( commandResponseListener )
            .addCallback( any( UUID.class ), eq( commandCallback ), anyInt(), any( Semaphore.class ) );
    remotePeer.executeAsync( requestBuilder, containerHost, commandCallback, semaphore );
    verify( commandResponseListener )
            .addCallback( any( UUID.class ), eq( commandCallback ), anyInt(), eq( semaphore ) );
    doThrow( messageException ).when( messenger )
                               .sendMessage( any( Peer.class ), any( Message.class ), anyString(), anyInt(),
                                       anyMap() );
    try
    {
        remotePeer.executeAsync( requestBuilder, containerHost, commandCallback, semaphore );
        fail( "Expected CommandException" );
    }
    catch ( CommandException e )
    {
    }
    try
    {
        Host host = mock( Host.class );
        remotePeer.executeAsync( requestBuilder, host, commandCallback, semaphore );
        fail( "Expected CommandException" );
    }
    catch ( CommandException e )
    {
    }
    try
    {
        when( containerHost.isConnected() ).thenReturn( false );
        remotePeer.executeAsync( requestBuilder, containerHost, commandCallback, semaphore );
        fail( "Expected CommandException" );
    }
    catch ( CommandException e )
    {
    }
}