David Gonzalez created SLING-6994:
-------------------------------------
Summary: [Mocks] Sling JCR Mocks do not resolve vanity resources
properly
Key: SLING-6994
URL: https://issues.apache.org/jira/browse/SLING-6994
Project: Sling
Issue Type: Improvement
Components: Apache Sling Testing Rules
Reporter: David Gonzalez
I would like to use Sling Mocks to test code that relies on sling:vanityPaths.
Sling Mocks resolve vanity pathed resources to sling:nonexisting rather than
sling:redirect (which is the actual behavior) which isn't allowing me to write
tests for my code unless i change my code to match mock behavior and not be
driven by actual behavior/contracts.
{noformat}
@Rule
public SlingContext context = new
SlingContextBuilder(ResourceResolverType.JCR_MOCK)
.resourceResolverFactoryActivatorProps(ImmutableMap.<String,
Object>of(
"resource.resolver.mapping", new String[] {"/:/",
"/content/test/</"}
))
.build();
@Before
public void setUp() throws Exception {
request = new MockSlingHttpServletRequest(context.resourceResolver(),
context.bundleContext());
response = new MockSlingHttpServletResponse();
context.build().resource("/content")
.resource("test")
.resource("vanity", "sling:vanityPath", "/my-vanity");
}
...
@Test
public void dispatch_path1() throws Exception {
request.setServletPath("/content/test/my-vanity");
... calls code that preforms ...
rr.resolve(rr.map("/content/test/my-vanity")).isResourceType("sling:redirect")
// This should return true; however in mocks the resource type is
"sling:nonexisting"
}
}
{noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)