HibernateService implements ShutdownListener { @Override public void shutdown() { logger.info("Shutting down the hibernate service"); sessionFactory.close(); } HibernateService(Config conf); SessionFactory getSessionFactory(); @Override void shutdown();  }
@Test public void testShutdown() { Properties props = getProperties(); Config conf = ConfigFactory.parseProperties(props); hs = new HibernateService(conf); SessionFactory sf = hs.getSessionFactory(); hs.shutdown(); assertTrue(sf.isClosed()); }