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 * @return the ClassPath
* *
* @throws IOException if there is an error * @throws IOException if there is an error
* @param classLoader
*/ */
@Bean @Bean
public ClassPath classPath() throws IOException { public ClassPath classPath(final ClassLoader classLoader) throws IOException {
return ClassPath.from(getClass().getClassLoader()); return ClassPath.from(classLoader);
}
@Bean
public ClassLoader classLoader() {
return BuilderConfiguration.class.getClassLoader();
} }
/** /**

View file

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