@Throws(Exception::class) fun testMergeSameFilterInTwoDocuments() { val srcXml = "<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>" + "</web-app>" val srcWebXml: WebXml = WebXmlIo.parseWebXml(ByteArrayInputStream(srcXml.toByteArray(charset("UTF-8"))), null) val 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>" + "</web-app>" val mergeWebXml: WebXml = WebXmlIo.parseWebXml(ByteArrayInputStream(mergeXml.toByteArray(charset("UTF-8"))), null) val merger = WebXmlMerger(srcWebXml) merger.mergeFilters(mergeWebXml) assertTrue(WebXmlUtils.hasFilter(srcWebXml, "f1")) val filterMappings: List<String> = WebXmlUtils.getFilterMappings(srcWebXml, "f1") assertEquals(1, filterMappings.size) assertEquals("/f1mapping1", filterMappings[0]) }
Tests whether the same filter in two different files is mapped correctly ( i.e. , once ) .