@Test public void testLocalSessionFactoryBeanWithValidProperties() throws Exception { final Set invocations = new HashSet(); LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() { @Override protected SessionFactory newSessionFactory(Configuration config) { assertEquals(UserSuppliedConnectionProvider.class.getName(), config.getProperty(Environment.CONNECTION_PROVIDER)); assertEquals("myValue", config.getProperty("myProperty")); invocations.add("newSessionFactory"); return null; } }; Properties prop = new Properties(); prop.setProperty(Environment.CONNECTION_PROVIDER, UserSuppliedConnectionProvider.class.getName()); prop.setProperty("myProperty", "myValue"); sfb.setHibernateProperties(prop); sfb.afterPropertiesSet(); assertTrue(sfb.getConfiguration() != null); assertTrue(invocations.contains("newSessionFactory")); }