public void testMergeOneServletIntoDocumentWithSameServletAndParam() throws Exception {
  String srcXml="<web-app>" + "  <servlet>" + "    <servlet-name>s1</servlet-name>"+ "    <servlet-class>sclass1</servlet-class>"+ "  </servlet>"+ "</web-app>";
  WebXml srcWebXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(srcXml.getBytes("UTF-8")),null);
  String mergeXml="<web-app>" + "  <servlet>" + "    <servlet-name>s1</servlet-name>"+ "    <servlet-class>sclass1</servlet-class>"+ "    <init-param>"+ "      <param-name>s1param1</param-name>"+ "      <param-value>s1param1value</param-value>"+ "    </init-param>"+ "  </servlet>"+ "</web-app>";
  WebXml mergeWebXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(mergeXml.getBytes("UTF-8")),null);
  WebXmlMerger merger=new WebXmlMerger(srcWebXml);
  merger.merge(mergeWebXml);
  assertTrue(WebXmlUtils.hasServlet(srcWebXml,"s1"));
  List<String> initParams=WebXmlUtils.getServletInitParamNames(srcWebXml,"s1");
  assertEquals(1,initParams.size());
  assertEquals("s1param1",initParams.get(0));
  assertEquals("s1param1value",WebXmlUtils.getServletInitParam(srcWebXml,"s1","s1param1"));
}

public void testMergeOneServletIntoDocumentWithSameServletAndParam ( ) throws Exception { String srcXml = "<web-app>" + "  <servlet>" + "    <servlet-name>s1</servlet-name>" + "    <servlet-class>sclass1</servlet-class>" + "  </servlet>" + "</web-app>" ; WebXml srcWebXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( srcXml . getBytes ( "UTF-8" ) ) , null ) ; String mergeXml = "<web-app>" + "  <servlet>" + "    <servlet-name>s1</servlet-name>" + "    <servlet-class>sclass1</servlet-class>" + "    <init-param>" + "      <param-name>s1param1</param-name>" + "      <param-value>s1param1value</param-value>" + "    </init-param>" + "  </servlet>" + "</web-app>" ; WebXml mergeWebXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( mergeXml . getBytes ( "UTF-8" ) ) , null ) ; WebXmlMerger merger = new WebXmlMerger ( srcWebXml ) ; merger . merge ( mergeWebXml ) ; assertTrue ( WebXmlUtils . hasServlet ( srcWebXml , "s1" ) ) ; List < String > initParams = WebXmlUtils . getServletInitParamNames ( srcWebXml , "s1" ) ; assertEquals ( 1 , initParams . size ( ) ) ; assertEquals ( "s1param1" , initParams . get ( 0 ) ) ; assertEquals ( "s1param1value" , WebXmlUtils . getServletInitParam ( srcWebXml , "s1" , "s1param1" ) ) ; }
tets whether a servlet with an initialization parameter is correctly merged into a descriptor that contains the definition of a servlet with the same name .
