public void testMergeSecurityRoleIntoEmptyDocument() throws Exception {
  String srcXml="<web-app></web-app>";
  WebXml srcWebXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(srcXml.getBytes("UTF-8")),null);
  String mergeXml="<web-app>" + "  <security-role>" + "    <role-name>role1</role-name>"+ "  </security-role>"+ "</web-app>";
  WebXml mergeWebXml=WebXmlIo.parseWebXml(new ByteArrayInputStream(mergeXml.getBytes("UTF-8")),null);
  WebXmlMerger merger=new WebXmlMerger(srcWebXml);
  merger.merge(mergeWebXml);
  List<String> securityRoleNames=WebXmlUtils.getSecurityRoleNames(srcWebXml);
  assertEquals(1,securityRoleNames.size());
  assertEquals("role1",securityRoleNames.get(0));
}

public void testMergeSecurityRoleIntoEmptyDocument ( ) throws Exception { String srcXml = "<web-app></web-app>" ; WebXml srcWebXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( srcXml . getBytes ( "UTF-8" ) ) , null ) ; String mergeXml = "<web-app>" + "  <security-role>" + "    <role-name>role1</role-name>" + "  </security-role>" + "</web-app>" ; WebXml mergeWebXml = WebXmlIo . parseWebXml ( new ByteArrayInputStream ( mergeXml . getBytes ( "UTF-8" ) ) , null ) ; WebXmlMerger merger = new WebXmlMerger ( srcWebXml ) ; merger . merge ( mergeWebXml ) ; List < String > securityRoleNames = WebXmlUtils . getSecurityRoleNames ( srcWebXml ) ; assertEquals ( 1 , securityRoleNames . size ( ) ) ; assertEquals ( "role1" , securityRoleNames . get ( 0 ) ) ; }
tests whether a single security role is correctly inserted into an empty descriptor .
