public void testGetServletNamesForJspFileWithMultipleServlets() throws Exception {
  String xml=WEBAPP_TEST_HEADER + "  <servlet>" + "    <servlet-name>s1</servlet-name>"+ "    <jsp-file>/s1.jsp</jsp-file>"+ "  </servlet>"+ "  <servlet>"+ "    <servlet-name>s2</servlet-name>"+ "    <servlet-class>sclass2</servlet-class>"+ "  </servlet>"+ "  <servlet>"+ "    <servlet-name>s3</servlet-name>"+ "    <jsp-file>/s3.jsp</jsp-file>"+ "  </servlet>"+ "</web-app>";
  WebXml webXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(xml.getBytes("UTF-8")),getEntityResolver());
  List<String> servletNames=WebXmlUtils.getServletNamesForJspFile(webXml,"/s3.jsp");
  assertEquals(1,servletNames.size());
  assertEquals("s3",servletNames.get(0));
}

public void testGetServletNamesForJspFileWithMultipleServlets ( ) throws Exception { String xml = WEBAPP_TEST_HEADER + "  <servlet>" + "    <servlet-name>s1</servlet-name>" + "    <jsp-file>/s1.jsp</jsp-file>" + "  </servlet>" + "  <servlet>" + "    <servlet-name>s2</servlet-name>" + "    <servlet-class>sclass2</servlet-class>" + "  </servlet>" + "  <servlet>" + "    <servlet-name>s3</servlet-name>" + "    <jsp-file>/s3.jsp</jsp-file>" + "  </servlet>" + "</web-app>" ; WebXml webXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( xml . getBytes ( "UTF-8" ) ) , getEntityResolver ( ) ) ; List < String > servletNames = WebXmlUtils . getServletNamesForJspFile ( webXml , "/s3.jsp" ) ; assertEquals ( 1 , servletNames . size ( ) ) ; assertEquals ( "s3" , servletNames . get ( 0 ) ) ; }
tests whether a retrieving the servlet names by the path of the jsp file implementing the servlet works correctly for a descriptor with multiple servlet definitions .
