You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Andrei Dulvac (JIRA)" <ji...@apache.org> on 2019/01/02 10:49:00 UTC

[jira] [Updated] (SLING-6994) [Mocks] Sling JCR Mocks do not resolve vanity resources properly

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

Andrei Dulvac updated SLING-6994:
---------------------------------
    Component/s:     (was: Apache Sling Testing Rules)

> [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
>            Reporter: David Gonzalez
>            Priority: Major
>
> 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}
> /cc [~sseifert@pro-vision.de]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)