@Test
public void testSendMessageSafely_theMessageIsSentWhenTheMachineIsThere_butMessagingIsNotReady() throws Exception {

	TestApplication app = new TestApplication();
	ManagedApplication ma = new ManagedApplication( app );
	Message msg = new MsgCmdRemoveInstance( "/" );
	app.getMySqlVm().setStatus( InstanceStatus.DEPLOYED_STARTED );
	Mockito.when( this.msgClient.isConnected()).thenReturn( false );
	Mockito.verifyZeroInteractions( this.msgClient );
	this.mngr.sendMessageSafely( ma, app.getMySqlVm(), msg );
	Mockito.verify( this.msgClient, Mockito.times( 1 )).isConnected();
	Mockito.verify( this.msgClient, Mockito.times( 0 )).sendMessageToAgent(
			Mockito.any( Application.class ),
			Mockito.any( Instance.class ),
			Mockito.any( Message.class ));
	List<Message> messages = ma.removeAwaitingMessages( app.getMySqlVm());
	Assert.assertEquals( 1, messages.size());
	Assert.assertEquals( msg, messages.iterator().next());
}