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>"
+ " <servlet>"
+ " <servlet-name>s1</servlet-name>"
+ " <servlet-class>sclass1</servlet-class>"
+ " </servlet>"
+ " <servlet-mapping>"
+ " <servlet-name>s1</servlet-name>"
+ " <url-pattern>/s1mapping1</url-pattern>"
+ " </servlet-mapping>"
+ " <servlet-mapping>"
+ " <servlet-name>s1</servlet-name>"
+ " <url-pattern>/s1mapping2</url-pattern>"
+ " </servlet-mapping>"
+ " <servlet-mapping>"
+ " <servlet-name>s1</servlet-name>"
+ " <url-pattern>/s1mapping3</url-pattern>"
+ " </servlet-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.hasServlet("s1"));
Iterator servletMappings = srcWebXml.getServletMappings("s1");
assertEquals("/s1mapping1", servletMappings.next());