use of org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor in project mule by mulesoft.
the class BundlePluginDependenciesResolverTestCase method resolvesDependenciesTwoVersionWhenLatestComesFromTransitiveMinor.
@Test
public void resolvesDependenciesTwoVersionWhenLatestComesFromTransitiveMinor() throws Exception {
final List<ArtifactPluginDescriptor> pluginDescriptors = createPluginDescriptors(fooPlugin, latestEchoPlugin, bazPlugin);
latestEchoPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(BAZ_PLUGIN_DESCRIPTOR)).build());
fooPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(ECHO_PLUGIN_DESCRIPTOR)).build());
echoPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(LATEST_BAZ_PLUGIN_DESCRIPTOR)).build());
final List<ArtifactPluginDescriptor> resolvedPluginDescriptors = dependenciesResolver.resolve(emptySet(), pluginDescriptors);
assertResolvedPlugins(resolvedPluginDescriptors, bazPlugin, latestEchoPlugin, fooPlugin);
}
use of org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor in project mule by mulesoft.
the class AbstractToolingClassLoaderTestCase method createAppClassLoader.
@Before
public void createAppClassLoader() {
final ClassLoaderLookupPolicy classLoaderLookupPolicy = mock(ClassLoaderLookupPolicy.class);
// Mandatory to find a resource releaser instance when doing the dispose of a RegionClassLoader
when(classLoaderLookupPolicy.getClassLookupStrategy(anyString())).thenReturn(PARENT_FIRST);
regionClassLoader = new RegionClassLoader(TEST_REGION, new ArtifactDescriptor(REGION_NAME), getClass().getClassLoader(), classLoaderLookupPolicy);
// Loading the additional classloader as the ToolingPluginClassLoaderBuilder does
regionClassLoader.addClassLoader(mock(ArtifactClassLoader.class), mock(ArtifactClassLoaderFilter.class));
artifactPluginDescriptor = new ArtifactPluginDescriptor(PLUGIN_NAME);
pluginArtifactClassLoader = spy(new TestToolingPluginClassLoader(artifactPluginDescriptor));
}
use of org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor 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.deployment.model.api.plugin.ArtifactPluginDescriptor in project mule by mulesoft.
the class BundlePluginDependenciesResolver method verifyPluginExportedPackages.
private void verifyPluginExportedPackages(List<ArtifactPluginDescriptor> plugins) {
final Map<String, List<String>> exportedPackages = new HashMap<>();
boolean error = false;
for (ArtifactPluginDescriptor plugin : plugins) {
for (String packageName : plugin.getClassLoaderModel().getExportedPackages()) {
List<String> exportedOn = exportedPackages.get(packageName);
if (exportedOn == null) {
exportedOn = new LinkedList<>();
exportedPackages.put(packageName, exportedOn);
} else {
error = true;
}
exportedOn.add(plugin.getName());
}
}
if (error) {
throw new DuplicateExportedPackageException(exportedPackages);
}
}
use of org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor in project mule by mulesoft.
the class PolicyTemplateDescriptorFactoryTestCase method readsPlugin.
@Test
public void readsPlugin() throws Exception {
MulePolicyModelBuilder policyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
ArtifactPluginFileBuilder plugin1 = new ArtifactPluginFileBuilder("plugin1");
ArtifactPluginFileBuilder plugin2 = new ArtifactPluginFileBuilder("plugin2");
PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).describedBy(policyModelBuilder.build()).dependingOn(plugin1).dependingOn(plugin2);
File tempFolder = createTempFolder();
unzip(policyFileBuilder.getArtifactFile(), tempFolder);
final ArtifactPluginDescriptorFactory pluginDescriptorFactory = mock(ArtifactPluginDescriptorFactory.class);
final PolicyTemplateDescriptorFactory policyTemplateDescriptorFactory = new PolicyTemplateDescriptorFactory(new ArtifactPluginDescriptorLoader(pluginDescriptorFactory), descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
final ArtifactPluginDescriptor expectedPluginDescriptor1 = new ArtifactPluginDescriptor("plugin1");
final ArtifactPluginDescriptor expectedPluginDescriptor2 = new ArtifactPluginDescriptor("plugin2");
when(pluginDescriptorFactory.create(any(), any())).thenReturn(expectedPluginDescriptor1).thenReturn(expectedPluginDescriptor2);
PolicyTemplateDescriptor descriptor = policyTemplateDescriptorFactory.create(tempFolder, empty());
Set<ArtifactPluginDescriptor> plugins = descriptor.getPlugins();
assertThat(plugins.size(), equalTo(2));
assertThat(plugins, hasItem(equalTo(expectedPluginDescriptor1)));
assertThat(plugins, hasItem(equalTo(expectedPluginDescriptor2)));
}
Aggregations