/** @see org.springframework.orm.hibernate3.LocalSessionFactoryBean#destroy() */
 @Override
 public void destroy() throws HibernateException {
   try {
     super.destroy();
   } catch (IllegalStateException e) {
     // ignore errors sometimes thrown by the CacheManager trying to shut down twice
     // see net.sf.ehcache.CacheManager#removeShutdownHook()
   }
 }
 public void testLocalSessionFactoryBeanWithCustomSessionFactory() throws Exception {
   MockControl factoryControl = MockControl.createControl(SessionFactory.class);
   final SessionFactory sessionFactory = (SessionFactory) factoryControl.getMock();
   sessionFactory.close();
   factoryControl.setVoidCallable(1);
   factoryControl.replay();
   LocalSessionFactoryBean sfb =
       new LocalSessionFactoryBean() {
         protected SessionFactory newSessionFactory(Configuration config) {
           return sessionFactory;
         }
       };
   sfb.setMappingResources(new String[0]);
   sfb.setDataSource(new DriverManagerDataSource());
   sfb.setExposeTransactionAwareSessionFactory(false);
   sfb.afterPropertiesSet();
   assertTrue(sessionFactory == sfb.getObject());
   sfb.destroy();
   factoryControl.verify();
 }