use of org.apache.sling.engine.impl.SlingHttpServletResponseImpl in project sling by apache.
the class RequestDataTest method setup.
@Before
public void setup() throws Exception {
context = new Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
}
};
req = context.mock(HttpServletRequest.class);
resp = context.mock(HttpServletResponse.class);
final ContentData contentData = context.mock(ContentData.class);
final Servlet servlet = context.mock(Servlet.class);
final ServletConfig servletConfig = context.mock(ServletConfig.class);
context.checking(new Expectations() {
{
allowing(req).getServletPath();
will(returnValue("/"));
allowing(req).getPathInfo();
will(returnValue(""));
allowing(req).getMethod();
will(returnValue("GET"));
allowing(req).setAttribute(with(any(String.class)), with(any(Object.class)));
allowing(req).setAttribute(with(any(String.class)), with(aNull(Object.class)));
allowing(contentData).getServlet();
will(returnValue(servlet));
allowing(servlet).getServletConfig();
will(returnValue(servletConfig));
allowing(servlet).service(with(any(ServletRequest.class)), with(any(ServletResponse.class)));
allowing(servletConfig).getServletName();
will(returnValue("SERVLET_NAME"));
allowing(req).getAttribute(RequestProgressTracker.class.getName());
will(returnValue(null));
}
});
requestData = new RequestData(null, req, resp) {
@Override
public ContentData getContentData() {
return contentData;
}
};
slingRequest = new SlingHttpServletRequestImpl(requestData, req);
slingResponse = new SlingHttpServletResponseImpl(requestData, resp);
RequestData.setMaxCallCounter(2);
}
use of org.apache.sling.engine.impl.SlingHttpServletResponseImpl in project sling by apache.
the class ExternalServletContextWrapperTest method testUnwrappingSlingResponse.
/**
* Unwrapping a sling response should return the first-level response wrapped
* by the sling response.
*/
@Test
public void testUnwrappingSlingResponse() {
final HttpServletResponse resp = context.mock(HttpServletResponse.class);
final HttpServletResponseWrapper wrapper = new HttpServletResponseWrapper(resp);
final HttpServletResponseWrapper wrapper2 = new HttpServletResponseWrapper(wrapper);
final SlingHttpServletResponseImpl slingResponse = new SlingHttpServletResponseImpl(null, wrapper2);
ServletResponse unwrapped = ExternalServletContextWrapper.RequestDispatcherWrapper.unwrapServletResponse(slingResponse);
assertEquals(wrapper2, unwrapped);
}
use of org.apache.sling.engine.impl.SlingHttpServletResponseImpl in project sling by apache.
the class ExternalServletContextWrapperTest method testUnwrappingWrappedSlingResponse.
/**
* Unwrapping a wrapped sling response should return the first-level response
* wrapped by the sling response.
*/
@Test
public void testUnwrappingWrappedSlingResponse() {
final HttpServletResponse resp = context.mock(HttpServletResponse.class);
final HttpServletResponseWrapper wrapper = new HttpServletResponseWrapper(resp);
final HttpServletResponseWrapper wrapper2 = new HttpServletResponseWrapper(wrapper);
final SlingHttpServletResponseImpl slingResponse = new SlingHttpServletResponseImpl(null, wrapper2);
final HttpServletResponseWrapper slingWrapper = new HttpServletResponseWrapper(slingResponse);
ServletResponse unwrapped = ExternalServletContextWrapper.RequestDispatcherWrapper.unwrapServletResponse(slingWrapper);
assertEquals(wrapper2, unwrapped);
}
Aggregations