### Question:
RobotsServlet extends SlingSafeMethodsServlet { private void writeFromOsgiConfig(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException { PrintWriter writer = response.getWriter(); PageManager pageManager = pageManagerFactory.getPageManager(request.getResourceResolver()); Page page = pageManager.getContainingPage(request.getResource()); if (page != null) { rules.getGroups().forEach(group -> writeGroup(group, request.getResourceResolver(), page, writer)); rules.getSitemaps().stream().map(sitemap -> buildSitemapDirective(sitemap, request, pageManager, request.getResourceResolver())).forEach(writer::println); if (!rules.getSitemapProperties().isEmpty()) { addRuleForPageHavingBooleanProperty(page, rules.getSitemapProperties(), writer, (currentPage) -> buildSitemapDirective(currentPage.getPath(), request, pageManager, request.getResourceResolver())); } } else { response.sendError(HttpServletResponse.SC_BAD_REQUEST); } }    }### Answer:
@Test public void testWriteFromOsgiConfig() throws ServletException, IOException { Map<String, Object> props = new HashMap<>(); props.put("sling.servlet.resourceTypes", "geometrixx/components/structure/page"); props.put("print.grouping.comments", true); props.put("user.agent.directives", new String[]{ "one:googlebot", "two:bingbot", "two:yahoobot", "three:*" }); props.put("allow.directives", new String[]{ "one:/botsOnly/", "one:/onlyGoogle/", "three:/content/geometrixx/en" }); props.put("disallow.directives", new String[]{ "one:/noGoogle/", "one:/stillNoGoogle/", "two:/content/geometrixx/en/no-bots", }); props.put("sitemap.directives", new String[]{ "https: "/content/geometrixx/en" }); RobotsServlet robotsServlet = context.registerInjectActivateService(new RobotsServlet(), props); robotsServlet.doGet(request, response); assertEquals("servlet returned an error", 200, response.getStatus()); assertResponse(getClass().getResourceAsStream("RobotsServlet_testWriteFromOsgiConfig.txt"), response); }