@Override
 public void destroy() {
   super.destroy();
   Enumeration<Driver> e = DriverManager.getDrivers();
   while (e.hasMoreElements()) {
     Driver driver = e.nextElement();
     try {
       if (driver.getClass().getClassLoader() == getClass().getClassLoader())
         DriverManager.deregisterDriver(driver);
     } catch (SQLException e1) {
       LOG.logError("Cannot unload driver: " + driver);
     }
   }
   LogFactory.releaseAll();
   LogManager.shutdown();
   // SLF4JLogFactory.releaseAll(); // should be the same as the LogFactory.releaseAll call
   Iterator<Class<?>> i = IIORegistry.getDefaultInstance().getCategories();
   while (i.hasNext()) {
     Class<?> c = i.next();
     Iterator<?> k = IIORegistry.getDefaultInstance().getServiceProviders(c, false);
     while (k.hasNext()) {
       Object o = k.next();
       if (o.getClass().getClassLoader() == getClass().getClassLoader()) {
         IIORegistry.getDefaultInstance().deregisterServiceProvider(o);
         LOG.logDebug("Deregistering JAI driver ", o.getClass());
       }
     }
   }
   Introspector.flushCaches();
   // just clear the configurations for now, it does not hurt
   CRSConfiguration.DEFINED_CONFIGURATIONS.clear();
 }
 /** Tear down instance variables required by this test case. */
 public void tearDown() {
   log = null;
   factory = null;
   LogFactory.releaseAll();
 }
 private InMemoryLog getInMemoryLog() {
   final InMemoryLog log = (InMemoryLog) LogFactory.getLog(CommonsQueryLoggingListener.class);
   LogFactory.releaseAll(); // release the Log cache
   return log;
 }