@Test public void testLogging() throws Exception { final StringHandler logHandler = new StringHandler(); RoboconfReturnListener listener = new RoboconfReturnListener(); Logger logger = TestUtils.getInternalField( listener, "logger", Logger.class ); Assert.assertNotNull( logger ); logger.setUseParentHandlers( false ); logger.addHandler( logHandler ); Message msg = new MsgCmdGatherLogs(); byte[] bytes = SerializationUtils.serializeObject( msg ); logger.setLevel( Level.SEVERE ); listener.handleReturn( 0, "reply", "exchange", "routingKey", null, bytes ); Assert.assertEquals( 0, logHandler.getLogs().length()); logger.setLevel( Level.INFO ); listener.handleReturn( 0, "reply", "exchange", "routingKey", null, bytes ); Assert.assertNotSame( 0, logHandler.getLogs().length()); }
@Override public void handleReturn( int replyCode, String replyText, String exchange, String routingKey, BasicProperties properties, byte[] body ) throws IOException { String messageType = "undetermined"; try { Message msg = SerializationUtils.deserializeObject( body ); messageType = msg.getClass().getName(); } catch( Exception e ) { this.logger.severe( "Failed to deserialize a message object." ); Utils.logException( this.logger, e ); } if( this.logger.isLoggable( Level.WARNING )) { final StringBuilder sb = new StringBuilder(); sb.append("A message sent by a RabbitMQ client was not received by any queue.\n"); sb.append("Message type: " + messageType + '\n'); sb.append("Routing key: " + routingKey + '\n'); sb.append("Reason: " + replyText); this.logger.warning( sb.toString()); } }
RoboconfReturnListener implements ReturnListener { @Override public void handleReturn( int replyCode, String replyText, String exchange, String routingKey, BasicProperties properties, byte[] body ) throws IOException { String messageType = "undetermined"; try { Message msg = SerializationUtils.deserializeObject( body ); messageType = msg.getClass().getName(); } catch( Exception e ) { this.logger.severe( "Failed to deserialize a message object." ); Utils.logException( this.logger, e ); } if( this.logger.isLoggable( Level.WARNING )) { final StringBuilder sb = new StringBuilder(); sb.append("A message sent by a RabbitMQ client was not received by any queue.\n"); sb.append("Message type: " + messageType + '\n'); sb.append("Routing key: " + routingKey + '\n'); sb.append("Reason: " + replyText); this.logger.warning( sb.toString()); } } }
RoboconfReturnListener implements ReturnListener { @Override public void handleReturn( int replyCode, String replyText, String exchange, String routingKey, BasicProperties properties, byte[] body ) throws IOException { String messageType = "undetermined"; try { Message msg = SerializationUtils.deserializeObject( body ); messageType = msg.getClass().getName(); } catch( Exception e ) { this.logger.severe( "Failed to deserialize a message object." ); Utils.logException( this.logger, e ); } if( this.logger.isLoggable( Level.WARNING )) { final StringBuilder sb = new StringBuilder(); sb.append("A message sent by a RabbitMQ client was not received by any queue.\n"); sb.append("Message type: " + messageType + '\n'); sb.append("Routing key: " + routingKey + '\n'); sb.append("Reason: " + replyText); this.logger.warning( sb.toString()); } }  }
RoboconfReturnListener implements ReturnListener { @Override public void handleReturn( int replyCode, String replyText, String exchange, String routingKey, BasicProperties properties, byte[] body ) throws IOException { String messageType = "undetermined"; try { Message msg = SerializationUtils.deserializeObject( body ); messageType = msg.getClass().getName(); } catch( Exception e ) { this.logger.severe( "Failed to deserialize a message object." ); Utils.logException( this.logger, e ); } if( this.logger.isLoggable( Level.WARNING )) { final StringBuilder sb = new StringBuilder(); sb.append("A message sent by a RabbitMQ client was not received by any queue.\n"); sb.append("Message type: " + messageType + '\n'); sb.append("Routing key: " + routingKey + '\n'); sb.append("Reason: " + replyText); this.logger.warning( sb.toString()); } }  @Override void handleReturn(
			int replyCode,
			String replyText,
			String exchange,
			String routingKey,
			BasicProperties properties,
			byte[] body ); }
RoboconfReturnListener implements ReturnListener { @Override public void handleReturn( int replyCode, String replyText, String exchange, String routingKey, BasicProperties properties, byte[] body ) throws IOException { String messageType = "undetermined"; try { Message msg = SerializationUtils.deserializeObject( body ); messageType = msg.getClass().getName(); } catch( Exception e ) { this.logger.severe( "Failed to deserialize a message object." ); Utils.logException( this.logger, e ); } if( this.logger.isLoggable( Level.WARNING )) { final StringBuilder sb = new StringBuilder(); sb.append("A message sent by a RabbitMQ client was not received by any queue.\n"); sb.append("Message type: " + messageType + '\n'); sb.append("Routing key: " + routingKey + '\n'); sb.append("Reason: " + replyText); this.logger.warning( sb.toString()); } }  @Override void handleReturn(
			int replyCode,
			String replyText,
			String exchange,
			String routingKey,
			BasicProperties properties,
			byte[] body );  }