use of javax.servlet.ServletRequest in project sling by apache.
the class ExternalServletContextWrapperTest method testUnwrappingWrappedSlingRequest.
/**
* Unwrapping a wrapped sling request should return the first-level request
* wrapped by the sling request.
*/
@Test
public void testUnwrappingWrappedSlingRequest() {
final HttpServletRequest req = context.mock(HttpServletRequest.class);
context.checking(new Expectations() {
{
allowing(req).getServletPath();
will(returnValue("/"));
allowing(req).getPathInfo();
will(returnValue("/test"));
}
});
final HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(req);
final HttpServletRequestWrapper wrapper2 = new HttpServletRequestWrapper(wrapper);
final SlingHttpServletRequestImpl slingRequest = new SlingHttpServletRequestImpl(null, wrapper2);
final HttpServletRequestWrapper slingWrapper = new HttpServletRequestWrapper(slingRequest);
ServletRequest unwrapped = ExternalServletContextWrapper.RequestDispatcherWrapper.unwrapServletRequest(slingWrapper);
assertEquals(wrapper2, unwrapped);
}
use of javax.servlet.ServletRequest in project sling by apache.
the class ExternalServletContextWrapperTest method testUnwrappingWrappedRequest.
/**
* Unwrapping a wrapper request should return in the request.
*/
@Test
public void testUnwrappingWrappedRequest() {
final ServletRequest req = context.mock(ServletRequest.class);
final ServletRequestWrapper wrapper = new ServletRequestWrapper(req);
ServletRequest unwrapped = ExternalServletContextWrapper.RequestDispatcherWrapper.unwrapServletRequest(wrapper);
assertEquals(req, unwrapped);
}
use of javax.servlet.ServletRequest in project sling by apache.
the class ExternalServletContextWrapperTest method testUnwrappingDoubleWrappedRequest.
@Test
public void testUnwrappingDoubleWrappedRequest() {
final ServletRequest req = context.mock(ServletRequest.class);
final ServletRequestWrapper wrapper = new ServletRequestWrapper(req);
final ServletRequestWrapper wrapper2 = new ServletRequestWrapper(wrapper);
ServletRequest unwrapped = ExternalServletContextWrapper.RequestDispatcherWrapper.unwrapServletRequest(wrapper2);
assertEquals(req, unwrapped);
}
use of javax.servlet.ServletRequest in project sling by apache.
the class ExternalServletContextWrapperTest method testUnwrappingRegularRequest.
/**
* Unwrapping a non-wrapper request should return the request itself.
*/
@Test
public void testUnwrappingRegularRequest() {
final ServletRequest req = context.mock(ServletRequest.class);
ServletRequest unwrapped = ExternalServletContextWrapper.RequestDispatcherWrapper.unwrapServletRequest(req);
assertEquals(req, unwrapped);
}
use of javax.servlet.ServletRequest in project sling by apache.
the class ExternalServletContextWrapperTest method testUnwrappingSlingRequest.
/**
* Unwrapping a sling request should return the first-level request wrapped
* by the sling request.
*/
@Test
public void testUnwrappingSlingRequest() {
final HttpServletRequest req = context.mock(HttpServletRequest.class);
context.checking(new Expectations() {
{
allowing(req).getServletPath();
will(returnValue("/"));
allowing(req).getPathInfo();
will(returnValue("/test"));
}
});
final HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(req);
final HttpServletRequestWrapper wrapper2 = new HttpServletRequestWrapper(wrapper);
final SlingHttpServletRequestImpl slingRequest = new SlingHttpServletRequestImpl(null, wrapper2);
ServletRequest unwrapped = ExternalServletContextWrapper.RequestDispatcherWrapper.unwrapServletRequest(slingRequest);
assertEquals(wrapper2, unwrapped);
}
Aggregations