Level 1
Level 2
Melden Sie sich an, um alle Badges zu sehen
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
Gelöst! Gehe zu Lösung.
Anhand von Themen werden Community-Inhalte kategorisiert und Sie können so relevanten Inhalt besser finden.
Zugriffe
Antworten
Likes gesamt
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
Zugriffe
Likes
Antworten
Zugriffe
Likes
Antworten