in src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverWithVanityBloomFilterTest.java [1229:1285]
public void testResolveResourceAliasJcrContent() throws Exception {
// define an alias for the rootPath in the jcr:content child node
String alias = "testAlias";
Node content = rootNode.addNode("jcr:content", "nt:unstructured");
content.setProperty("sling:alias", alias);
try {
saveMappings(session);
String path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html");
HttpServletRequest request = new FakeSlingHttpServletRequest(path);
Resource res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
assertEquals(".print.html", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html/suffix.pdf");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
assertEquals(rootNode.getPrimaryNodeType().getName(), res.getResourceType());
assertEquals(".print.html/suffix.pdf", res.getResourceMetadata().getResolutionPathInfo());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + "/" + alias + ".print.html");
res = resResolver.resolve(request, path);
assertEquals(
"GET request resolution does not go up the path",
Resource.RESOURCE_TYPE_NON_EXISTING,
res.getResourceType());
Node child = rootNode.addNode("child", "nt:unstructured");
child.setProperty("sling:alias", alias);
try {
saveMappings(session);
res = resResolver.resolve(request, path);
assertEquals(child.getPath(), res.getPath());
} finally {
child.remove();
session.save();
}
} finally {
content.remove();
session.save();
}
}