}
}
protected SlingHttpServletRequest getMockRequest() {
final String resourcePath = "foo";
final MockSlingHttpServletRequest r = new MockSlingHttpServletRequest(resourcePath,null,null,null,null) {
@Override
public String getContextPath() {
return "/CONTEXT";
}
@Override
public String getServletPath() {
return "/SERVLET";
}
};
final String path = "/foo/node";
final MockNode mn = new MockNode(path);
try {
mn.setProperty("title", "test.title");
mn.setProperty("desc", "test.desc");
} catch(RepositoryException ignored) {
// ignore, cannot happen with this mock class
}
final MockResource mr = new MockResource(null, path, null) {
@SuppressWarnings("unchecked")
public <Type> Type adaptTo(Class<Type> type) {
if(type.equals(Node.class)) {
return (Type)mn;
} else {
return null;
}
}
};
r.setResource(mr);
return r;
}