|
16 | 16 | */ |
17 | 17 | package org.apache.tomcat.util.descriptor.web; |
18 | 18 |
|
| 19 | +import java.net.MalformedURLException; |
| 20 | +import java.net.URL; |
19 | 21 | import java.util.ArrayList; |
20 | 22 | import java.util.HashSet; |
21 | 23 | import java.util.Iterator; |
@@ -348,6 +350,31 @@ public void testOrderWebFragmentsrelativeCircular2() { |
348 | 350 | WebXml.orderWebFragments(app, fragments, null); |
349 | 351 | } |
350 | 352 |
|
| 353 | + @Test(expected=IllegalArgumentException.class) |
| 354 | + public void testOrderWebFragmentsRelativeDuplicate() throws MalformedURLException { |
| 355 | + WebXml withDuplicate = new WebXml(); |
| 356 | + withDuplicate.setURL(new URL("https://example.com/original.jar")); |
| 357 | + withDuplicate.addDuplicate("https://example.com/duplicate.jar"); |
| 358 | + |
| 359 | + Map<String,WebXml> fragmentsWithDuplicate = new LinkedHashMap<>(); |
| 360 | + fragmentsWithDuplicate.put("has-duplicate", withDuplicate); |
| 361 | + |
| 362 | + WebXml.orderWebFragments(app, fragmentsWithDuplicate, null); |
| 363 | + } |
| 364 | + |
| 365 | + @SuppressWarnings("deprecation") |
| 366 | + @Test(expected=IllegalArgumentException.class) |
| 367 | + public void testOrderWebFragmentsRelativeDuplicateDeprecated() throws MalformedURLException { |
| 368 | + WebXml withDuplicate = new WebXml(); |
| 369 | + withDuplicate.setURL(new URL("https://example.com/original.jar")); |
| 370 | + withDuplicate.setDuplicated(true); |
| 371 | + |
| 372 | + Map<String,WebXml> fragmentsWithDuplicate = new LinkedHashMap<>(); |
| 373 | + fragmentsWithDuplicate.put("has-duplicate", withDuplicate); |
| 374 | + |
| 375 | + WebXml.orderWebFragments(app, fragmentsWithDuplicate, null); |
| 376 | + } |
| 377 | + |
351 | 378 | private interface RelativeOrderingTestRunner { |
352 | 379 | void init(); |
353 | 380 | void validate(String order); |
|
0 commit comments