DebugResource implements IDebugResource { @Override public Response checkMessagingConnectionForTheDm( String message ) { this.logger.fine( "Request: check the connection to the message queue. message=" + message ); Response response; String lang = lang( this.manager ); if( this.manager.debugMngr().pingMessageQueue( message )) response = handleError( Status.OK, new RestError( REST_DEBUG_AGENT_KO, name( "ECHO" ), value( message )), lang ).build(); else response = handleError( Status.INTERNAL_SERVER_ERROR, new RestError( REST_MESSAGING_ERROR ), lang ).build(); return response; } DebugResource( Manager manager ); @Override Response checkMessagingConnectionForTheDm( String message ); @Override Response checkMessagingConnectionWithAgent(
			String applicationName,
			String scopedInstancePath,
			String message ); @Override Response diagnoseInstance( String applicationName, String instancePath ); @Override List<Diagnostic> diagnoseApplication( String applicationName );  }
@Test public void testCheckMessagingConnectionForTheDm_success() { Assert.assertEquals( 0, this.msgClient.allSentMessages.size()); UUID uuid = UUID.randomUUID(); Response resp = this.resource.checkMessagingConnectionForTheDm( uuid.toString()); Assert.assertEquals( Status.OK.getStatusCode(), resp.getStatus()); Assert.assertEquals( 1, this.msgClient.allSentMessages.size()); Message msg = this.msgClient.allSentMessages.get( 0 ); Assert.assertEquals( MsgEcho.class, msg.getClass()); Assert.assertEquals( uuid.toString(), ((MsgEcho) msg).getContent()); }
@Test public void testCheckMessagingConnectionForTheDm_ioException() { Assert.assertEquals( 0, this.msgClient.allSentMessages.size()); this.msgClient.failMessageSending.set( true ); Response resp = this.resource.checkMessagingConnectionForTheDm( UUID.randomUUID().toString()); Assert.assertEquals( Status.INTERNAL_SERVER_ERROR.getStatusCode(), resp.getStatus()); Assert.assertEquals( 0, this.msgClient.allSentMessages.size()); }