throws Exception
{
String srcXml = "<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'><web-app></web-app>";
Document srcDoc =
builder.parse(new ByteArrayInputStream(srcXml.getBytes()));
WebXml srcWebXml = new WebXml(srcDoc);
String mergeXml = "<web-app>"
+ " <filter>"
+ " <filter-name>f1</filter-name>"
+ " <filter-class>fclass1</filter-class>"
+ " </filter>"
+ " <filter-mapping>"
+ " <filter-name>f1</filter-name>"
+ " <url-pattern>/f1mapping1</url-pattern>"
+ " </filter-mapping>"
+ " <filter-mapping>"
+ " <filter-name>f1</filter-name>"
+ " <url-pattern>/f1mapping2</url-pattern>"
+ " </filter-mapping>"
+ " <filter-mapping>"
+ " <filter-name>f1</filter-name>"
+ " <url-pattern>/f1mapping3</url-pattern>"
+ " </filter-mapping>"
+ "</web-app>";
Document mergeDoc =
builder.parse(new ByteArrayInputStream(mergeXml.getBytes()));
WebXml mergeWebXml = new WebXml(mergeDoc);
WebXmlMerger merger = new WebXmlMerger(srcWebXml);
merger.merge(mergeWebXml);
assertTrue(srcWebXml.hasFilter("f1"));
Iterator filterMappings = srcWebXml.getFilterMappings("f1");
assertEquals("/f1mapping1", filterMappings.next());