Class SlingContextBuilder
java.lang.Object
org.apache.sling.testing.mock.sling.junit5.SlingContextBuilder
Builder class for creating
SlingContext
instances with different sets
of parameters.-
Constructor Summary
ConstructorsConstructorDescriptionCreate builder with default resource resolver type.SlingContextBuilder
(@NotNull ResourceResolverType resourceResolverType) Create builder with given resource resolver type. -
Method Summary
Modifier and TypeMethodDescriptionfinal SlingContextBuilder
afterSetUp
(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... afterSetUpCallback) final SlingContextBuilder
afterTearDown
(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... afterTearDownCallback) final SlingContextBuilder
beforeSetUp
(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... beforeSetUpCallback) final SlingContextBuilder
beforeTearDown
(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... beforeTearDownCallback) @NotNull SlingContext
build()
final SlingContextBuilder
plugin
(@NotNull org.apache.sling.testing.mock.osgi.context.ContextPlugin<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... plugin) registerSlingModelsFromClassPath
(boolean value) Automatic registering of all Sling Models found in the classpath on startup (active by default).resourceResolverFactoryActivatorProps
(@NotNull Map<String, Object> props) Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.resourceResolverType
(@NotNull ResourceResolverType type)
-
Constructor Details
-
SlingContextBuilder
public SlingContextBuilder()Create builder with default resource resolver type. -
SlingContextBuilder
Create builder with given resource resolver type.- Parameters:
resourceResolverType
- Resource resolver type.
-
-
Method Details
-
resourceResolverType
- Parameters:
type
- Resource resolver type.- Returns:
- this
-
plugin
@SafeVarargs public final SlingContextBuilder plugin(@NotNull @NotNull org.apache.sling.testing.mock.osgi.context.ContextPlugin<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... plugin) - Parameters:
plugin
- Context plugin which listens to context lifecycle events.- Returns:
- this
-
beforeSetUp
@SafeVarargs public final SlingContextBuilder beforeSetUp(@NotNull @NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... beforeSetUpCallback) - Parameters:
beforeSetUpCallback
- Allows the application to register an own callback function that is called before the built-in setup rules are executed.- Returns:
- this
-
afterSetUp
@SafeVarargs public final SlingContextBuilder afterSetUp(@NotNull @NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... afterSetUpCallback) - Parameters:
afterSetUpCallback
- Allows the application to register an own callback function that is called after the built-in setup rules are executed.- Returns:
- this
-
beforeTearDown
@SafeVarargs public final SlingContextBuilder beforeTearDown(@NotNull @NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... beforeTearDownCallback) - Parameters:
beforeTearDownCallback
- Allows the application to register an own callback function that is called before the built-in teardown rules are executed.- Returns:
- this
-
afterTearDown
@SafeVarargs public final SlingContextBuilder afterTearDown(@NotNull @NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... afterTearDownCallback) - Parameters:
afterTearDownCallback
- Allows the application to register an own callback function that is after before the built-in teardown rules are executed.- Returns:
- this
-
resourceResolverFactoryActivatorProps
public SlingContextBuilder resourceResolverFactoryActivatorProps(@NotNull @NotNull Map<String, Object> props) Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.- Parameters:
props
- Configuration properties- Returns:
- this
-
registerSlingModelsFromClassPath
Automatic registering of all Sling Models found in the classpath on startup (active by default).- Parameters:
value
- If set to false Sling Models are not registered automatically from the classpath on startup.- Returns:
- this
-
build
- Returns:
- Build
SlingContext
instance.
-