use of org.apache.sling.servlethelpers.MockSlingHttpServletResponse in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class CoreFormHandlingServletTest method testDoPost.
@Test
public void testDoPost() throws Exception {
SlingHttpServletRequest request = new MockSlingHttpServletRequest(context.resourceResolver());
SlingHttpServletResponse response = new MockSlingHttpServletResponse();
servlet.doPost(request, response);
verify(formsHandlingServletHelper).doPost(request, response);
}
use of org.apache.sling.servlethelpers.MockSlingHttpServletResponse in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ElementNamesRenderConditionTest method getRenderCondition.
/**
* Calls the servlet with the specified render conditino resource and returns the resulting render condition.
*/
private RenderCondition getRenderCondition(String name) throws ServletException, IOException {
// get render condition resource
ResourceResolver resolver = context.resourceResolver();
Resource renderCondition = resolver.getResource(RENDERCONDITIONS_PATH + "/" + name);
// mock the request
MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(resolver, context.bundleContext());
request.setResource(renderCondition);
// call the servlet
servlet.doGet(request, new MockSlingHttpServletResponse());
// return the resulting render condition
return (RenderCondition) request.getAttribute(RenderCondition.class.getName());
}
use of org.apache.sling.servlethelpers.MockSlingHttpServletResponse in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class AbstractContentFragmentDataSourceServletTest method getDataSource.
/**
* Calls the servlet with the specified datasource resource and returns the resulting datasource.
*/
DataSource getDataSource(AbstractContentFragmentDataSourceServlet servlet, String name) throws ServletException, IOException {
// get datasource resource
ResourceResolver resolver = context.resourceResolver();
Resource dataSource = resolver.getResource(DATASOURCES_PATH + "/" + name);
// mock the request and request resource
Resource resource = mock(Resource.class);
when(resource.getChild(Config.DATASOURCE)).thenReturn(dataSource);
MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(resolver, context.bundleContext());
request.setResource(resource);
// call the servlet
servlet.doGet(request, new MockSlingHttpServletResponse());
// return the resulting datasource
return (DataSource) request.getAttribute(DataSource.class.getName());
}
Aggregations