protected void activate()

in src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockSlingRepository.java [67:91]


    protected void activate(BundleContext bundleContext) throws IOException {
        executor = Executors.newSingleThreadExecutor();
        scheduledExecutor = Executors.newSingleThreadScheduledExecutor();

        if (bundleContext.getServiceReference(Executor.class) == null) {
            bundleContext.registerService(Executor.class, executor, null);
        }

        Oak oak = new Oak()
                .with(executor)
                .with(scheduledExecutor);

        Jcr jcr = new Jcr(oak)
                .with(new ExtraSlingContent())
                .with(executor)
                .with(scheduledExecutor);

        this.repository = jcr.createRepository();
        // check if the right Oak version is loaded (older versions may be loaded in case of non-deliberate class loader collisions)
        String expectedVersion = getExpectedVersion();
        String actualVersion = repository.getDescriptor(REP_VERSION_DESC);
        if (new ComparableVersion(expectedVersion).compareTo(new ComparableVersion(actualVersion)) > 0) {
            throw new IllegalStateException("Unexpected (too old) Oak version " + actualVersion + ", expected " + expectedVersion + ". Make sure to load the `org.apache.sling.testing.sling-mock-oak` dependency before any other dependency which may transitively depend on Apache Jackrabbit Oak as well!");
        }
    }