saveMappings(session);
// ---------------------------------------------------------------------
// tests expecting paths without context
final HttpServletRequest virtualRequest = new FakeSlingHttpServletRequest(
null, mapHost, -1, rootPath);
// simple mapping - cut off prefix and add host
final String pathv0 = "/sample";
final String mappedv0 = resResolver.map(virtualRequest, mapRootPath
+ pathv0);
assertEquals("Expect unmangled path", pathv0, mappedv0);
// expected name mangling without host prefix
final String pathv1 = "/sample/jcr:content";
final String mangledv1 = "/sample/_jcr_content";
final String mappedv1 = resResolver.map(virtualRequest, mapRootPath
+ pathv1);
assertEquals("Expect mangled path", mangledv1, mappedv1);
// ---------------------------------------------------------------------
// tests expecting paths with context "/context"
((FakeSlingHttpServletRequest) virtualRequest).setContextPath(contextPath);
// simple mapping - cut off prefix and add host
final String pathvc0 = "/sample";
final String mappedvc0 = resResolver.map(virtualRequest, mapRootPath
+ pathvc0);
assertEquals("Expect unmangled path", contextPath + pathv0, mappedvc0);
// expected name mangling without host prefix
final String pathvc1 = "/sample/jcr:content";
final String mangledvc1 = "/sample/_jcr_content";
final String mappedvc1 = resResolver.map(virtualRequest, mapRootPath
+ pathvc1);
assertEquals("Expect mangled path", contextPath + mangledvc1, mappedvc1);
// ---------------------------------------------------------------------
// tests expecting absolute URLs without context
final HttpServletRequest foreignRequest = new FakeSlingHttpServletRequest(
null, "foreign.host.com", -1, rootPath);
final String pathf0 = "/sample";
final String mappedf0 = resResolver.map(foreignRequest, mapRootPath
+ pathf0);