Skip to content

Commit

Permalink
#24 Add test for direct static required modules
Browse files Browse the repository at this point in the history
  • Loading branch information
rfscholte committed May 28, 2019
1 parent 714fa9f commit c5c7d7e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,34 @@ public void testTransitiveStatic() throws Exception
assertThat( result.getPathExceptions().size(), is( 0 ) );
}

@Test
public void testDirectStatic() throws Exception
{
Path moduleA = Paths.get( "src/test/resources/mock/module-info.java" ); // some file called module-info.java
Path moduleB = Paths.get( "src/test/resources/mock/jar0.jar" ); // any existing file
Path moduleC = Paths.get( "src/test/resources/mock/jar1.jar" ); // any existing file
Path moduleD = Paths.get( "src/test/resources/mock/jar2.jar" ); // any existing file
ResolvePathsRequest<Path> request = ResolvePathsRequest.ofPaths( moduleB, moduleC, moduleD ).setMainModuleDescriptor( moduleA );

when( qdoxParser.fromSourcePath( moduleA ) ).thenReturn( JavaModuleDescriptor.newModule( "moduleA" )
.requires( "moduleB" )
.requires​( Collections.singleton( JavaModuleDescriptor.JavaRequires.JavaModifier.STATIC ), "moduleD")
.build() );
when( asmParser.getModuleDescriptor( moduleB ) ).thenReturn( JavaModuleDescriptor.newModule( "moduleB" )
.requires​( Collections.singleton( JavaModuleDescriptor.JavaRequires.JavaModifier.STATIC ), "moduleC" )
.build() );
when( asmParser.getModuleDescriptor( moduleC ) ).thenReturn( JavaModuleDescriptor.newModule( "moduleC" ).build() );
when( asmParser.getModuleDescriptor( moduleD ) ).thenReturn( JavaModuleDescriptor.newModule( "moduleD" ).build() );


ResolvePathsResult<Path> result = locationManager.resolvePaths( request );
assertThat( result.getPathElements().size(), is( 3 ) );
assertThat( result.getModulepathElements().size(), is( 2 ) );
assertThat( result.getModulepathElements().containsKey( moduleB ), is( true ) );
assertThat( result.getModulepathElements().containsKey( moduleD ), is( true ) );
assertThat( result.getClasspathElements().size(), is( 1 ) );
assertThat( result.getClasspathElements().contains( moduleC ), is( true ) );
assertThat( result.getPathExceptions().size(), is( 0 ) );
}

}
Empty file.

0 comments on commit c5c7d7e

Please sign in to comment.