public void testMergeOneSecurityConstraintIntoEmptyDocument() throws Exception {
  String srcXml="<web-app></web-app>";
  WebXml srcWebXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(srcXml.getBytes("UTF-8")),null);
  String mergeXml="<web-app>" + "  <security-constraint>" + "    <web-resource-collection>"+ "      <web-resource-name>resource1</web-resource-name>"+ "      <url-pattern>/s1/*</url-pattern>"+ "    </web-resource-collection>"+ "    <auth-constraint>"+ "      <role-name>role1</role-name>"+ "    </auth-constraint>"+ "  </security-constraint>"+ "</web-app>";
  WebXml mergeWebXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(mergeXml.getBytes("UTF-8")),null);
  WebXmlMerger merger=new WebXmlMerger(srcWebXml);
  merger.merge(mergeWebXml);
  assertNotNull(WebXmlUtils.getSecurityConstraint(srcWebXml,"/s1/*"));
  assertNull(WebXmlUtils.getSecurityConstraint(srcWebXml,"/s2/*"));
}

public void testMergeOneSecurityConstraintIntoEmptyDocument ( ) throws Exception { String srcXml = "<web-app></web-app>" ; WebXml srcWebXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( srcXml . getBytes ( "UTF-8" ) ) , null ) ; String mergeXml = "<web-app>" + "  <security-constraint>" + "    <web-resource-collection>" + "      <web-resource-name>resource1</web-resource-name>" + "      <url-pattern>/s1/*</url-pattern>" + "    </web-resource-collection>" + "    <auth-constraint>" + "      <role-name>role1</role-name>" + "    </auth-constraint>" + "  </security-constraint>" + "</web-app>" ; WebXml mergeWebXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( mergeXml . getBytes ( "UTF-8" ) ) , null ) ; WebXmlMerger merger = new WebXmlMerger ( srcWebXml ) ; merger . merge ( mergeWebXml ) ; assertNotNull ( WebXmlUtils . getSecurityConstraint ( srcWebXml , "/s1/*" ) ) ; assertNull ( WebXmlUtils . getSecurityConstraint ( srcWebXml , "/s2/*" ) ) ; }
tests whether a single security constraint is correctly merged into an empty descriptor .
