use of org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder in project mule by mulesoft.
the class AbstractDeploymentTestCase method createPolicyIncludingDependantPluginFileBuilder.
private PolicyFileBuilder createPolicyIncludingDependantPluginFileBuilder() {
MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName(BAZ_POLICY_NAME).setRequiredProduct(Product.MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(BAZ_POLICY_NAME, MULE_POLICY_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
ArtifactPluginFileBuilder dependantPlugin;
try {
dependantPlugin = new ArtifactPluginFileBuilder("dependantPlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo.echo").containingClass(new SingleClassCompiler().compile(getResourceFile("/org/foo/echo/Plugin3Echo.java")), "org/foo/echo/Plugin3Echo.class").dependingOn(helloExtensionV1Plugin);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
return new PolicyFileBuilder(BAZ_POLICY_NAME).describedBy(mulePolicyModelBuilder.build()).dependingOn(dependantPlugin);
}
use of org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder in project mule by mulesoft.
the class PolicyTemplateDescriptorFactoryTestCase method readsRuntimeLibs.
@Test
public void readsRuntimeLibs() throws Exception {
MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID));
mulePolicyModelBuilder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(FILE_SYSTEM_POLICY_MODEL_LOADER_ID, emptyMap()));
PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).usingLibrary(echoTestJarFile.getAbsolutePath()).describedBy(mulePolicyModelBuilder.build());
File tempFolder = createTempFolder();
unzip(policyFileBuilder.getArtifactFile(), tempFolder);
PolicyTemplateDescriptorFactory descriptorFactory = new PolicyTemplateDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
PolicyTemplateDescriptor desc = descriptorFactory.create(tempFolder, empty());
assertThat(desc.getClassLoaderModel().getUrls().length, equalTo(2));
assertThat(toFile(desc.getClassLoaderModel().getUrls()[0]).getPath(), equalTo(tempFolder.toString()));
assertThat(toFile(desc.getClassLoaderModel().getUrls()[1]).getPath(), equalTo(new File(tempFolder, LIB_DIR + separator + JAR_FILE_NAME).toString()));
}
use of org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder 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.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder in project mule by mulesoft.
the class AbstractDeploymentTestCase method createPolicyIncludingHelloPluginV2FileBuilder.
private PolicyFileBuilder createPolicyIncludingHelloPluginV2FileBuilder() {
MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName(BAZ_POLICY_NAME).setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(BAZ_POLICY_NAME, MULE_POLICY_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID));
mulePolicyModelBuilder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
return new PolicyFileBuilder(BAZ_POLICY_NAME).describedBy(mulePolicyModelBuilder.build()).dependingOn(helloExtensionV2Plugin);
}
use of org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder in project mule by mulesoft.
the class PolicyTemplateDescriptorFactoryTestCase method detectsInvalidBundleDescriptorLoaderId.
@Test
public void detectsInvalidBundleDescriptorLoaderId() throws Exception {
MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(INVALID_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(FILE_SYSTEM_POLICY_MODEL_LOADER_ID, emptyMap()));
PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).describedBy(mulePolicyModelBuilder.build());
File tempFolder = createTempFolder();
unzip(policyFileBuilder.getArtifactFile(), tempFolder);
PolicyTemplateDescriptorFactory descriptorFactory = new PolicyTemplateDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
expectedException.expect(ArtifactDescriptorCreateException.class);
expectedException.expectMessage(invalidBundleDescriptorLoaderIdError(tempFolder, mulePolicyModelBuilder.getBundleDescriptorLoader()));
descriptorFactory.create(tempFolder, empty());
}
Aggregations