Class SlingContextBuilder
- java.lang.Object
-
- org.apache.sling.testing.mock.sling.junit.SlingContextBuilder
-
@ProviderType public final class SlingContextBuilder extends Object
Builder class for creatingSlingContextinstances with different sets of parameters.
-
-
Constructor Summary
Constructors Constructor Description SlingContextBuilder()Create builder with default resource resolver type.SlingContextBuilder(@NotNull ResourceResolverType resourceResolverType)Create builder with given resource resolver type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull SlingContextBuilderafterSetUp(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... afterSetUpCallback)@NotNull SlingContextBuilderafterTearDown(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... afterTearDownCallback)@NotNull SlingContextBuilderbeforeSetUp(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... beforeSetUpCallback)@NotNull SlingContextBuilderbeforeTearDown(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... beforeTearDownCallback)@NotNull SlingContextbuild()@NotNull SlingContextBuilderplugin(@NotNull org.apache.sling.testing.mock.osgi.context.ContextPlugin<? extends org.apache.sling.testing.mock.osgi.context.OsgiContextImpl> @NotNull ... plugin)@NotNull SlingContextBuilderregisterSlingModelsFromClassPath(boolean registerSlingModelsFromClassPath)Automatic registering of all Sling Models found in the classpath on startup (active by default).@NotNull SlingContextBuilderresourceResolverFactoryActivatorProps(@NotNull Map<String,Object> props)Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.@NotNull SlingContextBuilderresourceResolverType(@NotNull ResourceResolverType resourceResolverType)
-
-
-
Constructor Detail
-
SlingContextBuilder
public SlingContextBuilder()
Create builder with default resource resolver type.
-
SlingContextBuilder
public SlingContextBuilder(@NotNull @NotNull ResourceResolverType resourceResolverType)Create builder with given resource resolver type.- Parameters:
resourceResolverType- Resource resolver type.
-
-
Method Detail
-
resourceResolverType
@NotNull public @NotNull SlingContextBuilder resourceResolverType(@NotNull @NotNull ResourceResolverType resourceResolverType)
- Parameters:
resourceResolverType- Resource resolver type.- Returns:
- this
-
plugin
@SafeVarargs @NotNull public final @NotNull 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 @NotNull public final @NotNull 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 @NotNull public final @NotNull 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 @NotNull public final @NotNull 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 @NotNull public final @NotNull 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
@NotNull public @NotNull 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
@NotNull public @NotNull SlingContextBuilder registerSlingModelsFromClassPath(boolean registerSlingModelsFromClassPath)
Automatic registering of all Sling Models found in the classpath on startup (active by default).- Parameters:
registerSlingModelsFromClassPath- If set to false Sling Models are not registered automatically from the classpath on startup.- Returns:
- this
-
build
@NotNull public @NotNull SlingContext build()
- Returns:
- Build
SlingContextinstance.
-
-