use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class SlingRequestPathInfoTest method testMerge.
public void testMerge() {
SlingRequestPathInfo p = new SlingRequestPathInfo(new MockResource("/some/path", ".s1.s2.ext"));
assertEquals("s1.s2", p.getSelectorString());
assertEquals("ext", p.getExtension());
// test to replace selectors with a new one
RequestDispatcherOptions o = new RequestDispatcherOptions();
o.setReplaceSelectors("a");
RequestPathInfo result = p.merge(o);
assertEquals("a", result.getSelectorString());
assertEquals("ext", result.getExtension());
// test to replace selector with the empty string
o.setReplaceSelectors("");
result = p.merge(o);
assertEquals(null, result.getSelectorString());
assertEquals("ext", result.getExtension());
// now add a selector
o.setAddSelectors("b");
result = p.merge(o);
assertEquals("b", result.getSelectorString());
assertEquals("ext", result.getExtension());
// replace ext
o.setReplaceSuffix("html");
result = p.merge(o);
assertEquals("b", result.getSelectorString());
assertEquals("html", result.getSuffix());
}
use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class SlingRequestPathInfoTest method testPathOnly.
public void testPathOnly() {
RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/some/path/here", ""));
assertEquals("/some/path/here", p.getResourcePath());
assertNull("Selectors are null", p.getSelectorString());
assertEquals(0, p.getSelectors().length);
assertNull("Extension is null", p.getExtension());
assertNull("Suffix is null", p.getSuffix());
}
use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class SlingRequestPathInfoTest method testAllOptions.
public void testAllOptions() {
RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/some/path", ".print.a4.html/some/suffix"));
assertEquals("/some/path", p.getResourcePath());
assertEquals("print.a4", p.getSelectorString());
assertEquals(2, p.getSelectors().length);
assertEquals("print", p.getSelectors()[0]);
assertEquals("a4", p.getSelectors()[1]);
assertEquals("html", p.getExtension());
assertEquals("/some/suffix", p.getSuffix());
}
use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class SlingRequestPathInfoTest method testTrailingDotDotDot.
public void testTrailingDotDotDot() {
RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/some/path", "..."));
assertEquals("/some/path", p.getResourcePath());
assertNull("Selectors are null", p.getSelectorString());
assertEquals(0, p.getSelectors().length);
assertNull("Extension is null", p.getExtension());
assertNull("Suffix is null", p.getSuffix());
}
use of org.apache.sling.api.request.RequestPathInfo in project sling by apache.
the class SlingRequestPathInfoTest method testTrailingDotDot.
public void testTrailingDotDot() {
RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/some/path", ".."));
assertEquals("/some/path", p.getResourcePath());
assertNull("Selectors are null", p.getSelectorString());
assertEquals(0, p.getSelectors().length);
assertNull("Extension is null", p.getExtension());
assertNull("Suffix is null", p.getSuffix());
}
Aggregations