@Test public void testGetAddAndRemoveOperationsForTargetConnectionFactories() { ConnectionFactory targetConnectionFactory = Mockito.mock(ConnectionFactory.class); AbstractRoutingConnectionFactory routingFactory = new AbstractRoutingConnectionFactory() { @Override protected Object determineCurrentLookupKey() { return null; } }; //Make sure map is initialized and doesn't contain lookup key "1" assertNull(routingFactory.getTargetConnectionFactory("1")); //Add one and make sure it's there routingFactory.addTargetConnectionFactory("1", targetConnectionFactory); assertEquals(targetConnectionFactory, routingFactory.getTargetConnectionFactory("1")); assertNull(routingFactory.getTargetConnectionFactory("2")); //Remove it and make sure it's gone ConnectionFactory removedConnectionFactory = routingFactory.removeTargetConnectionFactory("1"); assertEquals(targetConnectionFactory, removedConnectionFactory); assertNull(routingFactory.getTargetConnectionFactory("1")); }