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

# Class MockSling

java.lang.Object
org.apache.sling.testing.mock.sling.MockSling

public final class MockSling extends Object
Factory for mock Sling objects.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final @NotNull ResourceResolverType`
`DEFAULT_RESOURCERESOLVER_TYPE`
Default resource resolver type is `ResourceResolverType.RESOURCERESOLVER_MOCK`.

## Method Summary

Modifier and Type
Method
Description
`static void`
`clearAdapterManagerBundleContext()`
Clear adapter registrations..
`static @NotNull org.apache.sling.api.resource.ResourceResolver`
`newResourceResolver(@NotNull ResourceResolverType type, @NotNull org.osgi.framework.BundleContext bundleContext)`
Creates new sling resource resolver instance.
`static @NotNull org.apache.sling.api.resource.ResourceResolver`
`newResourceResolver(@NotNull org.osgi.framework.BundleContext bundleContext)`
Creates new sling resource resolver instance using `DEFAULT_RESOURCERESOLVER_TYPE`.
`static @NotNull org.apache.sling.api.resource.ResourceResolverFactory`
`newResourceResolverFactory(@NotNull ResourceResolverType type, @NotNull org.osgi.framework.BundleContext bundleContext)`
Creates new sling resource resolver factory instance.
`static @NotNull org.apache.sling.api.resource.ResourceResolverFactory`
`newResourceResolverFactory(@NotNull org.osgi.framework.BundleContext bundleContext)`
Creates new sling resource resolver factory instance.
`static @NotNull org.apache.sling.api.scripting.SlingScriptHelper`
`newSlingScriptHelper(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response, @NotNull org.osgi.framework.BundleContext bundleContext)`
Creates a new sling script helper instance.
`static @NotNull org.apache.sling.api.scripting.SlingScriptHelper`
`newSlingScriptHelper(@NotNull org.osgi.framework.BundleContext bundleContext)`
Creates a new sling script helper instance using `DEFAULT_RESOURCERESOLVER_TYPE` for the resource resolver.
`static void`
`setAdapterManagerBundleContext(@NotNull org.osgi.framework.BundleContext bundleContext)`
Set bundle context for adapter manager.

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

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

## Field Details

### DEFAULT_RESOURCERESOLVER_TYPE

@NotNull public static final @NotNull ResourceResolverType DEFAULT_RESOURCERESOLVER_TYPE
Default resource resolver type is `ResourceResolverType.RESOURCERESOLVER_MOCK`.

## Method Details

### newResourceResolverFactory

@NotNull public static @NotNull org.apache.sling.api.resource.ResourceResolverFactory newResourceResolverFactory(@NotNull @NotNull org.osgi.framework.BundleContext bundleContext)
Creates new sling resource resolver factory instance.

Parameters:
  `bundleContext` - Bundle context
Returns:
  Resource resolver factory instance

### newResourceResolverFactory

@NotNull public static @NotNull org.apache.sling.api.resource.ResourceResolverFactory newResourceResolverFactory(@NotNull @NotNull ResourceResolverType type, @NotNull @NotNull org.osgi.framework.BundleContext bundleContext)
Creates new sling resource resolver factory instance.

Parameters:
  `type` - Type of underlying repository.
  `bundleContext` - Bundle context
Returns:
  Resource resolver factory instance

### newResourceResolver

@NotNull public static @NotNull org.apache.sling.api.resource.ResourceResolver newResourceResolver(@NotNull @NotNull ResourceResolverType type, @NotNull @NotNull org.osgi.framework.BundleContext bundleContext)
Creates new sling resource resolver instance.

Parameters:
  `type` - Type of underlying repository.
  `bundleContext` - Bundle context
Returns:
  Resource resolver instance

### newResourceResolver

@NotNull public static @NotNull org.apache.sling.api.resource.ResourceResolver newResourceResolver(@NotNull @NotNull org.osgi.framework.BundleContext bundleContext)
Creates new sling resource resolver instance using `DEFAULT_RESOURCERESOLVER_TYPE`.

Parameters:
  `bundleContext` - Bundle context
Returns:
  Resource resolver instance

### newSlingScriptHelper

@NotNull public static @NotNull org.apache.sling.api.scripting.SlingScriptHelper newSlingScriptHelper(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response, @NotNull @NotNull org.osgi.framework.BundleContext bundleContext)
Creates a new sling script helper instance.

Parameters:
  `request` - Request
  `response` - Response
  `bundleContext` - Bundle context
Returns:
  Sling script helper instance

### newSlingScriptHelper

@NotNull public static @NotNull org.apache.sling.api.scripting.SlingScriptHelper newSlingScriptHelper(@NotNull @NotNull org.osgi.framework.BundleContext bundleContext)
Creates a new sling script helper instance using `DEFAULT_RESOURCERESOLVER_TYPE` for the resource resolver.

Parameters:
  `bundleContext` - Bundle context
Returns:
  Sling script helper instance

### setAdapterManagerBundleContext

public static void setAdapterManagerBundleContext(@NotNull @NotNull org.osgi.framework.BundleContext bundleContext)
Set bundle context for adapter manager. From this bundle context the adapter factories are detected.

Parameters:
  `bundleContext` - OSGi bundle context

### clearAdapterManagerBundleContext

public static void clearAdapterManagerBundleContext()
Clear adapter registrations..