List of Context Plugins
This page lists all AEM Mocks Context Plugins that are available. These plugins hook into the AEM Mocks Lifecyle and register all OSGi services that are required to test the use cases.
Context Plugin | Use Case | Plugin Class |
---|---|---|
Apache Sling Context-Aware Configuration Mock Plugin | Test code using Sling Context-Aware Configuration | org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG |
wcm.io Context-Aware Configuration Mock Helper | Test code using Sling Context-Aware Configuration together with wcm.io Context-Aware Configuration Extensions | io.wcm.testing.mock.wcmio.caconfig.ContextPlugins.WCMIO_CACONFIG |
wcm.io Sling Extensions Mock Helper | Test code using wcm.io AEM Sling Models Extensions | io.wcm.testing.mock.wcmio.sling.ContextPlugins.WCMIO_SLING |
wcm.io Handler Mock Helper | Test code using wcm.io Handler | io.wcm.testing.mock.wcmio.handler.ContextPlugins.WCMIO_HANDLER |
Usage Example
Example of a "AppAemContext" class which can be used in all your unit test classes to create a preconfigured AemContext object with all you need in your project.
import static io.wcm.testing.mock.wcmio.caconfig.ContextPlugins.WCMIO_CACONFIG; import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG; import io.wcm.testing.mock.aem.junit5.AemContext; import io.wcm.testing.mock.aem.junit5.AemContextBuilder; public class AppAemContext { public static AemContext newAemContext() { return new AemContextBuilder() // register plugins .plugin(CACONFIG) .plugin(WCMIO_CACONFIG) // shared context setup code for all tests .<AemContext>afterSetUp(context -> { // add more setup code here }) .build(); } }