use of org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder in project mule by mulesoft.
the class ArtifactPluginDescriptorFactoryTestCase method detectsInvalidBundleDescriptorModelLoaderId.
@Test
public void detectsInvalidBundleDescriptorModelLoaderId() throws Exception {
MulePluginModel.MulePluginModelBuilder pluginModelBuilder = new MulePluginModel.MulePluginModelBuilder().setName(PLUGIN_NAME).setMinMuleVersion(MIN_MULE_VERSION).setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(INVALID_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(FILE_SYSTEM_POLICY_MODEL_LOADER_ID, emptyMap()));
ArtifactPluginFileBuilder pluginFileBuilder = new ArtifactPluginFileBuilder(PLUGIN_NAME).tempFolder(pluginsTempFolder.newFolder()).describedBy(pluginModelBuilder.build());
File pluginJarLocation = pluginFileBuilder.getArtifactFile();
expectedException.expect(ArtifactDescriptorCreateException.class);
expectedException.expectMessage(invalidBundleDescriptorLoaderIdError(pluginJarLocation, pluginModelBuilder.getBundleDescriptorLoader()));
descriptorFactory.create(pluginJarLocation, empty());
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder 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.builder.ArtifactPluginFileBuilder in project mule by mulesoft.
the class ArtifactPluginDescriptorFactoryTestCase method createPluginDescriptor.
@Test
public void createPluginDescriptor() throws Exception {
String pluginName = "samplePlugin";
MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder();
builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().setId("mule").build());
Map<String, Object> attributes = new HashMap<>();
attributes.put(GROUP_ID, "org.mule.test");
attributes.put(ARTIFACT_ID, pluginName);
attributes.put(VERSION, "1.0.0");
attributes.put(CLASSIFIER, MULE_PLUGIN_CLASSIFIER);
attributes.put(TYPE, "jar");
builder.withBundleDescriptorLoader(new MuleArtifactLoaderDescriptor(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID, attributes));
builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
MulePluginModel mulePluginModel = builder.setName(pluginName).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).build();
ArtifactPluginFileBuilder pluginFileBuilder = new ArtifactPluginFileBuilder(PLUGIN_NAME).tempFolder(pluginsTempFolder.newFolder()).describedBy(mulePluginModel);
final ArtifactPluginDescriptor artifactPluginDescriptor = descriptorFactory.create(pluginFileBuilder.getArtifactFile(), empty());
assertThat(artifactPluginDescriptor.getName(), equalTo(pluginName));
assertThat(artifactPluginDescriptor.getBundleDescriptor().getArtifactId(), equalTo(pluginName));
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder in project mule by mulesoft.
the class ArtifactPluginDescriptorFactoryTestCase method detectsInvalidClassLoaderModelLoaderId.
@Test
public void detectsInvalidClassLoaderModelLoaderId() throws Exception {
MulePluginModel.MulePluginModelBuilder pluginModelBuilder = new MulePluginModel.MulePluginModelBuilder().setName(PLUGIN_NAME).setMinMuleVersion(MIN_MULE_VERSION).setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID));
pluginModelBuilder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(INVALID_LOADER_ID, emptyMap()));
ArtifactPluginFileBuilder pluginFileBuilder = new ArtifactPluginFileBuilder(PLUGIN_NAME).tempFolder(pluginsTempFolder.newFolder()).describedBy(pluginModelBuilder.build());
File pluginJarLocation = pluginFileBuilder.getArtifactFile();
expectedException.expect(ArtifactDescriptorCreateException.class);
expectedException.expectMessage(invalidClassLoaderModelIdError(pluginJarLocation, pluginModelBuilder.getClassLoaderModelDescriptorLoader()));
descriptorFactory.create(pluginJarLocation, empty());
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder in project mule by mulesoft.
the class ArtifactPluginDescriptorFactoryTestCase method pluginDescriptorNotFound.
@Test
public void pluginDescriptorNotFound() throws Exception {
ArtifactPluginFileBuilder pluginFileBuilder = new ArtifactPluginFileBuilder(PLUGIN_NAME).tempFolder(pluginsTempFolder.newFolder());
File pluginJarLocation = pluginFileBuilder.getArtifactFile();
expectedException.expect(ArtifactDescriptorCreateException.class);
expectedException.expectMessage(containsString(MULE_ARTIFACT_JSON_DESCRIPTOR));
descriptorFactory.create(pluginJarLocation, empty());
}
Aggregations