in core/src/main/java/org/apache/sling/testing/mock/sling/ThreadsafeMockAdapterManagerWrapper.java [95:108]
public synchronized AdapterManager getAdapterManager() {
if (bundleContext == null) {
BundleContext newBundleContext = MockOsgi.newBundleContext();
log.warn("Create new bundle context for adapter manager because it was null, bundleContext={}", bundleContext);
setBundleContext(newBundleContext);
}
ServiceReference<AdapterManager> serviceReference = bundleContext.getServiceReference(AdapterManager.class);
if (serviceReference != null) {
return bundleContext.getService(serviceReference);
}
else {
throw new RuntimeException("AdapterManager not registered in bundle context.");
}
}