### Question:
SpringModelRegistrar { @PreDestroy protected void shutdown() { this.bundlesWithModels.forEach((b, s) -> { try { s.unregister(); } catch (IllegalStateException e) { logger.trace("Cannot unregister the resource model factory service. The service may already have been unregistered.", e); } }); }  void registerModels(BundleContext bundleContext, ConfigurableListableBeanFactory factory); void unregister(Bundle bundle);  }### Answer:
@Test public void testRegistrarUnregistersAllFactoriesWhenRegistrarStops() { withBeanFactory(); withResourceModelsInApplicationContext("bean1", "bean2"); registerResourceModels(); shutdown(); assertRegistrarUnregistersModelFactory(); }