@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 )); for( Instance i : app.getRootInstances()) { i.setStatus( InstanceStatus.DEPLOYED_STARTED ); Assert.assertEquals( 2, this.mngr.pingAgent( ma, i, "TEST " + i.getName())); } 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 )); }
@Override public int pingAgent( ManagedApplication app, Instance scopedInstance, String message ) { int result; MsgEcho ping = new MsgEcho( "PING:" + message ); try { if( scopedInstance.getStatus() != InstanceStatus.NOT_DEPLOYED ) { this.messagingMngr.sendMessageDirectly( app, scopedInstance, ping ); this.logger.fine( "Sent PING request message=" + message + " to application=" + app + ", agent=" + scopedInstance ); result = 0; } else { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". The agent was not started." ); result = 1; } } catch( IOException e ) { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". An error occurred with the messaging." ); Utils.logException( this.logger, e ); result = 2; } return result; }
DebugMngrImpl implements IDebugMngr { @Override public int pingAgent( ManagedApplication app, Instance scopedInstance, String message ) { int result; MsgEcho ping = new MsgEcho( "PING:" + message ); try { if( scopedInstance.getStatus() != InstanceStatus.NOT_DEPLOYED ) { this.messagingMngr.sendMessageDirectly( app, scopedInstance, ping ); this.logger.fine( "Sent PING request message=" + message + " to application=" + app + ", agent=" + scopedInstance ); result = 0; } else { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". The agent was not started." ); result = 1; } } catch( IOException e ) { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". An error occurred with the messaging." ); Utils.logException( this.logger, e ); result = 2; } return result; } }
DebugMngrImpl implements IDebugMngr { @Override public int pingAgent( ManagedApplication app, Instance scopedInstance, String message ) { int result; MsgEcho ping = new MsgEcho( "PING:" + message ); try { if( scopedInstance.getStatus() != InstanceStatus.NOT_DEPLOYED ) { this.messagingMngr.sendMessageDirectly( app, scopedInstance, ping ); this.logger.fine( "Sent PING request message=" + message + " to application=" + app + ", agent=" + scopedInstance ); result = 0; } else { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". The agent was not started." ); result = 1; } } catch( IOException e ) { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". An error occurred with the messaging." ); Utils.logException( this.logger, e ); result = 2; } return result; } DebugMngrImpl( IMessagingMngr messagingMngr, INotificationMngr notificationMngr ); }
DebugMngrImpl implements IDebugMngr { @Override public int pingAgent( ManagedApplication app, Instance scopedInstance, String message ) { int result; MsgEcho ping = new MsgEcho( "PING:" + message ); try { if( scopedInstance.getStatus() != InstanceStatus.NOT_DEPLOYED ) { this.messagingMngr.sendMessageDirectly( app, scopedInstance, ping ); this.logger.fine( "Sent PING request message=" + message + " to application=" + app + ", agent=" + scopedInstance ); result = 0; } else { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". The agent was not started." ); result = 1; } } catch( IOException e ) { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". An error occurred with the messaging." ); Utils.logException( this.logger, e ); result = 2; } return result; } DebugMngrImpl( IMessagingMngr messagingMngr, INotificationMngr notificationMngr ); @Override boolean pingMessageQueue( String message ); @Override int pingAgent( ManagedApplication app, Instance scopedInstance, String message ); @Override void notifyMsgEchoReceived( MsgEcho message ); }
DebugMngrImpl implements IDebugMngr { @Override public int pingAgent( ManagedApplication app, Instance scopedInstance, String message ) { int result; MsgEcho ping = new MsgEcho( "PING:" + message ); try { if( scopedInstance.getStatus() != InstanceStatus.NOT_DEPLOYED ) { this.messagingMngr.sendMessageDirectly( app, scopedInstance, ping ); this.logger.fine( "Sent PING request message=" + message + " to application=" + app + ", agent=" + scopedInstance ); result = 0; } else { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". The agent was not started." ); result = 1; } } catch( IOException e ) { this.logger.fine( "No PING request was sent to application=" + app + ", agent=" + scopedInstance + ". An error occurred with the messaging." ); Utils.logException( this.logger, e ); result = 2; } return result; } DebugMngrImpl( IMessagingMngr messagingMngr, INotificationMngr notificationMngr ); @Override boolean pingMessageQueue( String message ); @Override int pingAgent( ManagedApplication app, Instance scopedInstance, String message ); @Override void notifyMsgEchoReceived( MsgEcho message );  }