Package org.apache.sling.junit.rules
Class Service
java.lang.Object
org.apache.sling.junit.rules.Service
- All Implemented Interfaces:
org.junit.rules.TestRule
- Direct Known Subclasses:
OSGiService
Allows a test class to obtain a reference to an OSGi service. This rule embodies the logic to get a bundle context,
obtain a service reference, fetch the reference to the object and perform the proper cleanup after the test has run.
The {#link TeleporterRule} also provides access to OSGi
services for server-side tests, in a more integrated way.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runner.Description description) <T> T
getService
(Class<T> serviceClass) Return the service object.
-
Constructor Details
-
Service
-
-
Method Details
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
getService
Return the service object.- Type Parameters:
T
- The type of the service.- Parameters:
serviceClass
- Use this class to perform a cast before the object is returned.- Returns:
- The service object.
-