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

Konrad Windszus edited comment on SLING-10937 at 11/25/21, 7:22 PM:
--------------------------------------------------------------------

The real-life example is at 
https://github.com/Adobe-Consulting-Services/acs-aem-commons/pull/2700/files#file-bundle-src-test-java-com-adobe-acs-commons-models-injectors-impl-i18ninjectortest-java-L103.
 It stopped working after upgrading to Sling Mocks 3.1.0+.

This is due to this Mock setup: 
https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/252341bfc815a9d49fb7157ca11a4da01998375b/bundle/src/test/java/com/adobe/acs/commons/models/injectors/impl/I18NInjectorTest.java#L78
 which does no longer match. The equals is used under the hood by Mockito 
(https://javadoc.io/static/org.mockito/mockito-core/4.1.0/org/mockito/Mockito.html#argument_matchers).


was (Author: kwin):
The real-life example is at 
https://github.com/Adobe-Consulting-Services/acs-aem-commons/pull/2700/files#file-bundle-src-test-java-com-adobe-acs-commons-models-injectors-impl-i18ninjectortest-java-L103.
 It stopped working after upgrading to Sling Mocks 3.1.0+.

> Resource in tested Sling Model not equal to Resource it was adapted from
> ------------------------------------------------------------------------
>
>                 Key: SLING-10937
>                 URL: https://issues.apache.org/jira/browse/SLING-10937
>             Project: Sling
>          Issue Type: Bug
>          Components: Testing
>    Affects Versions: Testing Sling Mock 3.1.2
>            Reporter: Konrad Windszus
>            Priority: Major
>             Fix For: Testing Sling Mock 3.1.4
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The resources returned from 
> {{org.apache.sling.testing.mock.sling.RRMockResourceResolverWrapper}} are of 
> type {{ResourceResolverResourceWrapper}} (in case the resource providers are 
> empty).
> When these resources are adapted to a Sling Model, the injected resource is 
> the unwrapped resource which is not equal to the wrapped resource from 
> outside.
> This is due to the fact that {{ResourceResolverResourceWrapper.adaptTo(...)}} 
> is not overwritten but just delegated to the underlying Resource. That makes 
> the Adapter only acting on the unwrapped resource which is not equal to the 
> wrapped one.
> This leads to unexpected behaviour when verifying interactions with mocks 
> taking the resource as argument, as the wrapped resource is never equal to 
> the resource used in the Sling Model given to the mock.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to