RabbitMqClientFactory implements IMessagingClientFactory { public void stop() { resetClients(true); }  void reconfigure(); void stop(); @Override String getType(); @Override IMessagingClient createClient( final ReconfigurableClient<?> parent ); void setConfiguration( Dictionary<?,?> properties ); @Override boolean setConfiguration( final Map<String,String> configuration );  }
@Test public void testStop() throws Exception { Assert.assertEquals( 0, this.factory.clients.size()); this.factory.stop(); testFactoryReconfiguration(); Assert.assertEquals( 1, this.factory.clients.size()); this.factory.stop(); Assert.assertEquals( 0, this.factory.clients.size()); }
@Test @SuppressWarnings({ "rawtypes" }) public void testStop_errorOnClose() throws Exception { ReconfigurableClient parent = Mockito.mock( ReconfigurableClientDm.class ); Mockito.doThrow( new IOException( "For tests..." )).when( parent ).closeConnection(); Map<String,String> configuration = new HashMap<> (); configuration.put( RABBITMQ_SERVER_IP, "" ); configuration.put( RABBITMQ_SERVER_USERNAME, "" ); configuration.put( RABBITMQ_SERVER_PASSWORD, "" ); RabbitMqClient client = new RabbitMqClient( parent, configuration ); this.factory.clients.add( client ); Assert.assertEquals( 1, this.factory.clients.size()); this.factory.stop(); Assert.assertEquals( 0, this.factory.clients.size()); Mockito.verify( parent, Mockito.times( 1 )).closeConnection(); }