You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Csaba Varga (Jira)" <ji...@apache.org> on 2021/04/21 11:01:00 UTC

[jira] [Commented] (SLING-10265) JUNIT5 Test cases are failing when I use code "new AemContext(ResourceResolverType.JCR_OAK)"

    [ https://issues.apache.org/jira/browse/SLING-10265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17326436#comment-17326436 ] 

Csaba Varga commented on SLING-10265:
-------------------------------------

I'm not a Sling developer, but I've run into the exact same issue this week. In my case, it was caused by two incompatible sets of Sling API classes being on the classpath. One was included via Sling Mocks, the other was embedded into the AEM SDK API JAR.

I could fix my issue by explicitly including org.apache.sling.api as a dependency before Sling Mocks and specifying a more recent version than what Sling Mocks would have pulled. This more recent version, while still technically a duplicate, played nicely with the classes coming from the AEM SDK.

I hope this helps.

> JUNIT5 Test cases are failing when I use code "new AemContext(ResourceResolverType.JCR_OAK)"
> --------------------------------------------------------------------------------------------
>
>                 Key: SLING-10265
>                 URL: https://issues.apache.org/jira/browse/SLING-10265
>             Project: Sling
>          Issue Type: Bug
>          Components: Apache Sling Testing Clients
>    Affects Versions: Testing Sling Mock 2.6.0
>            Reporter: subramanya
>            Priority: Blocker
>
> I am unable to run test cases using JUNIT5 with JCR_OAK repository implementation in the test case code .
> Repository using JCR_MOCK works, the snippet below works
> private final AemContext aemContext = new AemContext(ResourceResolverType.JCR_MOCK);   
> Where as this one throws exception:
> private final AemContext aemContext = new AemContext(ResourceResolverType.JCR_OAK);   
> This is the error I am getting 
> java.lang.RuntimeException: Unable to initialize JCR_OAK resource resolver factory: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.oak.OakMockSlingRepository Caused by: java.lang.NoSuchMethodError: org.apache.jackrabbit.oak.plugins.nodetype.constraint.Constraints.asPredicate(ILjava/lang/String;)Ljava/util/function/Predicate;  summary JUNIT5 Test cases are failing when I use new AemContext(ResourceResolverType.JCR_OAK)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)