Skip to content

Commit

Permalink
adobe#847 Update to latest AEM Mocks version (which includes some imp…
Browse files Browse the repository at this point in the history
…ortant updates from sling-mocks osgi-mock)

include Sling Context-Aware Configuration plugin to test code which uses context-aware configuration
refactor AppAemContext a bit to make it easier to test with different resource resolver types
also update JUnit and Mockito testing dependencies
  • Loading branch information
stefanseifert committed Dec 11, 2021
1 parent 567a55e commit 5e2d483
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/main/archetype/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ Import-Package: javax.annotation;version=0.0.0,*
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.testing.aem-mock-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
package ${package}.core.testcontext;

import static com.adobe.cq.wcm.core.components.testing.mock.ContextPlugins.CORE_COMPONENTS;
import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG;

import org.apache.sling.testing.mock.sling.ResourceResolverType;

import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextBuilder;
Expand All @@ -34,10 +37,24 @@ private AppAemContext() {
* @return {@link AemContext}
*/
public static AemContext newAemContext() {
return newAemContextBuilder().build();
}

/**
* @return {@link AemContextBuilder}
*/
public static AemContextBuilder newAemContextBuilder() {
return newAemContextBuilder(ResourceResolverType.RESOURCERESOLVER_MOCK);
}

/**
* @return {@link AemContextBuilder}
*/
public static AemContextBuilder newAemContextBuilder(ResourceResolverType resourceResolverType) {
return new AemContextBuilder()
.plugin(CACONFIG)
.plugin(CORE_COMPONENTS)
.afterSetUp(SETUP_CALLBACK)
.build();
.afterSetUp(SETUP_CALLBACK);
}

/**
Expand Down
13 changes: 9 additions & 4 deletions src/main/archetype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -909,20 +909,20 @@ Bundle-DocURL:
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.6.2</version>
<version>5.8.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.3.3</version>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.3.3</version>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -934,9 +934,14 @@ Bundle-DocURL:
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<version>4.1.2</version>
<version>4.1.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
<version>1.3.6</version>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.testing.aem-mock-plugin</artifactId>
Expand Down

0 comments on commit 5e2d483

Please sign in to comment.