use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method doApplicationPolicyExecutionTest.
private void doApplicationPolicyExecutionTest(PolicyPointcut pointcut, int expectedPolicyInvocations, Object expectedPolicyParametrization) 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, pointcut, 1, singletonMap(POLICY_PROPERTY_KEY, POLICY_PROPERTY_VALUE), getResourceFile("/fooPolicy.xml"), emptyList()));
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(expectedPolicyInvocations));
assertThat(policyParametrization, equalTo(expectedPolicyParametrization));
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesApplicationPolicyDuplicatingExtensionPlugin.
@Test
public void appliesApplicationPolicyDuplicatingExtensionPlugin() throws Exception {
policyManager.registerPolicyTemplate(policyIncludingPluginFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
policyManager.addPolicy(applicationFileBuilder.getId(), policyIncludingPluginFileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, s -> true, 1, emptyMap(), getResourceFile("/appPluginPolicy.xml"), emptyList()));
executeApplicationFlow("main");
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method failsToApplyApplicationPolicyWithPluginVersionMismatch.
@Test
public void failsToApplyApplicationPolicyWithPluginVersionMismatch() throws Exception {
policyManager.registerPolicyTemplate(policyIncludingHelloPluginV2FileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
try {
policyManager.addPolicy(applicationFileBuilder.getId(), policyIncludingHelloPluginV2FileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, s -> true, 1, emptyMap(), getResourceFile("/appPluginPolicy.xml"), emptyList()));
fail("Policy application should have failed");
} catch (PolicyRegistrationException expected) {
}
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class DomainBundleDeploymentTestCase method redeploysDomainBundleCausesUndeployOfRemovedApps.
@Test
public void redeploysDomainBundleCausesUndeployOfRemovedApps() throws Exception {
ApplicationFileBuilder applicationFileBuilder1 = new ApplicationFileBuilder(dummyAppDescriptorFileBuilder).dependingOn(dummyDomainFileBuilder);
ApplicationFileBuilder applicationFileBuilder2 = new ApplicationFileBuilder(emptyAppFileBuilder).dependingOn(dummyDomainFileBuilder);
DomainBundleFileBuilder domainBundleFileBuilder = new DomainBundleFileBuilder(dummyDomainFileBuilder).containing(applicationFileBuilder1).containing(applicationFileBuilder2);
addDomainBundleFromBuilder(domainBundleFileBuilder);
startDeployment();
assertDeploymentSuccess(domainBundleDeploymentListener, domainBundleFileBuilder.getId());
assertDeploymentSuccess(domainDeploymentListener, dummyDomainFileBuilder.getId());
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder1.getId());
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder2.getId());
reset(domainDeploymentListener);
reset(domainBundleDeploymentListener);
reset(applicationDeploymentListener);
domainBundleFileBuilder = new DomainBundleFileBuilder(dummyDomainFileBuilder).containing(applicationFileBuilder1);
addDomainBundleFromBuilder(domainBundleFileBuilder);
assertDeploymentSuccess(domainBundleDeploymentListener, domainBundleFileBuilder.getId());
assertDomainRedeploymentSuccess(dummyDomainFileBuilder.getId());
assertApplicationRedeploymentSuccess(applicationFileBuilder1.getId());
assertApplicationMissingOnBundleRedeployment(applicationFileBuilder2.getId());
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class DomainBundleDeploymentTestCase method redeploysDomainBundleWithBrokenDomain.
@Test
public void redeploysDomainBundleWithBrokenDomain() throws Exception {
ApplicationFileBuilder applicationFileBuilder = new ApplicationFileBuilder(dummyAppDescriptorFileBuilder).dependingOn(dummyDomainFileBuilder);
DomainBundleFileBuilder domainBundleFileBuilder = new DomainBundleFileBuilder(dummyDomainFileBuilder).containing(applicationFileBuilder);
addDomainBundleFromBuilder(domainBundleFileBuilder);
startDeployment();
assertDeploymentSuccess(domainBundleDeploymentListener, domainBundleFileBuilder.getId());
assertDeploymentSuccess(domainDeploymentListener, dummyDomainFileBuilder.getId());
assertApplicationDeploymentSuccess(applicationDeploymentListener, dummyAppDescriptorFileBuilder.getId());
reset(domainDeploymentListener);
reset(domainBundleDeploymentListener);
reset(applicationDeploymentListener);
dummyDomainFileBuilder = new DomainFileBuilder(dummyDomainFileBuilder).corrupted();
domainBundleFileBuilder = new DomainBundleFileBuilder(dummyDomainFileBuilder).containing(applicationFileBuilder);
addDomainBundleFromBuilder(domainBundleFileBuilder);
assertDeploymentFailure(domainBundleDeploymentListener, domainBundleFileBuilder.getId());
assertDomainRedeploymentFailure(dummyDomainFileBuilder.getId());
assertRedeploymentFailure(applicationDeploymentListener, dummyAppDescriptorFileBuilder.getId());
assertThat(deploymentService.findApplication(dummyAppDescriptorFileBuilder.getId()), is(nullValue()));
}
Aggregations