use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-wcm-components by adobe.
the class SearchResultServletTest method testSimpleSearch_badOffset.
/**
* Confirms that the servlet returns 404 status if the result offset is not a long.
*
* @throws Exception any exception.
*/
@Test
public void testSimpleSearch_badOffset() throws Exception {
context.currentResource(TEST_ROOT_EN);
MockSlingHttpServletRequest request = context.request();
request.setQueryString(SearchResultServlet.PARAM_FULLTEXT + "=yod&" + SearchResultServlet.PARAM_RESULTS_OFFSET + "=3x");
MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
requestPathInfo.setSuffix("jcr:content/search");
underTest.doGet(request, context.response());
assertEquals(HttpServletResponse.SC_BAD_REQUEST, context.response().getStatus());
}
use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-wcm-components by adobe.
the class SearchResultServletTest method testTemplateBasedSearch.
@Test
public void testTemplateBasedSearch() throws Exception {
setUpQueryBuilder();
com.adobe.cq.wcm.core.components.Utils.enableDataLayer(context, true);
context.currentResource(TEST_TEMPLATE_EN);
MockSlingHttpServletRequest request = context.request();
request.setQueryString(SearchResultServlet.PARAM_FULLTEXT + "=yod");
MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
requestPathInfo.setSuffix("jcr:content/search");
underTest.doGet(request, context.response());
List<Map<String, String>> expected = ImmutableList.of(ImmutableMap.of("url", CONTEXT_PATH + "/content/en/search/page.html", "title", "Page", "id", "search-ea349504cd-item-2290228025"), ImmutableMap.of("url", CONTEXT_PATH + "/content/en/search/page2.html", "title", "Page2", "id", "search-ea349504cd-item-ad3d190367"), ImmutableMap.of("url", CONTEXT_PATH + "/content/en/search/page-template.html", "title", "Page3", "id", "search-ea349504cd-item-1abc47fffe"), ImmutableMap.of("url", CONTEXT_PATH + "/content/en/search/xf-page.html", "title", "XF Page", "id", "search-ea349504cd-item-2246ed81a7"), ImmutableMap.of("url", CONTEXT_PATH + "/content/en/search/xf-page-template.html", "title", "XF Page Template", "id", "search-ea349504cd-item-7345474d48"), ImmutableMap.of("url", CONTEXT_PATH + "/content/en/search.html", "title", "Search", "id", "search-ea349504cd-item-04a609b18b"));
validateResponse(context.response(), expected);
verify(this.spyResolver, atLeastOnce()).close();
}
use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-wcm-components by adobe.
the class AdaptiveImageServletTest method testImageWithIncorrectLastModifiedSuffix.
@Test
void testImageWithIncorrectLastModifiedSuffix() throws Exception {
Pair<MockSlingHttpServletRequest, MockSlingHttpServletResponse> requestResponsePair = prepareRequestResponsePair(IMAGE19_PATH, "coreimg.800", "png");
MockSlingHttpServletRequest request = requestResponsePair.getLeft();
MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
requestPathInfo.setSuffix("/42.png");
MockSlingHttpServletResponse response = requestResponsePair.getRight();
servlet.doGet(request, response);
Assertions.assertEquals(302, response.getStatus(), "Expected a 302 response code.");
Assertions.assertEquals(CONTEXT_PATH + "/content/test/jcr%3acontent/root/image19.coreimg.800.png/1490005239000.png", response.getHeader("Location"), "Expected redirect location with correct last modified suffix");
}
use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-cif-components by adobe.
the class CategoryPageWithUrlKeyTest method testParseNoSuffix.
@Test
public void testParseNoSuffix() {
MockRequestPathInfo pathInfo = new MockRequestPathInfo();
pathInfo.setResourcePath("/page/path");
CategoryUrlFormat.Params parameters = subject.parse(pathInfo, null);
assertEquals("/page/path", parameters.getPage());
assertNull(parameters.getUrlKey());
}
use of org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo in project aem-core-cif-components by adobe.
the class CategoryPageWithUrlKeyTest method testParse.
@Test
public void testParse() {
MockRequestPathInfo pathInfo = new MockRequestPathInfo();
pathInfo.setResourcePath("/page/path");
pathInfo.setSuffix("/foo-bar.html");
CategoryUrlFormat.Params parameters = subject.parse(pathInfo, null);
assertEquals("/page/path", parameters.getPage());
assertEquals("foo-bar", parameters.getUrlKey());
}
Aggregations