assertNull(res);
}
@Test public void testResolveResource() throws Exception {
// existing resource
HttpServletRequest request = new FakeSlingHttpServletRequest(rootPath);
Resource res = resResolver.resolve(request, rootPath);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
assertEquals(rootNode.getPrimaryNodeType().getName(),
res.getResourceType());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
// missing resource below root should resolve "missing resource"
String path = rootPath + "/missing";
res = resResolver.resolve(new FakeSlingHttpServletRequest(path), path);
assertNotNull(res);
assertEquals(path, res.getPath());
assertEquals(Resource.RESOURCE_TYPE_NON_EXISTING, res.getResourceType());
assertNull(res.adaptTo(Node.class));
// root with selectors/ext should resolve root
path = rootPath + ".print.a4.html";
res = resResolver.resolve(new FakeSlingHttpServletRequest(path), path);
assertNotNull(res);
assertEquals(rootPath, res.getPath());
assertEquals(rootNode.getPrimaryNodeType().getName(),
res.getResourceType());
assertNotNull(res.adaptTo(Node.class));
assertTrue(rootNode.isSame(res.adaptTo(Node.class)));
// missing resource should return NON_EXISTING Resource
path = rootPath + System.currentTimeMillis();
res = resResolver.resolve(new FakeSlingHttpServletRequest(path), path);
assertNotNull(res);
assertTrue(ResourceUtil.isNonExistingResource(res));
assertEquals(path, res.getPath());
assertEquals(Resource.RESOURCE_TYPE_NON_EXISTING, res.getResourceType());
}