SLING-7803 move junit4-specific files to junit4 module
diff --git a/core/pom.xml b/core/pom.xml
index e8d3e49..4684c68 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -157,7 +157,7 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <scope>compile</scope>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java
new file mode 100644
index 0000000..f6a25b2
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.osgi.junit;
+
+import org.apache.sling.testing.mock.osgi.context.ContextCallback;
+import org.apache.sling.testing.mock.osgi.context.ContextPlugins;
+import org.apache.sling.testing.mock.osgi.context.OsgiContextImpl;
+import org.jetbrains.annotations.NotNull;
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+import org.osgi.annotation.versioning.ProviderType;
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * PLEASE NOTE: this file is copied from osgi-mock.junit4 project to ease the unit tests in the core project.
+ * If you need change it in osgi-mock.junit4, please update it her as well (and vice versa).
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ */
+
+/**
+ * JUnit rule for setting up and tearing down OSGi context for unit tests.
+ */
+@ProviderType
+public final class OsgiContext extends OsgiContextImpl implements TestRule {
+
+    private final ContextPlugins plugins;
+    private final TestRule delegate;
+
+    /**
+     * Initialize OSGi context.
+     */
+    public OsgiContext() {
+        this(new ContextPlugins());
+    }
+
+    /**
+     * Initialize OSGi context.
+     * @param <T> context type
+     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+     */
+    public <T extends OsgiContextImpl> OsgiContext(@NotNull final ContextCallback<T> afterSetUpCallback) {
+        this(new ContextPlugins(afterSetUpCallback));
+    }
+
+    /**
+     * Initialize OSGi context.
+     * @param <U> context type
+     * @param <V> context type
+     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+     * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+     */
+    public <U extends OsgiContextImpl, V extends OsgiContextImpl> OsgiContext(@NotNull final ContextCallback<U> afterSetUpCallback, @NotNull final ContextCallback<V> beforeTearDownCallback) {
+        this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback));
+    }
+
+    /**
+     * Initialize OSGi context with resource resolver type.
+     * @param contextPlugins Context plugins
+     */
+    OsgiContext(@NotNull final ContextPlugins contextPlugins) {
+        this.plugins = contextPlugins;
+
+        // wrap {@link ExternalResource} rule executes each test method once
+        this.delegate = new ExternalResource() {
+            @Override
+            protected void before() {
+                plugins.executeBeforeSetUpCallback(OsgiContext.this);
+                OsgiContext.this.setUp();
+                plugins.executeAfterSetUpCallback(OsgiContext.this);
+            }
+
+            @Override
+            protected void after() {
+                plugins.executeBeforeTearDownCallback(OsgiContext.this);
+                OsgiContext.this.tearDown();
+                plugins.executeAfterTearDownCallback(OsgiContext.this);
+            }
+        };
+    }
+
+    @Override
+    public Statement apply(final Statement base, final Description description) {
+        return this.delegate.apply(base, description);
+    }
+
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
new file mode 100644
index 0000000..ea29c87
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.osgi.junit;
+
+import org.apache.sling.testing.mock.osgi.context.ContextPlugins;
+import org.apache.sling.testing.mock.osgi.context.OsgiContextImpl;
+import org.jetbrains.annotations.NotNull;
+import org.apache.sling.testing.mock.osgi.context.ContextCallback;
+import org.apache.sling.testing.mock.osgi.context.ContextPlugin;
+import org.osgi.annotation.versioning.ProviderType;
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * PLEASE NOTE: this file is copied from osgi-mock.junit4 project to ease the unit tests in the core project.
+ * If you need change it in osgi-mock.junit4, please update it her as well (and vice versa).
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ */
+
+/**
+ * Builder class for creating {@link OsgiContext} instances with different sets of parameters.
+ */
+@ProviderType
+public final class OsgiContextBuilder {
+    
+    private final @NotNull ContextPlugins plugins = new ContextPlugins();
+    
+    /**
+     * Create builder with default resource resolver type.
+     */
+    public OsgiContextBuilder() {}
+    
+    /**
+     * @param <T> context type
+     * @param plugin Context plugin which listens to context lifecycle events.
+     * @return this
+     */
+    @SafeVarargs
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder plugin(@NotNull ContextPlugin<T> @NotNull ... plugin) {
+        plugins.addPlugin(plugin);
+        return this;
+    }
+
+    /**
+     * @param <T> context type
+     * @param beforeSetUpCallback Allows the application to register an own callback function that is called before the built-in setup rules are executed.
+     * @return this
+     */
+    @SafeVarargs
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder beforeSetUp(@NotNull ContextCallback<T> @NotNull ... beforeSetUpCallback) {
+        plugins.addBeforeSetUpCallback(beforeSetUpCallback);
+        return this;
+    }
+
+    /**
+     * @param <T> context type
+     * @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
+     * @return this
+     */
+    @SafeVarargs
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder afterSetUp(@NotNull ContextCallback<T> @NotNull ... afterSetUpCallback) {
+        plugins.addAfterSetUpCallback(afterSetUpCallback);
+        return this;
+    }
+
+    /**
+     * @param <T> context type
+     * @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
+     * @return this
+     */
+    @SafeVarargs
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder beforeTearDown(@NotNull ContextCallback<T> @NotNull ... beforeTearDownCallback) {
+        plugins.addBeforeTearDownCallback(beforeTearDownCallback);
+        return this;
+    }
+
+    /**
+     * @param <T> context type
+     * @param afterTearDownCallback Allows the application to register an own callback function that is after before the built-in teardown rules are executed.
+     * @return this
+     */
+    @SafeVarargs
+    public final @NotNull <T extends OsgiContextImpl> OsgiContextBuilder afterTearDown(@NotNull ContextCallback<T> @NotNull ... afterTearDownCallback) {
+        plugins.addAfterTearDownCallback(afterTearDownCallback);
+        return this;
+    }
+
+    /**
+     * @return Build {@link OsgiContext} instance.
+     */
+    public @NotNull OsgiContext build() {
+        return new OsgiContext(plugins);
+    }
+    
+}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
new file mode 100644
index 0000000..c37a583
--- /dev/null
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.testing.mock.osgi.junit;
+
+import org.apache.sling.testing.mock.osgi.context.ContextCallback;
+import org.osgi.annotation.versioning.ConsumerType;
+
+/*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ * PLEASE NOTE: this file is copied from osgi-mock.junit4 project to ease the unit tests in the core project.
+ * If you need change it in osgi-mock.junit4, please update it her as well (and vice versa).
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ */
+
+/**
+ * Callback interface for application-specific setup and teardown operations to
+ * customize the {@link OsgiContext} JUnit rule.
+ */
+@ConsumerType
+public interface OsgiContextCallback extends ContextCallback<OsgiContext> {
+
+    // specialized version of ContextCallback
+    
+}
diff --git a/junit4/pom.xml b/junit4/pom.xml
index a1cdd83..b7c196c 100644
--- a/junit4/pom.xml
+++ b/junit4/pom.xml
@@ -35,6 +35,61 @@
     <description>Mock implementation of selected OSGi APIs.</description>
 
     <dependencies>
