RabbitMqClientFactory implements IMessagingClientFactory { public void reconfigure() { this.logger.fine( "Rabbit MQ clients are about to be reconfigured." ); resetClients( false ); }  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 testFactoryReconfiguration() throws IllegalAccessException { final ReconfigurableClientDm client = new ReconfigurableClientDm(); client.associateMessageProcessor(new AbstractMessageProcessor<IDmClient>("dummy.messageProcessor") { @Override protected void processMessage( final Message message ) { } }); client.setRegistry(this.registry); client.switchMessagingType(FACTORY_RABBITMQ); final RabbitMqClient client1 = RabbitMqTestUtils.getMessagingClient(client); final Map<String,String> config1 = client1.getConfiguration(); Assert.assertEquals(FACTORY_RABBITMQ, config1.get(MessagingConstants.MESSAGING_TYPE_PROPERTY)); Assert.assertEquals("localhost", config1.get(RABBITMQ_SERVER_IP)); Assert.assertEquals("guest", config1.get(RABBITMQ_SERVER_USERNAME)); Assert.assertEquals("guest", config1.get(RABBITMQ_SERVER_PASSWORD)); Assert.assertEquals( 1, this.factory.clients.size()); Map<String,String> configuration = new HashMap<> (); configuration.put( RABBITMQ_SERVER_IP, "127.0.0.1" ); configuration.put( RABBITMQ_SERVER_USERNAME, "john.doe" ); configuration.put( RABBITMQ_SERVER_PASSWORD, "1234" ); this.factory.configuration = configuration; this.factory.reconfigure(); final RabbitMqClient client2 = RabbitMqTestUtils.getMessagingClient(client); Assert.assertNotSame(client1, client2); final Map<String,String> config2 = client2.getConfiguration(); Assert.assertEquals(FACTORY_RABBITMQ, config2.get(MessagingConstants.MESSAGING_TYPE_PROPERTY)); Assert.assertEquals("127.0.0.1", config2.get(RABBITMQ_SERVER_IP)); Assert.assertEquals("john.doe", config2.get(RABBITMQ_SERVER_USERNAME)); Assert.assertEquals("1234", config2.get(RABBITMQ_SERVER_PASSWORD)); Assert.assertEquals( 1, this.factory.clients.size()); }