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

[jira] [Updated] (SLING-11823) Sling Mocks: Allow specifying service ranking (or additional properties) when calling registerAdapter()

     [ https://issues.apache.org/jira/browse/SLING-11823?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henry Kuijpers updated SLING-11823:
-----------------------------------
    Description: 
{code:java}
final Session mockedSession = mock(Session.class);
doThrow(new RepositoryException("Failure")).when(mockedSession).move("/content/test", "/content/test2");
context.registerAdapter(ResourceResolver.class, Session.class, mockedSession);

// Call implementation that uses the ResourceResolver and adapts it to session to call move
underTest.doSomething();
{code}

The consequence of this is that an adapterfactory is registered etc, however, it will not be called, since it has a lower service ranking than existing adapters (in case of JCR/OAK ResourceResolverType). 

It would be nice to be able to specify additional properties, or at least be able to specify the service ranking, so that one of those adapters could be forced to be the first in the list.

  was:
{code:java}
final Session mockedSession = mock(Session.class);
doThrow(new RepositoryException("Failure")).when(mockedSession).move("/content/test", "/content/test2");
context.registerAdapter(ResourceResolver.class, Session.class, mockedSession);
{code}

The consequence of this is that an adapterfactory is registered etc, however, it will not be called, since it has a lower service ranking than existing adapters (in case of JCR/OAK ResourceResolverType). 

It would be nice to be able to specify additional properties, or at least be able to specify the service ranking, so that one of those adapters could be forced to be the first in the list.


> Sling Mocks: Allow specifying service ranking (or additional properties) when calling registerAdapter()
> -------------------------------------------------------------------------------------------------------
>
>                 Key: SLING-11823
>                 URL: https://issues.apache.org/jira/browse/SLING-11823
>             Project: Sling
>          Issue Type: Improvement
>          Components: Testing
>    Affects Versions: Testing Sling Mock 3.4.4
>            Reporter: Henry Kuijpers
>            Priority: Major
>
> {code:java}
> final Session mockedSession = mock(Session.class);
> doThrow(new RepositoryException("Failure")).when(mockedSession).move("/content/test", "/content/test2");
> context.registerAdapter(ResourceResolver.class, Session.class, mockedSession);
> // Call implementation that uses the ResourceResolver and adapts it to session to call move
> underTest.doSomething();
> {code}
> The consequence of this is that an adapterfactory is registered etc, however, it will not be called, since it has a lower service ranking than existing adapters (in case of JCR/OAK ResourceResolverType). 
> It would be nice to be able to specify additional properties, or at least be able to specify the service ranking, so that one of those adapters could be forced to be the first in the list.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)