+    
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.annotation.versioning</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.cmpn</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.osgi-mock.core</artifactId>
+            <version>2.4.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.osgi-mock.core</artifactId>
+            <version>2.4.0-SNAPSHOT</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- Nullability annotations -->
+        <dependency>
+            <groupId>org.jetbrains</groupId>
+            <artifactId>annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>2.19.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.logging-mock</artifactId>
+            <version>2.0.0</version>
+            <scope>test</scope>
+        </dependency>
 
     </dependencies>
 
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java b/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java
similarity index 100%
rename from core/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java
rename to junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContext.java
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java b/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
similarity index 100%
rename from core/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
rename to junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java b/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
similarity index 100%
rename from core/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
rename to junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/junit/package-info.java b/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/package-info.java
similarity index 100%
rename from core/src/main/java/org/apache/sling/testing/mock/osgi/junit/package-info.java
rename to junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/package-info.java
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextTest.java b/junit4/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextTest.java
similarity index 100%
rename from core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextTest.java
rename to junit4/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextTest.java
diff --git a/junit5/pom.xml b/junit5/pom.xml
index b60b188..c3e45c8 100644
--- a/junit5/pom.xml
+++ b/junit5/pom.xml
@@ -36,6 +36,50 @@
 
     <dependencies>
 
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.annotation.versioning</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.cmpn</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.osgi-mock.core</artifactId>
+            <version>2.4.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.osgi-mock.core</artifactId>
+            <version>2.4.0-SNAPSHOT</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>2.19.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.logging-mock</artifactId>
+            <version>2.0.0</version>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
     <build>