in src/main/java/org/apache/sling/launchpad/webapp/integrationtest/resourceresolver/ResourceResolverGeneralTest.java [1615:1674]
public void testResolveRemovedMixinVanityPath() throws Exception {
Node childNode = null;
try {
// create child now without vanity path first
childNode = maybeCreateNode(rootNode, "rootChild", "nt:unstructured");
session.save();
final String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/childVanity.print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertTrue(ResourceUtil.isNonExistingResource(res));
// now add vanity path without mixin
childNode.setProperty("sling:vanityPath", "childVanity");
saveMappings(session);
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(childNode.getPath(), res.getPath());
// add mixin
childNode.addMixin("sling:VanityPath");
saveMappings(session);
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(childNode.getPath(), res.getPath());
assertEquals(childNode.getPrimaryNodeType().getName(), res.getResourceType());
assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(childNode.isSame(res.adaptTo(Node.class)));
// remove mixin
childNode.removeMixin("sling:VanityPath");
saveMappings(session);
session.refresh(false);
assertTrue(childNode.hasProperty("sling:vanityPath"));
assertEquals(
"childVanity", childNode.getProperty("sling:vanityPath").getString());
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(childNode.getPath(), res.getPath());
} finally {
if (childNode != null) {
childNode.remove();
saveMappings(session);
}
}
}