@Test
public void testSetFactory() throws Exception {

	// Set a first factory
	ReconfigurableClientDm client = new ReconfigurableClientDm();
	final MessagingClientFactoryRegistry registry1 = new MessagingClientFactoryRegistry();
	ConcurrentLinkedQueue<?> listeners1 = TestUtils.getInternalField( registry1, "listeners", ConcurrentLinkedQueue.class );
	Assert.assertEquals( 0, listeners1.size());
	Assert.assertNull( TestUtils.getInternalField( client, "registry", MessagingClientFactoryRegistry.class ));
	client.setRegistry( registry1 );
	Assert.assertEquals( 1, listeners1.size());
	Assert.assertEquals( registry1, TestUtils.getInternalField( client, "registry", MessagingClientFactoryRegistry.class ));
	// Change the factory
	final MessagingClientFactoryRegistry registry2 = new MessagingClientFactoryRegistry();
	ConcurrentLinkedQueue<?> listeners2 = TestUtils.getInternalField( registry2, "listeners", ConcurrentLinkedQueue.class );
	Assert.assertEquals( 0, listeners2.size());
	client.setRegistry( registry2 );
	Assert.assertEquals( 0, listeners1.size());
	Assert.assertEquals( 1, listeners2.size());
	Assert.assertEquals( registry2, TestUtils.getInternalField( client, "registry", MessagingClientFactoryRegistry.class ));
}