use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method redeployPolicyWithSecurityManagerDefined.
@Test
public void redeployPolicyWithSecurityManagerDefined() throws Exception {
ArtifactPluginFileBuilder simpleExtensionPlugin = createSingleExtensionPlugin();
policyManager.registerPolicyTemplate(policyWithPluginAndResource().getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_SIMPLE_EXTENSION_CONFIG, simpleExtensionPlugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
PolicyParametrization policy = new PolicyParametrization(BAR_POLICY_ID, s -> true, 1, emptyMap(), getResourceFile("/policy-using-security-manager.xml"), emptyList());
policyManager.addPolicy(applicationFileBuilder.getId(), policyIncludingPluginFileBuilder.getArtifactId(), policy);
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(1));
policyManager.removePolicy(applicationFileBuilder.getId(), BAR_POLICY_ID);
policyManager.addPolicy(applicationFileBuilder.getId(), policyIncludingPluginFileBuilder.getArtifactId(), policy);
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(2));
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesMultipleApplicationPolicies.
@Test
public void appliesMultipleApplicationPolicies() throws Exception {
policyManager.registerPolicyTemplate(fooPolicyFileBuilder.getArtifactFile());
policyManager.registerPolicyTemplate(barPolicyFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
policyManager.addPolicy(applicationFileBuilder.getId(), fooPolicyFileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, pointparameters -> true, 1, singletonMap(POLICY_PROPERTY_KEY, POLICY_PROPERTY_VALUE), getResourceFile("/fooPolicy.xml"), emptyList()));
policyManager.addPolicy(applicationFileBuilder.getId(), barPolicyFileBuilder.getArtifactId(), new PolicyParametrization(BAR_POLICY_ID, poinparameters -> true, 2, emptyMap(), getResourceFile("/barPolicy.xml"), emptyList()));
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(2));
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesApplicationPolicyDuplicatingPluginOnDomain.
@Test
public void appliesApplicationPolicyDuplicatingPluginOnDomain() throws Exception {
addPackedDomainFromBuilder(exceptionThrowingPluginImportingDomain);
policyManager.registerPolicyTemplate(exceptionThrowingPluginImportingPolicyFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin).dependingOn(exceptionThrowingPluginImportingDomain);
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.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method removesApplicationPolicy.
@Test
public void removesApplicationPolicy() throws Exception {
policyManager.registerPolicyTemplate(fooPolicyFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
policyManager.addPolicy(applicationFileBuilder.getId(), fooPolicyFileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, parameters -> true, 1, singletonMap(POLICY_PROPERTY_KEY, POLICY_PROPERTY_VALUE), getResourceFile("/fooPolicy.xml"), emptyList()));
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(1));
policyManager.removePolicy(applicationFileBuilder.getId(), FOO_POLICY_ID);
executeApplicationFlow("main");
assertThat("Policy is still applied on the application", invocationCount, equalTo(1));
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesPolicyThatUsesPolicyClassOnExpression.
@Test
public void appliesPolicyThatUsesPolicyClassOnExpression() throws Exception {
ArtifactPluginFileBuilder simpleExtensionPlugin = createSingleExtensionPlugin();
policyManager.registerPolicyTemplate(policyWithPluginAndResource().getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_SIMPLE_EXTENSION_CONFIG, simpleExtensionPlugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
policyManager.addPolicy(applicationFileBuilder.getId(), policyIncludingPluginFileBuilder.getArtifactId(), new PolicyParametrization(BAR_POLICY_ID, s -> true, 1, emptyMap(), getResourceFile("/policy-using-policy-class-in-expression.xml"), emptyList()));
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(1));
}
Aggregations