@Test
public void testFactoryReconfiguration() throws IllegalAccessException {

	// Create the client DM
	final ReconfigurableClientDm client = new ReconfigurableClientDm();
	client.associateMessageProcessor(new AbstractMessageProcessor<IDmClient>("dummy.messageProcessor") {
		@Override
		protected void processMessage( final Message message ) {
			// nothing
		}
	});
	client.setRegistry(this.registry);
	client.switchMessagingType(FACTORY_RABBITMQ);
	// Check the initial (default) configuration.
	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());
	// Reconfigure the factory.
	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();
	// Check the client has been automatically changed.
	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());
}