public void testMergeMultipleFiltersIntoEmptyDocument() throws Exception {
  String srcXml="<web-app></web-app>";
  WebXml srcWebXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(srcXml.getBytes("UTF-8")),null);
  String mergeXml="<web-app>" + "  <filter>" + "    <filter-name>f1</filter-name>"+ "    <filter-class>fclass1</filter-class>"+ "  </filter>"+ "  <filter>"+ "    <filter-name>f2</filter-name>"+ "    <filter-class>fclass2</filter-class>"+ "  </filter>"+ "  <filter>"+ "    <filter-name>f3</filter-name>"+ "    <filter-class>fclass3</filter-class>"+ "  </filter>"+ "</web-app>";
  WebXml mergeWebXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(mergeXml.getBytes("UTF-8")),null);
  WebXmlMerger merger=new WebXmlMerger(srcWebXml);
  merger.mergeFilters(mergeWebXml);
  List<String> filterNames=WebXmlUtils.getFilterNames(srcWebXml);
  assertEquals(3,filterNames.size());
  assertEquals("f1",filterNames.get(0));
  assertEquals("f2",filterNames.get(1));
  assertEquals("f3",filterNames.get(2));
}

public void testMergeMultipleFiltersIntoEmptyDocument ( ) throws Exception { String srcXml = "<web-app></web-app>" ; WebXml srcWebXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( srcXml . getBytes ( "UTF-8" ) ) , null ) ; String mergeXml = "<web-app>" + "  <filter>" + "    <filter-name>f1</filter-name>" + "    <filter-class>fclass1</filter-class>" + "  </filter>" + "  <filter>" + "    <filter-name>f2</filter-name>" + "    <filter-class>fclass2</filter-class>" + "  </filter>" + "  <filter>" + "    <filter-name>f3</filter-name>" + "    <filter-class>fclass3</filter-class>" + "  </filter>" + "</web-app>" ; WebXml mergeWebXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( mergeXml . getBytes ( "UTF-8" ) ) , null ) ; WebXmlMerger merger = new WebXmlMerger ( srcWebXml ) ; merger . mergeFilters ( mergeWebXml ) ; List < String > filterNames = WebXmlUtils . getFilterNames ( srcWebXml ) ; assertEquals ( 3 , filterNames . size ( ) ) ; assertEquals ( "f1" , filterNames . get ( 0 ) ) ; assertEquals ( "f2" , filterNames . get ( 1 ) ) ; assertEquals ( "f3" , filterNames . get ( 2 ) ) ; }
tests whether multiple filters are correctly merged into an empty descriptor .
