Package io.wcm.testing.mock.aem.junit
Class AemContext
java.lang.Object
org.apache.sling.testing.mock.osgi.context.OsgiContextImpl
org.apache.sling.testing.mock.sling.context.SlingContextImpl
io.wcm.testing.mock.aem.context.AemContextImpl
io.wcm.testing.mock.aem.junit.AemContext
- All Implemented Interfaces:
org.junit.rules.TestRule
@ProviderType
public final class AemContext
extends AemContextImpl
implements org.junit.rules.TestRule
JUnit rule for setting up and tearing down AEM context objects for unit tests.
You can use
AemContextBuilder alternatively to the constructors on this class - it offers
more options and fine-grained control about setting up the test context.-
Field Summary
Fields inherited from class org.apache.sling.testing.mock.sling.context.SlingContextImpl
contentBuilder, contentLoader, contentLoaderAutoCommit, request, resourceBuilder, resourceResolver, resourceResolverFactory, resourceResolverType, response, slingScriptHelper, uniqueRootFields inherited from class org.apache.sling.testing.mock.osgi.context.OsgiContextImpl
componentContext -
Constructor Summary
ConstructorsConstructorDescriptionAemContext(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<T> afterSetUpCallback, @NotNull org.apache.sling.testing.mock.sling.ResourceResolverType @NotNull ... resourceResolverTypes) Initialize AEM context.AemContext(@NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<U> afterSetUpCallback, @NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<V> beforeTearDownCallback, @NotNull org.apache.sling.testing.mock.sling.ResourceResolverType @NotNull ... resourceResolverTypes) Initialize AEM context.AemContext(@NotNull org.apache.sling.testing.mock.sling.ResourceResolverType @NotNull ... resourceResolverTypes) Initialize AEM context. -
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) Methods inherited from class io.wcm.testing.mock.aem.context.AemContextImpl
assetManager, contentPolicyMapping, contentPolicyMapping, create, currentPage, currentPage, currentPage, currentResource, graniteAssetManager, newResourceResolverFactory, pageManager, registerDefaultServices, resolveSlingBindingProperty, resourceResolverFactoryActivatorPropsMergeWithAemDefault, setResourceResolverType, setUp, tearDown, uniqueRootMethods inherited from class org.apache.sling.testing.mock.sling.context.SlingContextImpl
addModelsForClasses, addModelsForClasses, addModelsForPackage, addModelsForPackage, build, currentResource, currentResource, load, load, registerAdapter, registerAdapter, request, requestPathInfo, resolveSlingBindingProperty, resourceResolver, resourceResolverType, response, runMode, setRegisterSlingModelsFromClassPath, setResourceResolverFactoryActivatorProps, slingScriptHelperMethods inherited from class org.apache.sling.testing.mock.osgi.context.OsgiContextImpl
bundleContext, componentContext, getService, getServices, registerInjectActivateService, registerInjectActivateService, registerInjectActivateService, registerInjectActivateService, registerInjectActivateService, registerInjectActivateService, registerService, registerService, registerService, registerService
-
Constructor Details
-
AemContext
public AemContext(@NotNull @NotNull org.apache.sling.testing.mock.sling.ResourceResolverType @NotNull ... resourceResolverTypes) Initialize AEM context.If context is initialized with:
- No resource resolver type - default is used
MockSling.DEFAULT_RESOURCERESOLVER_TYPE. - One resource resolver type - exactly this is used.
- More than one: all unit test methods are executed for all resource resolver types using
ListGenerator.
- Parameters:
resourceResolverTypes- Resource resolver type(s).
- No resource resolver type - default is used
-
AemContext
public AemContext(@NotNull @NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<T> afterSetUpCallback, @NotNull @NotNull org.apache.sling.testing.mock.sling.ResourceResolverType @NotNull ... resourceResolverTypes) Initialize AEM context.If context is initialized with:
- No resource resolver type - default is used
MockSling.DEFAULT_RESOURCERESOLVER_TYPE. - One resource resolver type - exactly this is used.
- More than one: all unit test methods are executed for all resource resolver types using
ListGenerator.
- Type Parameters:
T- context type- Parameters:
afterSetUpCallback- Allows the application to register an own callback function that is called after the built-in setup rules are executed.resourceResolverTypes- Resource resolver type(s).
- No resource resolver type - default is used
-
AemContext
public AemContext(@NotNull @NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<U> afterSetUpCallback, @NotNull @NotNull org.apache.sling.testing.mock.osgi.context.ContextCallback<V> beforeTearDownCallback, @NotNull @NotNull org.apache.sling.testing.mock.sling.ResourceResolverType @NotNull ... resourceResolverTypes) Initialize AEM context.If context is initialized with:
- No resource resolver type - default is used
MockSling.DEFAULT_RESOURCERESOLVER_TYPE. - One resource resolver type - exactly this is used.
- More than one: all unit test methods are executed for all resource resolver types using
ListGenerator.
- Type Parameters:
U- context typeV- context type- Parameters:
afterSetUpCallback- Allows the application to register an own callback function that is called after the built-in setup rules are executed.beforeTearDownCallback- Allows the application to register an own callback function that is called before the built-in teardown rules are executed.resourceResolverTypes- Resource resolver type(s).
- No resource resolver type - default is used
-
-
Method Details
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
applyin interfaceorg.junit.rules.TestRule
-