private static void initializeResourceResolverFactoryActivator()

in core/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java [169:190]


    private static void initializeResourceResolverFactoryActivator(@NotNull BundleContext bundleContext) {
        Map<String, Object> config = new HashMap<>();
        // do not required a specific resource provider (otherwise "NONE" will not work)
        config.put("resource.resolver.required.providers", "");
        config.put("resource.resolver.required.providernames", "");
        MockOsgi.registerInjectActivateService(ResourceResolverFactoryActivator.class, bundleContext, config);

        // wait until ResourceResolverFactory appears as service - since SLING-12019 this is done asynchronously
        final long startTime = System.currentTimeMillis();
        while (bundleContext.getServiceReference(ResourceResolverFactory.class) == null) {
            try {
                Thread.sleep(1);
            } catch (InterruptedException ex) {
                Thread.currentThread().interrupt();
            }
            if (System.currentTimeMillis() - startTime > RESOURCERESOLVER_FACTORY_ACTIVATOR_TIMEOUT_MS) {
                throw new IllegalStateException(
                        "ResourceResolverFactoryActivator did not register a ResourceResolverFactory after "
                                + RESOURCERESOLVER_FACTORY_ACTIVATOR_TIMEOUT_MS + "ms.");
            }
        }
    }