@Test public void testExecute_valid_withSpecifiedInstance_deployed() throws Exception { this.cmd.applicationName = this.app.getName(); this.cmd.scopedInstancePath = InstanceHelpers.computeInstancePath( this.app.getTomcatVm()); this.app.getTomcatVm().setStatus( InstanceStatus.DEPLOYED_STARTED ); ByteArrayOutputStream os = new ByteArrayOutputStream(); this.cmd.out = new PrintStream( os, true, "UTF-8" ); this.cmd.execute(); Mockito.verify( this.applicationMngr, Mockito.times( 1 )).findManagedApplicationByName( this.cmd.applicationName ); Mockito.verify( this.debugMngr, Mockito.times( 1 )).pingMessageQueue( Mockito.anyString()); Mockito.verify( this.debugMngr, Mockito.times( 1 )).pingAgent( Mockito.eq( this.ma ), Mockito.eq( this.app.getTomcatVm()), Mockito.anyString()); String s = os.toString( "UTF-8" ).trim(); Assert.assertTrue( s.startsWith( "Pinging the DM..." )); Assert.assertTrue( s.contains( "Pinging agent" )); Assert.assertFalse( s.contains( "null" )); Assert.assertTrue( s.contains( "[ FAILURE ]" )); Assert.assertFalse( s.contains( "[ SUCCESS ]" )); }
@Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); if( ! info.getScopedInstances().isEmpty()) { DiagnosticListener listener = new DiagnosticListener( this.uuidToFound ); try { this.manager.listenerAppears( listener ); this.out.println( "Pinging the DM..." ); String uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "The DM" ); this.manager.debugMngr().pingMessageQueue( uuid ); for( Instance inst : info.getScopedInstances()) { String path = InstanceHelpers.computeInstancePath( inst ); if( inst.getStatus() != InstanceStatus.DEPLOYED_STARTED ) { this.out.println( "Skipping agent " + path + " as it is not deployed and started." ); continue; } this.out.println( "Pinging agent " + path ); uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "Agent " + path ); this.manager.debugMngr().pingAgent( info.getManagedApplication(), inst, uuid ); } this.out.println( "" ); this.out.println( "Waiting few seconds to get PING results..." ); this.out.println( "" ); Thread.sleep( this.waitingDelay * 1000 ); } finally { this.manager.listenerDisappears( listener ); listener = null; this.out.println( "" ); this.out.print( "The " + this.waitingDelay + " second" ); if( this.waitingDelay > 1 ) this.out.print( "s" ); this.out.print( " delay elapsed." ); this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b != null && b ) this.out.println( "[ SUCCESS ] " + entry.getValue() + " responded to the ping." ); } this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b == null || ! b ) this.out.println( "[ FAILURE ] " + entry.getValue() + " did not respond to the ping." ); } } } return null; }
DiagnosticMessagingCommand implements Action { @Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); if( ! info.getScopedInstances().isEmpty()) { DiagnosticListener listener = new DiagnosticListener( this.uuidToFound ); try { this.manager.listenerAppears( listener ); this.out.println( "Pinging the DM..." ); String uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "The DM" ); this.manager.debugMngr().pingMessageQueue( uuid ); for( Instance inst : info.getScopedInstances()) { String path = InstanceHelpers.computeInstancePath( inst ); if( inst.getStatus() != InstanceStatus.DEPLOYED_STARTED ) { this.out.println( "Skipping agent " + path + " as it is not deployed and started." ); continue; } this.out.println( "Pinging agent " + path ); uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "Agent " + path ); this.manager.debugMngr().pingAgent( info.getManagedApplication(), inst, uuid ); } this.out.println( "" ); this.out.println( "Waiting few seconds to get PING results..." ); this.out.println( "" ); Thread.sleep( this.waitingDelay * 1000 ); } finally { this.manager.listenerDisappears( listener ); listener = null; this.out.println( "" ); this.out.print( "The " + this.waitingDelay + " second" ); if( this.waitingDelay > 1 ) this.out.print( "s" ); this.out.print( " delay elapsed." ); this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b != null && b ) this.out.println( "[ SUCCESS ] " + entry.getValue() + " responded to the ping." ); } this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b == null || ! b ) this.out.println( "[ FAILURE ] " + entry.getValue() + " did not respond to the ping." ); } } } return null; } }
DiagnosticMessagingCommand implements Action { @Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); if( ! info.getScopedInstances().isEmpty()) { DiagnosticListener listener = new DiagnosticListener( this.uuidToFound ); try { this.manager.listenerAppears( listener ); this.out.println( "Pinging the DM..." ); String uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "The DM" ); this.manager.debugMngr().pingMessageQueue( uuid ); for( Instance inst : info.getScopedInstances()) { String path = InstanceHelpers.computeInstancePath( inst ); if( inst.getStatus() != InstanceStatus.DEPLOYED_STARTED ) { this.out.println( "Skipping agent " + path + " as it is not deployed and started." ); continue; } this.out.println( "Pinging agent " + path ); uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "Agent " + path ); this.manager.debugMngr().pingAgent( info.getManagedApplication(), inst, uuid ); } this.out.println( "" ); this.out.println( "Waiting few seconds to get PING results..." ); this.out.println( "" ); Thread.sleep( this.waitingDelay * 1000 ); } finally { this.manager.listenerDisappears( listener ); listener = null; this.out.println( "" ); this.out.print( "The " + this.waitingDelay + " second" ); if( this.waitingDelay > 1 ) this.out.print( "s" ); this.out.print( " delay elapsed." ); this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b != null && b ) this.out.println( "[ SUCCESS ] " + entry.getValue() + " responded to the ping." ); } this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b == null || ! b ) this.out.println( "[ FAILURE ] " + entry.getValue() + " did not respond to the ping." ); } } } return null; }  }
DiagnosticMessagingCommand implements Action { @Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); if( ! info.getScopedInstances().isEmpty()) { DiagnosticListener listener = new DiagnosticListener( this.uuidToFound ); try { this.manager.listenerAppears( listener ); this.out.println( "Pinging the DM..." ); String uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "The DM" ); this.manager.debugMngr().pingMessageQueue( uuid ); for( Instance inst : info.getScopedInstances()) { String path = InstanceHelpers.computeInstancePath( inst ); if( inst.getStatus() != InstanceStatus.DEPLOYED_STARTED ) { this.out.println( "Skipping agent " + path + " as it is not deployed and started." ); continue; } this.out.println( "Pinging agent " + path ); uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "Agent " + path ); this.manager.debugMngr().pingAgent( info.getManagedApplication(), inst, uuid ); } this.out.println( "" ); this.out.println( "Waiting few seconds to get PING results..." ); this.out.println( "" ); Thread.sleep( this.waitingDelay * 1000 ); } finally { this.manager.listenerDisappears( listener ); listener = null; this.out.println( "" ); this.out.print( "The " + this.waitingDelay + " second" ); if( this.waitingDelay > 1 ) this.out.print( "s" ); this.out.print( " delay elapsed." ); this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b != null && b ) this.out.println( "[ SUCCESS ] " + entry.getValue() + " responded to the ping." ); } this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b == null || ! b ) this.out.println( "[ FAILURE ] " + entry.getValue() + " did not respond to the ping." ); } } } return null; }  @Override Object execute(); }
DiagnosticMessagingCommand implements Action { @Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); if( ! info.getScopedInstances().isEmpty()) { DiagnosticListener listener = new DiagnosticListener( this.uuidToFound ); try { this.manager.listenerAppears( listener ); this.out.println( "Pinging the DM..." ); String uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "The DM" ); this.manager.debugMngr().pingMessageQueue( uuid ); for( Instance inst : info.getScopedInstances()) { String path = InstanceHelpers.computeInstancePath( inst ); if( inst.getStatus() != InstanceStatus.DEPLOYED_STARTED ) { this.out.println( "Skipping agent " + path + " as it is not deployed and started." ); continue; } this.out.println( "Pinging agent " + path ); uuid = UUID.randomUUID().toString(); this.uuidToTarget.put( uuid, "Agent " + path ); this.manager.debugMngr().pingAgent( info.getManagedApplication(), inst, uuid ); } this.out.println( "" ); this.out.println( "Waiting few seconds to get PING results..." ); this.out.println( "" ); Thread.sleep( this.waitingDelay * 1000 ); } finally { this.manager.listenerDisappears( listener ); listener = null; this.out.println( "" ); this.out.print( "The " + this.waitingDelay + " second" ); if( this.waitingDelay > 1 ) this.out.print( "s" ); this.out.print( " delay elapsed." ); this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b != null && b ) this.out.println( "[ SUCCESS ] " + entry.getValue() + " responded to the ping." ); } this.out.println( "" ); for( Map.Entry<String,String> entry : this.uuidToTarget.entrySet()) { Boolean b = this.uuidToFound.get( entry.getKey()); if( b == null || ! b ) this.out.println( "[ FAILURE ] " + entry.getValue() + " did not respond to the ping." ); } } } return null; }  @Override Object execute();  }