Hi,
I want to write a Testcase for my Servlet, which expects a specific selector.
So far I ve always created my MockSlingHttpServletRequest request object using AemContext context.request().
However, I have nt found any method which might allow me to set a selector for it ?
Would be great if you could share an example setting a selector.
thanks a lot for your support in advance.
--
Volker
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
context.requestPathInfo().setSelectorString(DownloadServlet.SELECTOR);
Please check
context.requestPathInfo().setSelectorString(DownloadServlet.SELECTOR);
Please check
Hi @vhochsteinTef ,
To set a selector in a MockSlingHttpServletRequest for your AEM servlet test, you can use the setSelectorString() method. Here's a brief example:
MockSlingHttpServletRequest request = context.request();
request.setSelectorString("myselector");
// Your servlet logic here
servlet.doGet(request, context.response());
// Verify the selector
assertEquals("myselector", request.getRequestPathInfo().getSelectorString());
This will set the selector to "myselector" and you can then use it in your test.
Thanks
Ritesh Mittal
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies