public void testMergeOneServletIntoDocumentWithAnotherServlet() 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>s2</servlet-name>"+ "    <servlet-class>sclass2</servlet-class>"+ "  </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"));
  assertTrue(WebXmlUtils.hasServlet(srcWebXml,"s2"));
}

public void testMergeOneServletIntoDocumentWithAnotherServlet ( ) 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>s2</servlet-name>" + "    <servlet-class>sclass2</servlet-class>" + "  </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" ) ) ; assertTrue ( WebXmlUtils . hasServlet ( srcWebXml , "s2" ) ) ; }
tests whether a single servlet is correctly merged into a descriptor that already contains the definition of an other servlet .
