use of org.mule.runtime.core.api.policy.PolicyParametrization in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesApplicationPolicyDuplicatingPlugin.
@Test
public void appliesApplicationPolicyDuplicatingPlugin() throws Exception {
policyManager.registerPolicyTemplate(exceptionThrowingPluginImportingPolicyFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, exceptionThrowingPlugin, helloExtensionV1Plugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
policyManager.addPolicy(applicationFileBuilder.getId(), exceptionThrowingPluginImportingPolicyFileBuilder.getArtifactId(), new PolicyParametrization(EXCEPTION_POLICY_NAME, s -> true, 1, emptyMap(), getResourceFile("/exceptionThrowingPolicy.xml"), emptyList()));
try {
executeApplicationFlow("main");
fail("Flow execution was expected to throw an exception");
} catch (MuleRuntimeException expected) {
assertThat(expected.getCause().getCause().getClass().getName(), is(equalTo("org.exception.CustomException")));
}
}
use of org.mule.runtime.core.api.policy.PolicyParametrization 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.core.api.policy.PolicyParametrization in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesApplicationPolicyUsingAppPlugin.
@Test
public void appliesApplicationPolicyUsingAppPlugin() throws Exception {
policyManager.registerPolicyTemplate(policyUsingAppPluginFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
policyManager.addPolicy(applicationFileBuilder.getId(), policyUsingAppPluginFileBuilder.getArtifactId(), new PolicyParametrization(BAR_POLICY_ID, s -> true, 1, emptyMap(), getResourceFile("/appPluginPolicy.xml"), emptyList()));
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(1));
}
use of org.mule.runtime.core.api.policy.PolicyParametrization in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesApplicationPolicyUsingPluginOnlyInPolicy.
@Test
public void appliesApplicationPolicyUsingPluginOnlyInPolicy() throws Exception {
policyManager.registerPolicyTemplate(policyIncludingPluginFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_SIMPLE_EXTENSION_CONFIG, createSingleExtensionPlugin());
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
policyManager.addPolicy(applicationFileBuilder.getId(), policyIncludingPluginFileBuilder.getArtifactId(), new PolicyParametrization(BAR_POLICY_ID, s -> true, 1, emptyMap(), getResourceFile("/appPluginPolicy.xml"), emptyList()));
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(1));
}
use of org.mule.runtime.core.api.policy.PolicyParametrization in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesApplicationPolicyUsingModuleThatUsesPlugin.
@Test
public void appliesApplicationPolicyUsingModuleThatUsesPlugin() throws Exception {
PolicyFileBuilder policyIncludingByePlugin = createPolicyIncludingByePlugin();
policyManager.registerPolicyTemplate(policyIncludingByePlugin.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_SIMPLE_EXTENSION_CONFIG, createSingleExtensionPlugin());
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
policyManager.addPolicy(applicationFileBuilder.getId(), policyIncludingByePlugin.getArtifactId(), new PolicyParametrization(BAR_POLICY_ID, s -> true, 1, emptyMap(), getResourceFile("/module-using-bye-policy.xml"), emptyList()));
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(1));
}
Aggregations