ExtensibleUrlClassLoaderTest.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:components 作者:
@Test
public void testDynamicClassLoaderService() throws MalformedURLException {
    // this will check that the java service loader works on a classloader that is mutable
    RuntimeUtil.registerMavenUrlHandler();
    // given
    ExtensibleUrlClassLoader urlClassLoader = new ExtensibleUrlClassLoader(new URL[0]);
    // 2 comp installer
    assertThat(ServiceLoader.load(ComponentInstaller.class, urlClassLoader),
            IsIterableWithSize.<ComponentInstaller> iterableWithSize(2));

    // when
    urlClassLoader.addURL(new URL("mvn:org.talend.components/multiple-runtime-comp/0.18.0"));

    // then
    // 3 comp installer
    assertThat(ServiceLoader.load(ComponentInstaller.class, urlClassLoader),
            IsIterableWithSize.<ComponentInstaller> iterableWithSize(3));

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号