public void testMergeMultipleServletsIntoEmptyDocument() throws Exception {
  String srcXml="<web-app></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>"+ "  </servlet>"+ "  <servlet>"+ "    <servlet-name>s2</servlet-name>"+ "    <servlet-class>sclass2</servlet-class>"+ "  </servlet>"+ "  <servlet>"+ "    <servlet-name>s3</servlet-name>"+ "    <servlet-class>sclass3</servlet-class>"+ "  </servlet>"+ "</web-app>";
  WebXml mergeWebXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(mergeXml.getBytes("UTF-8")),null);
  WebXmlMerger merger=new WebXmlMerger(srcWebXml);
  merger.merge(mergeWebXml);
  List<String> servletNames=WebXmlUtils.getServletNames(srcWebXml);
  assertEquals(3,servletNames.size());
  assertEquals("s1",servletNames.get(0));
  assertEquals("s2",servletNames.get(1));
  assertEquals("s3",servletNames.get(2));
}

public void testMergeMultipleServletsIntoEmptyDocument ( ) throws Exception { String srcXml = "<web-app></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>" + "  </servlet>" + "  <servlet>" + "    <servlet-name>s2</servlet-name>" + "    <servlet-class>sclass2</servlet-class>" + "  </servlet>" + "  <servlet>" + "    <servlet-name>s3</servlet-name>" + "    <servlet-class>sclass3</servlet-class>" + "  </servlet>" + "</web-app>" ; WebXml mergeWebXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( mergeXml . getBytes ( "UTF-8" ) ) , null ) ; WebXmlMerger merger = new WebXmlMerger ( srcWebXml ) ; merger . merge ( mergeWebXml ) ; List < String > servletNames = WebXmlUtils . getServletNames ( srcWebXml ) ; assertEquals ( 3 , servletNames . size ( ) ) ; assertEquals ( "s1" , servletNames . get ( 0 ) ) ; assertEquals ( "s2" , servletNames . get ( 1 ) ) ; assertEquals ( "s3" , servletNames . get ( 2 ) ) ; }
tests whether multiple servlet in the merge file are correctly inserted into an empty descriptor .
