HibernateService implements ShutdownListener { public SessionFactory getSessionFactory() { return sessionFactory; } HibernateService(Config conf); SessionFactory getSessionFactory(); @Override void shutdown();  }
@Test public void testCreationOfSessionFactory() { Properties props = getProperties(); Config conf = ConfigFactory.parseProperties(props); hs = new HibernateService(conf); SessionFactory sf = hs.getSessionFactory(); assertNotNull(sf); assertFalse(sf.isClosed()); SessionFactoryOptions sfo = sf.getSessionFactoryOptions(); StandardServiceRegistry ssr = sfo.getServiceRegistry(); ConfigurationService cs = ssr.getService(ConfigurationService.class); assertEquals(props.getProperty("hibernate.connection.driver_class"), cs.getSetting("hibernate.connection.driver_class", StandardConverters.STRING)); assertEquals(props.getProperty("hibernate.connection.url"), cs.getSetting("hibernate.connection.url", StandardConverters.STRING)); assertEquals(props.getProperty("hibernate.dialect"), cs.getSetting("hibernate.dialect", StandardConverters.STRING)); assertEquals(props.getProperty("hibernate.hbm2ddl.auto"), cs.getSetting("hibernate.hbm2ddl.auto", StandardConverters.STRING)); ClassMetadata cm = sf.getClassMetadata(TestObject.class); String[] names = cm.getPropertyNames(); assertEquals(1, names.length); assertEquals("name", names[0]); assertEquals("string", cm.getPropertyType("name").getName()); }