builder: use BuilderConfiguration to provide the classLoader

This commit is contained in:
Paul Campbell 2018-03-09 19:52:10 +00:00
parent 9f9096f657
commit defa19a143
2 changed files with 10 additions and 3 deletions

View file

@ -47,10 +47,16 @@ public class BuilderConfiguration {
* @return the ClassPath
*
* @throws IOException if there is an error
* @param classLoader
*/
@Bean
public ClassPath classPath() throws IOException {
return ClassPath.from(getClass().getClassLoader());
public ClassPath classPath(final ClassLoader classLoader) throws IOException {
return ClassPath.from(classLoader);
}
@Bean
public ClassLoader classLoader() {
return BuilderConfiguration.class.getClassLoader();
}
/**

View file

@ -23,7 +23,8 @@ public class BuilderConfigurationTest {
@Test
public void canGetClassPath() throws IOException {
//when
final ClassPath classPath = new BuilderConfiguration().classPath();
final BuilderConfiguration builderConfiguration = new BuilderConfiguration();
final ClassPath classPath = builderConfiguration.classPath(builderConfiguration.getClass().getClassLoader());
//then
assertThat(classPath).isNotNull();
}