use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class DefaultRegionPluginClassLoadersFactoryTestCase method createsPluginWithPrivilegedContainerAccess.
@Test
public void createsPluginWithPrivilegedContainerAccess() throws Exception {
MuleModule privilegedModule = mock(MuleModule.class);
when(privilegedModule.getPrivilegedArtifacts()).thenReturn(singleton(PLUGIN_ARTIFACT_ID1));
when(privilegedModule.getPrivilegedExportedPackages()).thenReturn(singleton(PRIVILEGED_PACKAGE));
when(moduleRepository.getModules()).thenReturn(singletonList(privilegedModule));
List<ArtifactPluginDescriptor> artifactPluginDescriptors = singletonList(plugin1Descriptor);
ArgumentCaptor<Map> mapArgumentCaptor = forClass(Map.class);
when(regionOwnerLookupPolicy.extend(mapArgumentCaptor.capture())).thenReturn(pluginLookupPolicy);
List<ArtifactClassLoader> pluginClassLoaders = factory.createPluginClassLoaders(regionClassLoader, artifactPluginDescriptors, regionOwnerLookupPolicy);
assertThat(pluginClassLoaders, contains(pluginClassLoader1));
Map<String, LookupStrategy> value = mapArgumentCaptor.getValue();
assertThat(value, hasEntry(equalTo(PRIVILEGED_PACKAGE), instanceOf(ContainerOnlyLookupStrategy.class)));
}
use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class ArtifactBootstrapRegistryConfigurationBuilderTestCase method createBootstrapServiceDiscovererContextBuilder.
private ArtifactBootstrapServiceDiscovererConfigurationBuilder createBootstrapServiceDiscovererContextBuilder() {
try {
ArtifactPlugin plugin1 = mock(ArtifactPlugin.class);
final ArtifactClassLoader pluginClassLoader1 = mock(ArtifactClassLoader.class);
when(plugin1.getArtifactClassLoader()).thenReturn(pluginClassLoader1);
final List<ArtifactPlugin> artifactPlugins = new ArrayList<>();
artifactPlugins.add(plugin1);
final List<URL> urls = new ArrayList<>();
urls.add(this.getClass().getResource("/plugin1-bootstrap.properties"));
urls.add(this.getClass().getResource("/plugin2-bootstrap.properties"));
when(pluginClassLoader1.findResources(BOOTSTRAP_PROPERTIES)).thenReturn(new EnumerationAdapter<>(urls));
return new ArtifactBootstrapServiceDiscovererConfigurationBuilder(artifactPlugins);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class DefaultArtifactClassLoaderManagerTestCase method getIdForNonRegisteredArtifactClassLoader.
@Test
public void getIdForNonRegisteredArtifactClassLoader() {
ArtifactClassLoader artifactClassLoader = getArtifactClassLoader();
assertThat(manager.getId(artifactClassLoader.getClassLoader()), is(Optional.empty()));
}
use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class DefaultArtifactClassLoaderManagerTestCase method getIdForRegisteredArtifactClassLoader.
@Test
public void getIdForRegisteredArtifactClassLoader() {
ArtifactClassLoader artifactClassLoader = getArtifactClassLoader();
manager.register(artifactClassLoader);
assertThat(manager.getId(artifactClassLoader.getClassLoader()), is(Optional.of(ARTIFACT_ID)));
}
use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class DefaultPolicyTemplateFactoryTestCase method createRegionClassLoader.
private RegionClassLoader createRegionClassLoader() {
ClassLoaderLookupPolicy lookupPolicy = mock(ClassLoaderLookupPolicy.class);
RegionClassLoader regionClassLoader = new RegionClassLoader(descriptor.getName(), descriptor, this.getClass().getClassLoader(), lookupPolicy);
// Adds the owner of the region
ArtifactClassLoader regionOwnerClassLoader = mock(ArtifactClassLoader.class);
regionClassLoader.addClassLoader(regionOwnerClassLoader, NULL_CLASSLOADER_FILTER);
return regionClassLoader;
}
Aggregations