use of org.mule.runtime.deployment.model.api.application.Application in project mule by mulesoft.
the class DefaultArchiveDeployerTestCase method ignoresErrorsWhileRemovingArtifactDataFolder.
@Test
public void ignoresErrorsWhileRemovingArtifactDataFolder() throws Exception {
AbstractDeployableArtifactFactory artifactFactory = mock(AbstractDeployableArtifactFactory.class);
ArtifactDeployer artifactDeployer = mock(ArtifactDeployer.class);
DefaultArchiveDeployer<Application> deployer = new DefaultArchiveDeployer(artifactDeployer, artifactFactory, new ObservableList(), null, null);
deployer.setDeploymentListener(mock(DeploymentListener.class));
deployer.deployArtifact(createMockApplication(), empty());
mockStatic(FileUtils.class);
PowerMockito.doThrow(new IOException()).when(FileUtils.class);
deleteDirectory(Matchers.eq(getAppDataFolder(ARTIFACT_ID)));
deployer.undeployArtifact(ARTIFACT_ID);
}
use of org.mule.runtime.deployment.model.api.application.Application in project mule by mulesoft.
the class DefaultMuleDeployerTestCase method disposesAppOnDeployFailure.
@Test
public void disposesAppOnDeployFailure() throws Exception {
DefaultArtifactDeployer deployer = new DefaultArtifactDeployer();
Application app = mock(Application.class);
doThrow(new IllegalStateException()).when(app).init();
try {
deployer.deploy(app);
fail("Deployment is supposed to fail");
} catch (DeploymentException expected) {
}
verify(app, times(1)).dispose();
}
use of org.mule.runtime.deployment.model.api.application.Application in project mule by mulesoft.
the class DomainDeploymentTestCase method failsToApplyApplicationPolicyWithDomainPluginVersionMismatch.
@Test
public void failsToApplyApplicationPolicyWithDomainPluginVersionMismatch() throws Exception {
installEchoService();
installFooService();
policyManager.registerPolicyTemplate(policyIncludingHelloPluginV2FileBuilder.getArtifactFile());
DomainFileBuilder domainFileBuilder = new DomainFileBuilder("dummy-domain-bundle").definedBy("empty-domain-config.xml").dependingOn(helloExtensionV1Plugin);
ApplicationFileBuilder applicationFileBuilder = new ApplicationFileBuilder("dummyWithHelloExtension").definedBy(APP_WITH_EXTENSION_PLUGIN_CONFIG).dependingOn(domainFileBuilder);
addPackedDomainFromBuilder(domainFileBuilder);
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.deployment.model.api.application.Application in project mule by mulesoft.
the class DomainDeploymentTestCase method deploysDomain.
private void deploysDomain() {
assertDeploymentSuccess(domainDeploymentListener, dummyDomainBundleFileBuilder.getId());
assertDomainDir(NONE, new String[] { DEFAULT_DOMAIN_NAME, dummyDomainBundleFileBuilder.getId() }, true);
final Domain domain = findADomain(dummyDomainBundleFileBuilder.getId());
assertNotNull(domain);
assertNotNull(domain.getRegistry());
assertApplicationDeploymentSuccess(applicationDeploymentListener, dummyAppDescriptorFileBuilder.getId());
assertAppsDir(NONE, new String[] { dummyAppDescriptorFileBuilder.getId() }, true);
final Application app = findApp(dummyAppDescriptorFileBuilder.getId(), 1);
assertNotNull(app);
}
use of org.mule.runtime.deployment.model.api.application.Application in project mule by mulesoft.
the class TestPolicyManager method removePolicy.
/**
* Removes a parameterized policy
*
* @param appName application where the policy is applied. Non empty.
* @param policyId identifies the policy parametrization. Non empty.
* @return true if the poclicy was removed, false if the policy is not applied in the application.
* @throws IllegalArgumentException if the application does not exists or there is an invalid parameter value.
*/
public boolean removePolicy(String appName, String policyId) {
checkArgument(!isEmpty(appName), "appName cannot be empty");
checkArgument(!isEmpty(policyId), "policyId cannot be empty");
Application application = deploymentService.findApplication(appName);
if (application == null) {
throw new IllegalArgumentException("Cannot find application named: " + appName);
}
return application.getPolicyManager().removePolicy(policyId);
}
Aggregations