Rework the internal requests API, an actual Resource is required for direct servlet requests
diff --git a/README.md b/README.md
index ed58c22..5b02188 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
## InternalRequest helpers
-The `InternalRequest` class uses either a `SlingRequestProcessor` to execute internal requests using
+The internal request helpers use either a `SlingRequestProcessor` to execute internal requests using
the full Sling request processing pipeline, or a `ServletResolver` to resolve and call a Servlet or Script
directly.
@@ -28,10 +28,9 @@
scripts that are resolved based on the current resource type, for non-HTTP operations. Inventing HTTP method
names for this is fine and allows for reusing this powerful resolution mechanism in other contexts.
-Here's an example using this `InternalRequest` helper - see the test code for more.
+Here's an example using the `SlingInternalRequest` helper - see the test code for more.
- OutputStream os = InternalRequest
- .servletRequest(resourceResolver, servletResolver, "/some/path")
+ OutputStream os = new SlingInternalRequest(resourceResolver, slingRequestProcessor, path)
.withResourceType("website/article/news")
.withResourceSuperType("website/article")
.withSelectors("print", "a4")
diff --git a/src/main/java/org/apache/sling/servlethelpers/internalrequests/InternalRequest.java b/src/main/java/org/apache/sling/servlethelpers/internalrequests/InternalRequest.java
index 26b3516..a4167bc 100644
--- a/src/main/java/org/apache/sling/servlethelpers/internalrequests/InternalRequest.java
+++ b/src/main/java/org/apache/sling/servlethelpers/internalrequests/InternalRequest.java
@@ -31,13 +31,11 @@
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.servlets.ServletResolver;
-import org.apache.sling.engine.SlingRequestProcessor;
import org.apache.sling.servlethelpers.MockRequestPathInfo;
import org.apache.sling.servlethelpers.MockSlingHttpServletRequest;
import org.apache.sling.servlethelpers.MockSlingHttpServletResponse;
-import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -56,17 +54,15 @@
* like content aggregation, generating query schemas dynamically, etc.
*/
public abstract class InternalRequest {
+ protected final ResourceResolver resourceResolver;
protected final String path;
- private String selectorString;
- private String extension;
- private String requestMethod;
- private String resourceType;
- private String resourceSuperType;
- private String contentType;
+ protected String selectorString;
+ protected String extension;
+ protected String requestMethod = DEFAULT_METHOD;
+ protected String contentType;
private Reader bodyReader;
private boolean explicitStatusCheck;
private Map<String, Object> parameters = new HashMap<>();
- private final ResourceResolver resourceResolver;
private MockSlingHttpServletRequest request;
private MockSlingHttpServletResponse response;
@@ -80,58 +76,9 @@
*/
public static final String MDC_KEY = "sling." + InternalRequest.class.getSimpleName();
- /** Clients use the static builder methods to create instances of this class */
protected InternalRequest(ResourceResolver resourceResolver, String path) {
this.resourceResolver = resourceResolver;
this.path = path;
- this.requestMethod = DEFAULT_METHOD;
- }
-
- @Override
- public String toString() {
- return String.format("%s %s", getClass().getSimpleName(), getRequestInfo());
- }
-
- /** Return essential request info, used to set the logging MDC */
- protected String getRequestInfo() {
- return String.format(
- "%s P=%s S=%s EXT=%s RT=%s(%s)",
- requestMethod,
- path,
- selectorString,
- extension,
- resourceType,
- resourceSuperType
- );
- }
-
- /** Start preparing an internal request that uses the "SlingRequest"Processor mode.
- *
- * @param resourceResolver Used for access control
- * @param processor The SlingRequestProcessor to use for processing
- * @param path The path of the request
- * @return a fluent InternalRequest
- */
- @NotNull
- public static InternalRequest slingRequest(
- @NotNull ResourceResolver resourceResolver,
- @NotNull SlingRequestProcessor processor,
- @NotNull String path) {
- return new SlingInternalRequest(resourceResolver, processor, path);
- }
-
- /** Start preparing an internal request that calls the resolved Servlet
- * directly. This bypasses the Servlet Filters used by the default
- * Sling request processing pipeline, which are often not needed
- * for internal requests.
- *
- * @param resourceResolver Used for access control
- * @param servletResolver Resolves the Servlet or Script used to process the internal request
- * @param path The path of the request
- * @return a fluent InternalRequest
- */
- public static InternalRequest servletRequest(ResourceResolver resourceResolver, ServletResolver servletResolver, String path) {
- return new ServletInternalRequest(resourceResolver, servletResolver, path);
}
/** Set the HTTP request method to use - defaults to GET */
@@ -152,20 +99,6 @@
return this;
}
- /** Sets the sling:resourceSuperType of the fake Resource used to resolve
- * the Script or Servlet to use for the internal request */
- public InternalRequest withResourceSuperType(String resourceSuperType) {
- this.resourceSuperType = resourceSuperType;
- return this;
- }
-
- /** Sets the sling:resourceType of the fake Resource used to resolve
- * the Script or Servlet to use for the internal request */
- public InternalRequest withResourceType(String resourceType) {
- this.resourceType = resourceType;
- return this;
- }
-
/** Sets the optional selectors of the internal request, which influence
* the Servlet/Script resolution.
*/
@@ -218,6 +151,7 @@
if(request != null) {
throw new IOException("Request was already executed");
}
+ final Resource resource = getExecutionResource();
request = new MockSlingHttpServletRequest(resourceResolver) {
@Override
protected MockRequestPathInfo newMockRequestPathInfo() {
@@ -239,12 +173,12 @@
};
request.setMethod(requestMethod);
request.setContentType(contentType);
- request.setResource(new MockResource(resourceResolver, path, resourceType, resourceSuperType));
+ request.setResource(resource);
request.setParameterMap(parameters);
response = new MockSlingHttpServletResponse();
- MDC.put(MDC_KEY, getRequestInfo());
+ MDC.put(MDC_KEY, toString());
try {
delegateExecute(request, response, resourceResolver);
} catch(ServletException sx) {
@@ -253,6 +187,10 @@
return this;
}
+ /** Return the Resource to use to execute the request */
+ protected abstract Resource getExecutionResource();
+
+ /** Execute the supplied Request */
protected abstract void delegateExecute(SlingHttpServletRequest request, SlingHttpServletResponse response, ResourceResolver resourceResolver)
throws ServletException, IOException;
diff --git a/src/main/java/org/apache/sling/servlethelpers/internalrequests/ServletInternalRequest.java b/src/main/java/org/apache/sling/servlethelpers/internalrequests/ServletInternalRequest.java
index 1f228d6..27b4804 100644
--- a/src/main/java/org/apache/sling/servlethelpers/internalrequests/ServletInternalRequest.java
+++ b/src/main/java/org/apache/sling/servlethelpers/internalrequests/ServletInternalRequest.java
@@ -26,17 +26,47 @@
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.servlets.ServletResolver;
+import org.jetbrains.annotations.NotNull;
-class ServletInternalRequest extends InternalRequest {
+/** Internal request that calls the resolved Servlet directly.
+ * This bypasses the Servlet Filters used by the default
+ * Sling request processing pipeline, which are often not
+ * needed for internal requests. That's more efficient than
+ * the {@link SlingInternalRequest} but less faithful to the
+ * way Sling processes HTTP requests.
+ */
+public class ServletInternalRequest extends InternalRequest {
protected final ServletResolver servletResolver;
+ private final Resource resource;
- ServletInternalRequest(ResourceResolver resourceResolver, ServletResolver servletResolver, String path) {
- super(resourceResolver, path);
+ public ServletInternalRequest(@NotNull ServletResolver servletResolver, @NotNull Resource resource) {
+ super(resource.getResourceResolver(), resource.getPath());
+ this.resource = resource;
this.servletResolver = servletResolver;
}
+ /** Return essential request info, used to set the logging MDC */
+ public String toString() {
+ return String.format(
+ "%s: %s P=%s S=%s EXT=%s RT=%s(%s)",
+ getClass().getSimpleName(),
+ requestMethod,
+ resource.getPath(),
+ selectorString,
+ extension,
+ resource.getResourceType(),
+ resource.getResourceSuperType()
+ );
+ }
+
+ @Override
+ protected Resource getExecutionResource() {
+ return resource;
+ }
+
@Override
protected void delegateExecute(SlingHttpServletRequest request, SlingHttpServletResponse response, ResourceResolver resourceResolver)
throws ServletException, IOException {
diff --git a/src/main/java/org/apache/sling/servlethelpers/internalrequests/MockResource.java b/src/main/java/org/apache/sling/servlethelpers/internalrequests/ServletResolutionResource.java
similarity index 72%
rename from src/main/java/org/apache/sling/servlethelpers/internalrequests/MockResource.java
rename to src/main/java/org/apache/sling/servlethelpers/internalrequests/ServletResolutionResource.java
index 8d98529..faffb8c 100644
--- a/src/main/java/org/apache/sling/servlethelpers/internalrequests/MockResource.java
+++ b/src/main/java/org/apache/sling/servlethelpers/internalrequests/ServletResolutionResource.java
@@ -24,23 +24,25 @@
import org.apache.sling.api.resource.ResourceMetadata;
import org.apache.sling.api.resource.ResourceResolver;
-/** Minimal Resource implementation for our internal requests */
-class MockResource implements Resource {
+/** Minimal Resource implementation for our internal requests, meant
+ * to be used only to resolve scripts and servlets.
+ */
+class ServletResolutionResource implements Resource {
private final String path;
private final String resourceType;
private final String resourceSuperType;
private final ResourceResolver resourceResolver;
- static class NotNeededException extends UnsupportedOperationException {
+ static class NotImplementedException extends UnsupportedOperationException {
private static final long serialVersionUID = 1L;
- NotNeededException() {
- super("Not implemented - this method should not be needed?");
+ NotImplementedException() {
+ super("Not implemented - this Resource is only meant to resolve Servlets and Scripts");
}
}
- MockResource(ResourceResolver resourceResolver, String path, String resourceType, String resourceSuperType) {
+ ServletResolutionResource(ResourceResolver resourceResolver, String path, String resourceType, String resourceSuperType) {
this.path = path;
this.resourceType = resourceType;
this.resourceSuperType = resourceSuperType;
@@ -49,7 +51,7 @@
@Override
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
- throw new NotNeededException();
+ throw new NotImplementedException();
}
@Override
@@ -59,27 +61,27 @@
@Override
public String getName() {
- throw new NotNeededException();
+ throw new NotImplementedException();
}
@Override
public Resource getParent() {
- throw new NotNeededException();
+ throw new NotImplementedException();
}
@Override
public Iterator<Resource> listChildren() {
- throw new NotNeededException();
+ throw new NotImplementedException();
}
@Override
public Iterable<Resource> getChildren() {
- throw new NotNeededException();
+ throw new NotImplementedException();
}
@Override
public Resource getChild(String relPath) {
- throw new NotNeededException();
+ throw new NotImplementedException();
}
@Override
@@ -94,12 +96,12 @@
@Override
public boolean isResourceType(String resourceType) {
- throw new NotNeededException();
+ throw new NotImplementedException();
}
@Override
public ResourceMetadata getResourceMetadata() {
- throw new NotNeededException();
+ throw new NotImplementedException();
}
@Override
diff --git a/src/main/java/org/apache/sling/servlethelpers/internalrequests/SlingInternalRequest.java b/src/main/java/org/apache/sling/servlethelpers/internalrequests/SlingInternalRequest.java
index 0761e95..8b5c434 100644
--- a/src/main/java/org/apache/sling/servlethelpers/internalrequests/SlingInternalRequest.java
+++ b/src/main/java/org/apache/sling/servlethelpers/internalrequests/SlingInternalRequest.java
@@ -24,24 +24,65 @@
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.engine.SlingRequestProcessor;
+import org.jetbrains.annotations.NotNull;
-/** Common interface between the various types of
- * internal requests
+/** Internal request that uses a SlingRequestProcessor.
+ * This executes the complete Sling request processing
+ * pipeline. That's the same processing than Sling uses
+ * for HTTP requests, but it's not as efficient as the
+ * {@link ServletInternalRequest} which resolves and
+ * calls a Servlet or Script directly.
*/
-class SlingInternalRequest extends InternalRequest {
- protected final SlingRequestProcessor processor;
+public class SlingInternalRequest extends InternalRequest {
+ private final SlingRequestProcessor processor;
+ private String resourceType;
+ private String resourceSuperType;
- SlingInternalRequest(ResourceResolver resolver, SlingRequestProcessor p, String path) {
- super(resolver, path);
- processor = p;
+ public SlingInternalRequest(@NotNull ResourceResolver resourceResolver, @NotNull SlingRequestProcessor p, @NotNull String path) {
+ super(resourceResolver, path);
+ this.processor = p;
+ }
+
+ /** Return essential request info, used to set the logging MDC */
+ public String toString() {
+ return String.format(
+ "%s: %s P=%s S=%s EXT=%s RT=%s(%s)",
+ getClass().getSimpleName(),
+ requestMethod,
+ path,
+ selectorString,
+ extension,
+ resourceType,
+ resourceSuperType
+ );
+ }
+
+ /** Sets the sling:resourceSuperType of the fake Resource used to resolve
+ * the Script or Servlet to use for the internal request */
+ public SlingInternalRequest withResourceSuperType(String resourceSuperType) {
+ this.resourceSuperType = resourceSuperType;
+ return this;
+ }
+
+ /** Sets the sling:resourceType of the fake Resource used to resolve
+ * the Script or Servlet to use for the internal request */
+ public SlingInternalRequest withResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ return this;
}
@Override
protected void delegateExecute(SlingHttpServletRequest request, SlingHttpServletResponse response, ResourceResolver resourceResolver)
throws ServletException, IOException {
- log.debug("Executing request using the SlingRequestProcessor");
+ log.debug("Executing request using a SlingRequestProcessor");
processor.processRequest(request, response, resourceResolver);
}
+
+ @Override
+ protected Resource getExecutionResource() {
+ return new ServletResolutionResource(resourceResolver, path, resourceType, resourceSuperType);
+ }
}
diff --git a/src/test/java/org/apache/sling/servlethelpers/internalrequests/MockServletResolver.java b/src/test/java/org/apache/sling/servlethelpers/internalrequests/MockServletResolver.java
index 711ee1f..6b5500c 100644
--- a/src/test/java/org/apache/sling/servlethelpers/internalrequests/MockServletResolver.java
+++ b/src/test/java/org/apache/sling/servlethelpers/internalrequests/MockServletResolver.java
@@ -29,7 +29,7 @@
@Override
public Servlet resolveServlet(SlingHttpServletRequest request) {
- if(request.getResource() != null && "NOSERVLET".equals(request.getResource().getResourceType())) {
+ if(request.getResource() != null && "/NOSERVLET".equals(request.getResource().getPath())) {
return null;
} else {
return new RequestInfoServlet(request);
diff --git a/src/test/java/org/apache/sling/servlethelpers/internalrequests/MockSlingRequestProcessor.java b/src/test/java/org/apache/sling/servlethelpers/internalrequests/MockSlingRequestProcessor.java
index ec49d97..fa2ef1b 100644
--- a/src/test/java/org/apache/sling/servlethelpers/internalrequests/MockSlingRequestProcessor.java
+++ b/src/test/java/org/apache/sling/servlethelpers/internalrequests/MockSlingRequestProcessor.java
@@ -34,7 +34,7 @@
public void processRequest(HttpServletRequest httpRequest, HttpServletResponse response, ResourceResolver resourceResolver)
throws ServletException, IOException {
final SlingHttpServletRequest request = (SlingHttpServletRequest)httpRequest;
- if(request.getResource() != null && "NOSERVLET".equals(request.getResource().getResourceType())) {
+ if(request.getResource() != null && "/NOSERVLET".equals(request.getResource().getPath())) {
response.sendError(404);
} else {
new RequestInfoServlet((SlingHttpServletRequest)request).service(request, response);
diff --git a/src/test/java/org/apache/sling/servlethelpers/internalrequests/RequestInfoServlet.java b/src/test/java/org/apache/sling/servlethelpers/internalrequests/RequestInfoServlet.java
index 10828fa..2db8708 100644
--- a/src/test/java/org/apache/sling/servlethelpers/internalrequests/RequestInfoServlet.java
+++ b/src/test/java/org/apache/sling/servlethelpers/internalrequests/RequestInfoServlet.java
@@ -59,10 +59,10 @@
@Override
public void service(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException,ServletException {
- if(request.getMethod().equals("EXCEPTION")) {
+ if(request.getResource().getPath().equals("/EXCEPTION")) {
throw new IOException("Failing as designed");
}
- if(request.getMethod().equals("SERVLET-EXCEPTION")) {
+ if(request.getResource().getPath().equals("/SERVLET-EXCEPTION")) {
throw new ServletException("Failing as designed");
}
if(request.getMethod().equals("STATUS")) {
diff --git a/src/test/java/org/apache/sling/servlethelpers/internalrequests/ServletInternalRequestTest.java b/src/test/java/org/apache/sling/servlethelpers/internalrequests/ServletInternalRequestTest.java
index 15abcea..7605675 100644
--- a/src/test/java/org/apache/sling/servlethelpers/internalrequests/ServletInternalRequestTest.java
+++ b/src/test/java/org/apache/sling/servlethelpers/internalrequests/ServletInternalRequestTest.java
@@ -37,8 +37,16 @@
public class ServletInternalRequestTest {
protected ResourceResolver resourceResolver;
- protected InternalRequest request(String path) {
- return InternalRequest.servletRequest(resourceResolver, new MockServletResolver(), path);
+ protected final InternalRequest request(String path) {
+ return request(path, null, null);
+ }
+
+
+ protected InternalRequest request(String path, String resourceType, String resourceSuperType) {
+ return new ServletInternalRequest(
+ new MockServletResolver(),
+ new ServletResolutionResource(resourceResolver, path, resourceType, resourceSuperType)
+ );
}
@Before
@@ -60,9 +68,7 @@
params.put("A", "alpha");
params.put("B", "bravo");
- final String content = request("/451")
- .withResourceType("quincy")
- .withResourceSuperType("jones")
+ final String content = request("/451", "quincy", "jones")
.withSelectors("leo", "nardo")
.withExtension("davinci")
.withParameter("K", "willBeOverwritten")
@@ -129,12 +135,12 @@
@Test(expected = IOException.class)
public void servletIOException() throws IOException {
- request("/never").withRequestMethod("EXCEPTION").execute();
+ request("/EXCEPTION").execute();
}
@Test(expected = IOException.class)
public void servletServletException() throws IOException {
- request("/never").withRequestMethod("SERVLET-EXCEPTION").execute();
+ request("/SERVLET-EXCEPTION").execute();
}
@Test
@@ -226,12 +232,12 @@
@Test
public void noServletReturns404() throws IOException {
- request("/noservlet").withResourceType("NOSERVLET").execute().checkStatus(HttpServletResponse.SC_NOT_FOUND);
+ request("/NOSERVLET").execute().checkStatus(HttpServletResponse.SC_NOT_FOUND);
}
@Test
public void checkStatusCodeReturn() throws IOException {
- InternalRequest call = request("/noservlet").withResourceType("NOSERVLET").execute().checkStatus(HttpServletResponse.SC_NOT_FOUND);
+ InternalRequest call = request("/NOSERVLET").execute().checkStatus(HttpServletResponse.SC_NOT_FOUND);
assertEquals("Unexpected Status Code", HttpServletResponse.SC_NOT_FOUND, call.getStatus());
}
diff --git a/src/test/java/org/apache/sling/servlethelpers/internalrequests/ServletResolutionResourceTest.java b/src/test/java/org/apache/sling/servlethelpers/internalrequests/ServletResolutionResourceTest.java
new file mode 100644
index 0000000..92af948
--- /dev/null
+++ b/src/test/java/org/apache/sling/servlethelpers/internalrequests/ServletResolutionResourceTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.servlethelpers.internalrequests;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.UUID;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class ServletResolutionResourceTest {
+ private final String id = UUID.randomUUID().toString();
+ private final String path = "P_" + id;
+ private final String resourceType = "RT_" + id;
+ private final String resourceSuperType = "RST_" + id;
+ private final ResourceResolver resourceResolver = Mockito.mock(ResourceResolver.class);
+ private final ServletResolutionResource r = new ServletResolutionResource(resourceResolver, path, resourceType, resourceSuperType);
+
+ @Test
+ public void testImplementedMethods() {
+ assertEquals(path, r.getPath());
+ assertEquals(resourceType, r.getResourceType());
+ assertEquals(resourceSuperType, r.getResourceSuperType());
+ assertEquals(resourceResolver, r.getResourceResolver());
+ }
+
+ @Test(expected = ServletResolutionResource.NotImplementedException.class)
+ public void testAdaptTo() {
+ r.adaptTo(Object.class);
+ }
+
+ @Test(expected = ServletResolutionResource.NotImplementedException.class)
+ public void testGetName() {
+ r.getName();
+ }
+
+ @Test(expected = ServletResolutionResource.NotImplementedException.class)
+ public void testGetParent() {
+ r.getParent();
+ }
+
+ @Test(expected = ServletResolutionResource.NotImplementedException.class)
+ public void testListChildren() {
+ r.listChildren();
+ }
+
+ @Test(expected = ServletResolutionResource.NotImplementedException.class)
+ public void testGetChildren() {
+ r.getChildren();
+ }
+
+ @Test(expected = ServletResolutionResource.NotImplementedException.class)
+ public void testGetChild() {
+ r.getChild("451");
+ }
+
+ @Test(expected = ServletResolutionResource.NotImplementedException.class)
+ public void testIsResourceType() {
+ r.isResourceType("farenheit");
+ }
+
+ @Test(expected = ServletResolutionResource.NotImplementedException.class)
+ public void testResourceMetadata() {
+ r.getResourceMetadata();
+ }
+
+}
diff --git a/src/test/java/org/apache/sling/servlethelpers/internalrequests/SlingInternalRequestTest.java b/src/test/java/org/apache/sling/servlethelpers/internalrequests/SlingInternalRequestTest.java
index 2de36a7..6bc5caa 100644
--- a/src/test/java/org/apache/sling/servlethelpers/internalrequests/SlingInternalRequestTest.java
+++ b/src/test/java/org/apache/sling/servlethelpers/internalrequests/SlingInternalRequestTest.java
@@ -18,9 +18,26 @@
*/
package org.apache.sling.servlethelpers.internalrequests;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
/** Run the same tests as the ServletInternalRequestTest but in "sling" mode */
public class SlingInternalRequestTest extends ServletInternalRequestTest {
- protected InternalRequest request(String path) {
- return InternalRequest.slingRequest(resourceResolver, new MockSlingRequestProcessor(), path);
+ protected InternalRequest request(String path, String resourceType, String resourceSuperType) {
+ return new SlingInternalRequest(resourceResolver, new MockSlingRequestProcessor(), path)
+ .withResourceType(resourceType)
+ .withResourceSuperType(resourceSuperType)
+ ;
+ }
+
+ @Test
+ public void verifyClassUnderTestNoParams() {
+ assertEquals(SlingInternalRequest.class, request("unused").getClass());
+ }
+
+ @Test
+ public void verifyClassUnderTestWithParams() {
+ assertEquals(SlingInternalRequest.class, request("unused", "with", "resourceType").getClass());
}
}