Incorrect resourcePage provided in mocked model using a wrapped resource from another page

Description

When constructing a sling model from a wrapped resource (i.e. ModelFactory#getModelFromWrappedRequest) if the resource provided is from a different page then the "resourcePage" injected into the model does not match the page of the resource provided.

In fact, the resourcePage that is injected into the newly constructed model is the same that was injected into the calling module. It seems like that value is set once per request and is not re-calculated.

This differs from the documented behaviour where the "resourcePage" is always expected to be the page containing the current resource.

This works in an actual AEM instance, the injected "resourcePage" is actually the page that contains the resource. The result is that tests fail when they would actually work correctly in AEM.

Assignee

Stefan Seifert

Reporter

Kyle Giovannetti

Labels

None

Components

Fix versions

Priority

Major
Configure