@Test
public void testSendPingAgent_normal_rootsAreDeployed_messagingError() throws Exception {

	TestApplication app = new TestApplication();
	ManagedApplication ma = new ManagedApplication( app );
	Mockito.verifyZeroInteractions( this.messagingMngr );
	Mockito.doThrow( new IOException( "for test" ) ).when( this.messagingMngr ).sendMessageDirectly(
			Mockito.any( ManagedApplication.class ),
			Mockito.any( Instance.class ),
			Mockito.any( Message.class ));
	// Ping all the root instances.
	for( Instance i : app.getRootInstances()) {
		i.setStatus( InstanceStatus.DEPLOYED_STARTED );
		Assert.assertEquals( 2, this.mngr.pingAgent( ma, i, "TEST " + i.getName()));
	}
	// Now check the DM has tried to send a ping to every agent.
	int inv = app.getRootInstances().size();
	Mockito.verify( this.messagingMngr, Mockito.times( inv )).sendMessageDirectly(
			Mockito.any( ManagedApplication.class ),
			Mockito.any( Instance.class ),
			Mockito.any( Message.class ));
}