use of org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory in project mule by mulesoft.
the class TestDomainFactory method createDomainFactory.
public static TestDomainFactory createDomainFactory(DomainClassLoaderFactory domainClassLoaderFactory, ArtifactClassLoader containerClassLoader, ServiceRepository serviceRepository, ModuleRepository moduleRepository, DescriptorLoaderRepository descriptorLoaderRepository) {
ArtifactPluginDescriptorFactory artifactPluginDescriptorFactory = new ArtifactPluginDescriptorFactory();
ArtifactPluginDescriptorLoader artifactPluginDescriptorLoader = new ArtifactPluginDescriptorLoader(artifactPluginDescriptorFactory);
DomainDescriptorFactory domainDescriptorFactory = new DomainDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
final DefaultClassLoaderManager artifactClassLoaderManager = new DefaultClassLoaderManager();
PluginDependenciesResolver pluginDependenciesResolver = new BundlePluginDependenciesResolver(artifactPluginDescriptorFactory);
DomainClassLoaderBuilderFactory domainClassLoaderBuilderFactory = new DomainClassLoaderBuilderFactory(containerClassLoader, domainClassLoaderFactory, new DefaultRegionPluginClassLoadersFactory(new TrackingArtifactClassLoaderFactory<>(artifactClassLoaderManager, new ArtifactPluginClassLoaderFactory()), moduleRepository));
return new TestDomainFactory(artifactClassLoaderManager, serviceRepository, domainDescriptorFactory, pluginDependenciesResolver, domainClassLoaderBuilderFactory, new MuleExtensionModelLoaderManager(containerClassLoader));
}
use of org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory 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)));
}
use of org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory in project mule by mulesoft.
the class PropertyOverridesTestCase method testOverrides.
@Test
public void testOverrides() throws Exception {
File tempProps = File.createTempFile("property", "overrides");
InputStream input = getClass().getClassLoader().getResourceAsStream("overridden.properties");
FileOutputStream output = new FileOutputStream(tempProps);
copy(input, output);
input.close();
output.close();
ApplicationDescriptor descriptor = new ApplicationDescriptor("app");
ApplicationDescriptorFactory applicationDescriptorFactory = new ApplicationDescriptorFactory(new ArtifactPluginDescriptorLoader(new ArtifactPluginDescriptorFactory()), new ServiceRegistryDescriptorLoaderRepository(new SpiServiceRegistry()), ArtifactDescriptorValidatorBuilder.builder());
applicationDescriptorFactory.setApplicationProperties(descriptor, tempProps);
Map<String, String> appProps = descriptor.getAppProperties();
assertEquals("state", appProps.get("texas"));
assertEquals("country", appProps.get("peru"));
assertEquals("austin", appProps.get("texas.capital"));
assertEquals("4", appProps.get("peru.capital.numberOfletters"));
assertEquals("runtime", appProps.get("mule"));
assertEquals("ipaas", appProps.get("mule.ion"));
try {
setSystemProperties();
descriptor = new ApplicationDescriptor("app");
applicationDescriptorFactory.setApplicationProperties(descriptor, tempProps);
appProps = descriptor.getAppProperties();
assertEquals("state", appProps.get("texas"));
assertEquals("nation", appProps.get("peru"));
assertEquals("austin", appProps.get("texas.capital"));
assertEquals("4", appProps.get("peru.capital.numberOfletters"));
assertEquals("wayCool", appProps.get("mule"));
assertEquals("ipaas", appProps.get("mule.ion"));
assertEquals("evenCooler", appProps.get("mule.mmc"));
descriptor = new ApplicationDescriptor("app");
applicationDescriptorFactory.setApplicationProperties(descriptor, new File("nonexistent.nonexistent"));
appProps = descriptor.getAppProperties();
assertNull(appProps.get("texas"));
assertEquals("nation", appProps.get("peru"));
assertNull(appProps.get("texas.capital"));
assertNull(appProps.get("peru.capital.numberOfletters"));
assertEquals("wayCool", appProps.get("mule"));
assertNull(appProps.get("mule.ion"));
assertEquals("evenCooler", appProps.get("mule.mmc"));
} finally {
resetSystemProperties();
}
}
use of org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory in project mule by mulesoft.
the class TestApplicationFactory method createTestApplicationFactory.
public static TestApplicationFactory createTestApplicationFactory(MuleApplicationClassLoaderFactory applicationClassLoaderFactory, DomainManager domainManager, ServiceRepository serviceRepository, ExtensionModelLoaderRepository extensionModelLoaderRepository, ModuleRepository moduleRepository, DescriptorLoaderRepository descriptorLoaderRepository) {
ArtifactPluginDescriptorFactory artifactPluginDescriptorFactory = new ArtifactPluginDescriptorFactory();
ArtifactPluginDescriptorLoader artifactPluginDescriptorLoader = new ArtifactPluginDescriptorLoader(artifactPluginDescriptorFactory);
ApplicationDescriptorFactory applicationDescriptorFactory = new ApplicationDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
final DefaultClassLoaderManager artifactClassLoaderManager = new DefaultClassLoaderManager();
PluginDependenciesResolver pluginDependenciesResolver = new BundlePluginDependenciesResolver(artifactPluginDescriptorFactory);
ApplicationClassLoaderBuilderFactory applicationClassLoaderBuilderFactory = new ApplicationClassLoaderBuilderFactory(applicationClassLoaderFactory, new TrackingArtifactClassLoaderFactory<>(artifactClassLoaderManager, new ArtifactPluginClassLoaderFactory()), new DefaultRegionPluginClassLoadersFactory(new ArtifactPluginClassLoaderFactory(), moduleRepository));
return new TestApplicationFactory(applicationClassLoaderBuilderFactory, applicationDescriptorFactory, domainManager, serviceRepository, extensionModelLoaderRepository, artifactClassLoaderManager, mock(PolicyTemplateClassLoaderBuilderFactory.class), pluginDependenciesResolver, artifactPluginDescriptorLoader);
}
Aggregations