RabbitMqUtils { public static void closeConnection( Channel channel ) throws IOException { if( channel != null ) { if( channel.isOpen()) channel.close(); if( channel.getConnection().isOpen()) channel.getConnection().close(); } } private  RabbitMqUtils(); static void configureFactory( ConnectionFactory factory, Map<String,String> configuration ); static void closeConnection( Channel channel ); static void declareApplicationExchanges( String domain, String applicationName, Channel channel ); static void declareGlobalExchanges( String domain, Channel channel ); static String buildExchangeNameForAgent( String domain, String applicationName ); static String buildExchangeNameForTheDm( String domain ); static String buildExchangeNameForInterApp( String domain ); static String buildExchangeName( MessagingContext ctx );  }
@Test public void testCloseConnection_withNull() throws Exception { RabbitMqUtils.closeConnection( null ); }
@Test public void testCloseConnection() throws Exception { Assume.assumeTrue( rabbitMqIsRunning ); Channel channel = RabbitMqTestUtils.createTestChannel(); Assert.assertTrue( channel.isOpen()); Assert.assertTrue( channel.getConnection().isOpen()); RabbitMqUtils.closeConnection( channel ); Assert.assertFalse( channel.isOpen()); Assert.assertFalse( channel.getConnection().isOpen()); RabbitMqUtils.closeConnection( channel ); Assert.assertFalse( channel.isOpen()); Assert.assertFalse( channel.getConnection().isOpen()); }