in src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverWithVanityBloomFilterTest.java [1361:1418]
public void testResolveRemovedesourceAliasJcrContent() 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());
// remove alias property
content.getProperty("sling:alias").remove();
saveMappings(session);
path = ResourceUtil.normalize(ResourceUtil.getParent(rootPath) + "/" + alias + ".print.html");
request = new FakeSlingHttpServletRequest(path);
res = resResolver.resolve(request, path);
assertNotNull(res);
assertTrue(res instanceof NonExistingResource);
assertEquals("/" + alias + ".print.html", res.getPath());
} finally {
content.remove();
session.save();
}
}