[
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);
// 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.
> 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)