Selection of methods exposed from the Sling and OSGi contexts.
Type Params | Return Type | Name and description |
---|---|---|
|
void |
addModelsForClasses(String... classNames) Scan classpath for given class names and register all classes with @Model annotation. |
|
void |
addModelsForClasses(Class... classes) Scan classpath for given classes and register all classes with @Model annotation. |
|
void |
addModelsForPackage(String packageName) Scan classpaths for given package name (and sub packages) and register all classes with @Model
annotation. |
|
void |
addModelsForPackage(String... packageNames) Scan classpath for given package names (and sub packages) and register all classes with @Model
annotation. |
|
BundleContext |
getBundleContext() Get the mock OSGi bundle context. |
|
ResourceResolver |
getResourceResolver() Get the Sling resource resolver for the current Sling context. |
<ServiceType> |
ServiceType |
getService(Class<ServiceType> serviceType) Lookup a single service. |
<ServiceType> |
ServiceType[] |
getServices(Class<ServiceType> serviceType, String filter) Lookup one or several services. |
|
void |
registerAdapter(Class adaptableType, Class adapterType, Closure closure) Register an adapter for the current Prosper context. |
|
void |
registerAdapterFactory(AdapterFactory adapterFactory) Register an adapter factory for the current Prosper context. |
|
void |
registerAdapterFactory(AdapterFactory adapterFactory, String[] adaptableClasses, String[] adapterClasses) Register an adapter factory for the current Prosper context. |
<T> |
T |
registerInjectActivateService(T service) Injects dependencies, activates and registers a service in the mocked OSGi environment. |
<T> |
T |
registerInjectActivateService(T service, Map<String, Object> properties) Injects dependencies, activates and registers a service in the mocked OSGi environment. |
|
void |
registerInjector(Injector injector, Integer serviceRanking) Register a Sling Injector for use in a test. |
|
void |
registerRequestAdapter(Class adapterType, Closure closure) Convenience method to register an adapter for SlingHttpServletRequest instances. |
|
void |
registerResourceAdapter(Class adapterType, Closure closure) Convenience method to register an adapter for Resource instances. |
|
void |
registerResourceResolverAdapter(Class adapterType, Closure closure) Convenience method to register an adapter for ResourceResolver instances. |
<T> |
T |
registerService(T service) Registers a service in the mocked OSGi environment. |
<T> |
T |
registerService(Class<T> serviceClass, T service) Registers a service in the mocked OSGi environment. |
<T> |
T |
registerService(Class<T> serviceClass, T service, Map<String, Object> properties) Registers a service in the mocked OSGi environment. |
|
void |
runMode(String... runModes) Set current run mode(s). |
Scan classpath for given class names and register all classes with @Model
annotation.
classNames
- class names Scan classpath for given classes and register all classes with @Model
annotation.
classes
- classes Scan classpaths for given package name (and sub packages) and register all classes with @Model
annotation.
packageName
- package name Scan classpath for given package names (and sub packages) and register all classes with @Model
annotation.
packageNames
- package namesGet the mock OSGi bundle context.
Get the Sling resource resolver for the current Sling context.
Lookup a single service.
serviceType
- the type (interface) of the service.Lookup one or several services.
serviceType
- the type (interface) of the service.filter
- an optional filter (LDAP-like, see OSGi spec)Register an adapter for the current Prosper context.
adaptableType
- type to adapt fromadapterType
- type returned by the closure functionclosure
- closure accepting an instance of the adaptable type as an argument and returning an instance of
the adapter typeRegister an adapter factory for the current Prosper context. Use this method only if the adapter factory has an OSGi metadata XML file in the classpath at /OSGI-INF containing the adaptable and adapter classes. Otherwise, use the other permutation of this method to explicitly specify the required metadata values.
adapterFactory
- adapter factory instanceRegister an adapter factory for the current Prosper context.
adapterFactory
- adapter factory instanceadaptableClasses
- array of class names that can be adapted from by this factoryadapterClasses
- array of class names that can be adapted to by this factoryInjects dependencies, activates and registers a service in the mocked OSGi environment.
service
- service instanceInjects dependencies, activates and registers a service in the mocked OSGi environment.
service
- service instanceproperties
- service properties (optional)Register a Sling Injector for use in a test.
injector
- injector to registerserviceRanking
- OSGi service ranking Convenience method to register an adapter for SlingHttpServletRequest
instances.
adapterType
- type returned by the closure functionclosure
- closure accepting a single SlingHttpServletRequest
instance as an argument Convenience method to register an adapter for Resource
instances.
adapterType
- type returned by the closure functionclosure
- closure accepting a single Resource
instance as an argument Convenience method to register an adapter for ResourceResolver
instances.
adapterType
- type returned by the closure functionclosure
- closure accepting a single ResourceResolver
instance as an argumentRegisters a service in the mocked OSGi environment.
service
- service instanceRegisters a service in the mocked OSGi environment.
serviceClass
- service classservice
- service instanceRegisters a service in the mocked OSGi environment.
serviceClass
- service classservice
- service instanceproperties
- service properties (optional)Set current run mode(s).
runModes
- run mode(s)