|
21 | 21 |
|
22 | 22 | import static org.hamcrest.CoreMatchers.is;
|
23 | 23 | import static org.hamcrest.CoreMatchers.nullValue;
|
24 |
| -import static org.junit.Assert.assertThat; |
| 24 | +import static org.hamcrest.MatcherAssert.assertThat; |
25 | 25 | import static org.mockito.ArgumentMatchers.any;
|
26 | 26 | import static org.mockito.Mockito.when;
|
27 | 27 |
|
@@ -410,5 +410,31 @@ public void testDirectStatic() throws Exception
|
410 | 410 | assertThat( result.getClasspathElements().contains( moduleC ), is( true ) );
|
411 | 411 | assertThat( result.getPathExceptions().size(), is( 0 ) );
|
412 | 412 | }
|
| 413 | + |
| 414 | + @Test |
| 415 | + public void testDuplicateModule() throws Exception |
| 416 | + { |
| 417 | + Path moduleA = Paths.get( "src/test/resources/mock/module-info.java" ); // some file called module-info.java |
| 418 | + Path moduleB = Paths.get( "src/test/resources/mock/jar0.jar" ); // any existing file |
| 419 | + Path moduleC = Paths.get( "src/test/resources/mock/jar1.jar" ); // any existing file |
| 420 | + |
| 421 | + ResolvePathsRequest<Path> request = ResolvePathsRequest.ofPaths( moduleB, moduleC ).setMainModuleDescriptor( moduleA ); |
| 422 | + |
| 423 | + when( qdoxParser.fromSourcePath( moduleA ) ).thenReturn( JavaModuleDescriptor.newModule( "moduleA" ) |
| 424 | + .requires( "anonymous" ) |
| 425 | + .build() ); |
| 426 | + when( asmParser.getModuleDescriptor( moduleB ) ).thenReturn( JavaModuleDescriptor.newModule( "anonymous" ) |
| 427 | + .build() ); |
| 428 | + when( asmParser.getModuleDescriptor( moduleC ) ).thenReturn( JavaModuleDescriptor.newModule( "anonymous" ) |
| 429 | + .build() ); |
| 430 | + |
| 431 | + ResolvePathsResult<Path> result = locationManager.resolvePaths( request ); |
| 432 | + assertThat( result.getPathElements().size(), is( 2 ) ); |
| 433 | + assertThat( result.getModulepathElements().size(), is( 1 ) ); |
| 434 | + assertThat( result.getModulepathElements().containsKey( moduleB ), is( true ) ); |
| 435 | + // with current default the duplicate will be ignored |
| 436 | + assertThat( result.getClasspathElements().size(), is( 0 ) ); |
| 437 | + assertThat( result.getPathExceptions().size(), is( 0 ) ); |
| 438 | + } |
413 | 439 |
|
414 | 440 | }
|
0 commit comments