use of org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder 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.module.deployment.impl.internal.builder.PolicyFileBuilder 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.module.deployment.impl.internal.builder.PolicyFileBuilder 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.module.deployment.impl.internal.builder.PolicyFileBuilder 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.module.deployment.impl.internal.builder.PolicyFileBuilder in project mule by mulesoft.
the class PolicyTemplateDescriptorFactoryTestCase method verifiesThatPolicyDescriptorIsPresent.
@Test
public void verifiesThatPolicyDescriptorIsPresent() throws Exception {
PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).usingLibrary(echoTestJarFile.getAbsolutePath());
File tempFolder = createTempFolder();
unzip(policyFileBuilder.getArtifactFile(), tempFolder);
PolicyTemplateDescriptorFactory descriptorFactory = new PolicyTemplateDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
expectedException.expect(ArtifactDescriptorCreateException.class);
expectedException.expectMessage(allOf(containsString(ARTIFACT_DESCRIPTOR_DOES_NOT_EXISTS_ERROR), containsString(MULE_ARTIFACT_JSON_DESCRIPTOR_LOCATION)));
descriptorFactory.create(tempFolder, empty());
}
Aggregations