Package org.apache.sling.testing.mock.sling.junit5

# Class SlingContext

java.lang.Object
org.apache.sling.testing.mock.osgi.context.OsgiContextImpl
org.apache.sling.testing.mock.sling.context.SlingContextImpl
org.apache.sling.testing.mock.sling.junit5.SlingContext

@ConsumerType public final class SlingContext extends org.apache.sling.testing.mock.sling.context.SlingContextImpl
Sling Mock parameter object with resource resolver type defaulting to `ResourceResolverType.RESOURCERESOLVER_MOCK`.

Additionally you can subclass this class and provide further parameters via `SlingContextBuilder`.

## Field Summary

### Fields inherited from class org.apache.sling.testing.mock.sling.context.SlingContextImpl

`contentBuilder, contentLoader, contentLoaderAutoCommit, jakartaRequest, jakartaResponse, request, resourceBuilder, resourceResolver, resourceResolverFactory, resourceResolverType, response, slingScriptHelper, uniqueRoot`

### Fields inherited from class org.apache.sling.testing.mock.osgi.context.OsgiContextImpl

`componentContext`

## Constructor Summary

Constructors
Constructor
Description
`SlingContext()`
Initialize Sling context.
`SlingContext(@NotNull org.apache.sling.testing.mock.sling.ResourceResolverType resourceResolverType)`
Initialize Sling context.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`setUpContext()`
This is called by `SlingContextExtension` to set up context.
`protected void`
`tearDownContext()`
This is called by `SlingContextExtension` to tear down context.

### Methods inherited from class org.apache.sling.testing.mock.sling.context.SlingContextImpl

`addModelsForClasses, addModelsForClasses, addModelsForPackage, addModelsForPackage, build, create, currentResource, currentResource, currentResource, jakartaRequest, jakartaResponse, load, load, newResourceResolverFactory, registerAdapter, registerAdapter, registerDefaultServices, request, requestPathInfo, resolveSlingBindingProperty, resolveSlingBindingProperty, resolveSlingBindingProperty, resourceResolver, resourceResolverType, response, runMode, setRegisterSlingModelsFromClassPath, setResourceResolverFactoryActivatorProps, setResourceResolverType, setUp, slingScriptHelper, tearDown, uniqueRoot`

### Methods 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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SlingContext

public SlingContext()
Initialize Sling context.

### SlingContext

public SlingContext(@NotNull @NotNull org.apache.sling.testing.mock.sling.ResourceResolverType resourceResolverType)
Initialize Sling context.

Parameters:
  `resourceResolverType` - Resource resolver type.

## Method Details

### setUpContext

protected void setUpContext()
This is called by `SlingContextExtension` to set up context.

### tearDownContext

protected void tearDownContext()
This is called by `SlingContextExtension` to tear down context.