Source:
private void assertClassLoaderModelWithPluginDependencyAndAdditionalDependencies(String location) throws Exception { D desc = createArtifactDescriptor(getArtifactRootFolder() + location); ClassLoaderModel classLoaderModel = desc.getClassLoaderModel(); assertThat(classLoaderModel.getDependencies().size(), is(2)); assertThat(classLoaderModel.getDependencies(), hasItem(testEmptyPluginDependencyMatcher(COMPILE, true, false))); assertThat(classLoaderModel.getUrls().length, is(1)); assertThat(asList(classLoaderModel.getUrls()), not(hasItem(classLoaderModel.getDependencies().iterator().next()))); assertThat(desc.getPlugins(), hasSize(2)); ArtifactPluginDescriptor testEmptyPluginDescriptor = desc.getPlugins().stream() .filter(plugin -> plugin.getBundleDescriptor().getArtifactId().contains("test-empty-plugin")).findFirst().get(); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getUrls().length, is(3)); assertThat(of(testEmptyPluginDescriptor.getClassLoaderModel().getUrls()).map(url -> FileUtils.toFile(url)).collect(toList()), everyItem(exists())); assertThat(of(testEmptyPluginDescriptor.getClassLoaderModel().getUrls()).map(url -> FileUtils.toFile(url).getName()) .collect(toList()), hasItems(startsWith("test-empty-plugin-"), equalTo("commons-io-2.6.jar"), equalTo("commons-collections-3.2.1.jar"))); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getDependencies(), hasSize(0)); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getLocalPackages(), IsCollectionWithSize.hasSize(19)); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getLocalPackages(), hasItems("org.apache.commons.collections", "org.apache.commons.io")); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getLocalResources(), hasItems("META-INF/maven/commons-collections/commons-collections/pom.xml", "META-INF/maven/commons-io/commons-io/pom.xml")); ArtifactPluginDescriptor dependantPluginDescriptor = desc.getPlugins().stream() .filter(plugin -> plugin.getBundleDescriptor().getArtifactId().contains("dependant")).findFirst().get(); assertThat(dependantPluginDescriptor.getClassLoaderModel().getUrls().length, is(1)); assertThat(dependantPluginDescriptor.getClassLoaderModel().getDependencies(), hasSize(1)); }

Target:
private void assertClassLoaderModelWithPluginDependencyAndAdditionalDependencies(String location) throws Exception { D desc = createArtifactDescriptor(getArtifactRootFolder() + location); ClassLoaderModel classLoaderModel = desc.getClassLoaderModel(); assertThat(classLoaderModel.getDependencies().size(), is(2)); assertThat(classLoaderModel.getDependencies(), hasItem(testEmptyPluginDependencyMatcher(COMPILE, true, false))); assertThat(classLoaderModel.getUrls().length, is(1)); assertThat(asList(classLoaderModel.getUrls()), not(hasItem(classLoaderModel.getDependencies().iterator().next()))); assertThat(desc.getPlugins(), hasSize(2)); ArtifactPluginDescriptor testEmptyPluginDescriptor = desc.getPlugins().stream() .filter(plugin -> plugin.getBundleDescriptor().getArtifactId().contains("test-empty-plugin")).findFirst().get(); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getUrls().length, is(3)); assertThat(of(testEmptyPluginDescriptor.getClassLoaderModel().getUrls()).map(url -> FileUtils.toFile(url)).collect(toList()), everyItem(exists())); assertThat(of(testEmptyPluginDescriptor.getClassLoaderModel().getUrls()).map(url -> FileUtils.toFile(url).getName()) .collect(toList()), hasItems(startsWith("test-empty-plugin-"), equalTo("commons-io-2.6.jar"), equalTo("commons-collections-3.2.1.jar"))); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getDependencies(), hasSize(0)); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getLocalPackages(), hasSize(19)); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getLocalPackages(), hasItems("org.apache.commons.collections", "org.apache.commons.io")); assertThat(testEmptyPluginDescriptor.getClassLoaderModel().getLocalResources(), hasItems("META-INF/maven/commons-collections/commons-collections/pom.xml", "META-INF/maven/commons-io/commons-io/pom.xml")); ArtifactPluginDescriptor dependantPluginDescriptor = desc.getPlugins().stream() .filter(plugin -> plugin.getBundleDescriptor().getArtifactId().contains("dependant")).findFirst().get(); assertThat(dependantPluginDescriptor.getClassLoaderModel().getUrls().length, is(1)); assertThat(dependantPluginDescriptor.getClassLoaderModel().getDependencies(), hasSize(1)); }