List of AEM Mock Context Plugins
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 |
|---|---|---|
Test code extending AEM WCM Core Components |
| |
Test code using Sling Context-Aware Configuration |
| |
Test code using Sling Context-Aware Configuration together with wcm.io Context-Aware Configuration Extensions |
| |
Test code using wcm.io WCM Commons |
| |
Test code using wcm.io AEM Sling Models Extensions |
| |
Test code using wcm.io 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();
}
}