use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.
the class AbstractDeploymentTestCase method createByeXmlPluginFileBuilder.
private ArtifactPluginFileBuilder createByeXmlPluginFileBuilder() {
final String prefixModuleName = "module-bye";
String extensionName = "bye-extension";
final String resources = "org/mule/module/";
String moduleDestination = resources + prefixModuleName + ".xml";
MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder().setName(extensionName).setMinMuleVersion(MIN_MULE_VERSION);
builder.withExtensionModelDescriber().setId(XmlExtensionModelLoader.DESCRIBER_ID).addProperty(RESOURCE_XML, moduleDestination);
builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
builder.withBundleDescriptorLoader(createBundleDescriptorLoader(extensionName, MULE_EXTENSION_CLASSIFIER, MULE_LOADER_ID));
builder.setRequiredProduct(MULE).setMinMuleVersion(MIN_MULE_VERSION);
return new ArtifactPluginFileBuilder(extensionName).containingResource("module-byeSource.xml", moduleDestination).containingResource("module-using-bye-catalogSource.xml", resources + prefixModuleName + "-catalog.xml").containingResource("module-bye-type-schemaSource.json", resources + "type1-schema.json").containingResource("module-bye-type-schemaSource.json", resources + "inner/folder/type2-schema.json").containingResource("module-bye-type-schemaSource.json", "org/mule/type3-schema.json").describedBy(builder.build());
}
use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method failsToApplyBrokenApplicationPolicy.
@Test
public void failsToApplyBrokenApplicationPolicy() throws Exception {
PolicyFileBuilder brokenPolicyFileBuilder = new PolicyFileBuilder(BAR_POLICY_NAME).describedBy(new MulePolicyModel.MulePolicyModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName(BAR_POLICY_NAME).setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(BAR_POLICY_NAME, MULE_POLICY_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap())).build());
policyManager.registerPolicyTemplate(brokenPolicyFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
try {
policyManager.addPolicy(applicationFileBuilder.getId(), brokenPolicyFileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, parameters -> true, 1, emptyMap(), getResourceFile("/brokenPolicy.xml"), emptyList()));
fail("Policy application should have failed");
} catch (PolicyRegistrationException expected) {
}
}
use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor 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());
}
use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.
the class PolicyTemplateDescriptorFactoryTestCase method detectsInvalidClassLoaderModelLoaderId.
@Test
public void detectsInvalidClassLoaderModelLoaderId() throws Exception {
MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(INVALID_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(invalidClassLoaderModelIdError(tempFolder, mulePolicyModelBuilder.getClassLoaderModelDescriptorLoader()));
descriptorFactory.create(tempFolder, empty());
}
use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.
the class PolicyTemplateDescriptorFactoryTestCase method assignsBundleDescriptor.
@Test
public void assignsBundleDescriptor() throws Exception {
MulePolicyModelBuilder mulePolicyModelBuilder = 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()));
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.getBundleDescriptor().getArtifactId(), equalTo(POLICY_NAME));
assertThat(desc.getBundleDescriptor().getGroupId(), equalTo(POLICY_GROUP_ID));
assertThat(desc.getBundleDescriptor().getClassifier().get(), equalTo(POLICY_CLASSIFIER));
assertThat(desc.getBundleDescriptor().getType(), equalTo(POLICY_ARTIFACT_TYPE));
assertThat(desc.getBundleDescriptor().getVersion(), equalTo(POLICY_VERSION));
}
Aggregations