use of org.apache.sling.commons.testing.osgi.MockServiceReference in project sling by apache.
the class ServletResourceProviderCreateTest method testCreateMethodsAll.
public void testCreateMethodsAll() {
MockServiceReference msr = new MockServiceReference(null);
msr.setProperty(ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES, RES_TYPE);
msr.setProperty(ServletResolverConstants.SLING_SERVLET_METHODS, "*");
ServletResourceProvider srp = factory.create(msr, TEST_SERVLET);
assertNotNull(srp);
String[] paths = srp.getServletPaths();
assertNotNull(paths);
assertEquals(1, paths.length);
Set<String> checkerSet = new HashSet<>();
checkerSet.add(ROOT + RES_TYPE_PATH + ServletResourceProviderFactory.SERVLET_PATH_EXTENSION);
for (String path : paths) {
assertTrue(path + " not expected", checkerSet.remove(path));
}
assertTrue(checkerSet.isEmpty());
}
use of org.apache.sling.commons.testing.osgi.MockServiceReference in project sling by apache.
the class ServletResourceProviderCreateTest method testCreateMethodsSingle.
public void testCreateMethodsSingle() {
MockServiceReference msr = new MockServiceReference(null);
msr.setProperty(ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES, RES_TYPE);
msr.setProperty(ServletResolverConstants.SLING_SERVLET_METHODS, "GET");
ServletResourceProvider srp = factory.create(msr, TEST_SERVLET);
assertNotNull(srp);
String[] paths = srp.getServletPaths();
assertNotNull(paths);
assertEquals(1, paths.length);
Set<String> checkerSet = new HashSet<>();
checkerSet.add(ROOT + RES_TYPE_PATH + "/" + HttpConstants.METHOD_GET + ServletResourceProviderFactory.SERVLET_PATH_EXTENSION);
for (String path : paths) {
assertTrue(path + " not expected", checkerSet.remove(path));
}
assertTrue(checkerSet.isEmpty());
}
use of org.apache.sling.commons.testing.osgi.MockServiceReference in project sling by apache.
the class ServletResourceProviderCreateTest method testCreateMethodsDefault.
public void testCreateMethodsDefault() {
MockServiceReference msr = new MockServiceReference(null);
msr.setProperty(ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES, RES_TYPE);
// msr.setProperty(ServletResolverConstants.SLING_SERVLET_METHODS, "*");
ServletResourceProvider srp = factory.create(msr, TEST_SERVLET);
assertNotNull(srp);
String[] paths = srp.getServletPaths();
assertNotNull(paths);
assertEquals(2, paths.length);
Set<String> checkerSet = new HashSet<>();
checkerSet.add(ROOT + RES_TYPE_PATH + "/" + HttpConstants.METHOD_GET + ServletResourceProviderFactory.SERVLET_PATH_EXTENSION);
checkerSet.add(ROOT + RES_TYPE_PATH + "/" + HttpConstants.METHOD_HEAD + ServletResourceProviderFactory.SERVLET_PATH_EXTENSION);
for (String path : paths) {
assertTrue(path + " not expected", checkerSet.remove(path));
}
assertTrue(checkerSet.isEmpty());
}
Aggregations