Search in sources :

Example 31 with Application

use of org.mule.runtime.deployment.model.api.application.Application in project mule by mulesoft.

the class DomainArchiveDeployer method undeployArtifact.

/**
 * Undeploys a domain.
 * <p/>
 * Before undeploying the domain it undeploys the applications associated.
 *
 * @param artifactId domain name to undeploy
 */
@Override
public void undeployArtifact(String artifactId) {
    Collection<Application> domainApplications = findApplicationsAssociated(artifactId);
    for (Application domainApplication : domainApplications) {
        applicationDeployer.undeployArtifact(domainApplication.getArtifactName());
    }
    domainDeployer.undeployArtifact(artifactId);
}
Also used : Application(org.mule.runtime.deployment.model.api.application.Application)

Example 32 with Application

use of org.mule.runtime.deployment.model.api.application.Application in project mule by mulesoft.

the class DefaultArchiveDeployerTestCase method createMockApplication.

private Application createMockApplication() {
    Application artifact = mock(Application.class);
    ApplicationDescriptor descriptor = mock(ApplicationDescriptor.class);
    when(descriptor.getDataFolderName()).thenReturn(ARTIFACT_ID);
    when(artifact.getDescriptor()).thenReturn(descriptor);
    when(artifact.getArtifactName()).thenReturn(ARTIFACT_ID);
    return artifact;
}
Also used : Application(org.mule.runtime.deployment.model.api.application.Application) ApplicationDescriptor(org.mule.runtime.deployment.model.api.application.ApplicationDescriptor)

Example 33 with Application

use of org.mule.runtime.deployment.model.api.application.Application in project mule by mulesoft.

the class DomainDeploymentTestCase method doRedeployBrokenDomainAfterFixedDomain.

/**
 * After a successful deploy using the {@link DomainDeploymentTestCase#domainDeploymentListener}, this method deploys a domain
 * zip with the same name and a wrong configuration. Applications dependant of the domain should not be deleted after this
 * failure full redeploy.
 */
private void doRedeployBrokenDomainAfterFixedDomain() throws Exception {
    assertApplicationAnchorFileExists(dummyAppDescriptorFileBuilder.getId());
    reset(domainDeploymentListener);
    DomainFileBuilder domainBundleWrongFullRedeploy = new DomainFileBuilder("dummy-domain-bundle").definedBy("incomplete-domain-config.xml");
    addPackedDomainFromBuilder(domainBundleWrongFullRedeploy);
    assertDeploymentFailure(domainDeploymentListener, domainBundleWrongFullRedeploy.getId());
    assertThat(undeployLatch.await(5000, SECONDS), is(true));
    assertApplicationAnchorFileExists(dummyAppDescriptorFileBuilder.getId());
    Application dependantApplication = deploymentService.getApplications().get(0);
    assertThat(dependantApplication, is(notNullValue()));
    assertThat(dependantApplication.getStatus(), is(DESTROYED));
}
Also used : DomainFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder) Application(org.mule.runtime.deployment.model.api.application.Application)

Example 34 with Application

use of org.mule.runtime.deployment.model.api.application.Application in project mule by mulesoft.

the class TestApplicationFactory method createArtifact.

@Override
public Application createArtifact(File appLocation, Optional<Properties> appProperties) throws IOException {
    Application app = super.createArtifact(appLocation, appProperties);
    TestApplicationWrapper testApplicationWrapper = new TestApplicationWrapper(app);
    testApplicationWrapper.setFailOnDisposeApplication(failOnDisposeApplication);
    testApplicationWrapper.setFailOnStopApplication(failOnStopApplication);
    return testApplicationWrapper;
}
Also used : TestApplicationWrapper(org.mule.runtime.module.deployment.impl.internal.application.TestApplicationWrapper) Application(org.mule.runtime.deployment.model.api.application.Application)

Example 35 with Application

use of org.mule.runtime.deployment.model.api.application.Application in project mule by mulesoft.

the class TestPolicyManager method addPolicy.

/**
 * Adds a parameterized policy
 *
 * @param appName application where the policy must be applied. Non empty.
 * @param policyTemplateName template that must be used to instantiate the parametrized policy. Non empty.
 * @param policyParametrization parametrization to instantiate the policy. Non null.
 */
public void addPolicy(String appName, String policyTemplateName, PolicyParametrization policyParametrization) throws PolicyRegistrationException {
    checkArgument(!isEmpty(appName), "appName cannot be empty");
    checkArgument(!isEmpty(policyTemplateName), "policyTemplateName cannot be empty");
    checkArgument(policyParametrization != null, "policyParametrization cannot be ull");
    Optional<PolicyTemplateDescriptor> policyTemplateDescriptor = policyTemplateDescriptors.stream().filter(template -> template.getName().equals(policyTemplateName)).findFirst();
    if (!policyTemplateDescriptor.isPresent()) {
        throw new IllegalStateException("Cannot find policy template descriptor with name: " + policyTemplateName);
    }
    Application application = deploymentService.findApplication(appName);
    ApplicationPolicyManager policyManager = application.getPolicyManager();
    policyManager.addPolicy(policyTemplateDescriptor.get(), policyParametrization);
}
Also used : DeploymentService(org.mule.runtime.module.deployment.api.DeploymentService) Optional.empty(java.util.Optional.empty) PolicyTemplateDescriptorFactory(org.mule.runtime.module.deployment.impl.internal.policy.PolicyTemplateDescriptorFactory) ApplicationPolicyManager(org.mule.runtime.deployment.model.api.application.ApplicationPolicyManager) Preconditions.checkArgument(org.mule.runtime.api.util.Preconditions.checkArgument) PolicyParametrization(org.mule.runtime.core.api.policy.PolicyParametrization) IOException(java.io.IOException) PolicyRegistrationException(org.mule.runtime.deployment.model.api.policy.PolicyRegistrationException) File(java.io.File) ArrayList(java.util.ArrayList) FilenameUtils.getBaseName(org.apache.commons.io.FilenameUtils.getBaseName) PolicyTemplateDescriptor(org.mule.runtime.deployment.model.api.policy.PolicyTemplateDescriptor) List(java.util.List) FileUtils.unzip(org.mule.runtime.core.api.util.FileUtils.unzip) MuleFoldersUtil.getExecutionFolder(org.mule.runtime.container.api.MuleFoldersUtil.getExecutionFolder) Optional(java.util.Optional) DeploymentListener(org.mule.runtime.module.deployment.api.DeploymentListener) Application(org.mule.runtime.deployment.model.api.application.Application) StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.isEmpty) ApplicationPolicyManager(org.mule.runtime.deployment.model.api.application.ApplicationPolicyManager) PolicyTemplateDescriptor(org.mule.runtime.deployment.model.api.policy.PolicyTemplateDescriptor) Application(org.mule.runtime.deployment.model.api.application.Application)

Aggregations

Application (org.mule.runtime.deployment.model.api.application.Application)35 Test (org.junit.Test)19 File (java.io.File)7 Domain (org.mule.runtime.deployment.model.api.domain.Domain)6 ApplicationFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder)6 Matchers.containsString (org.hamcrest.Matchers.containsString)5 IOException (java.io.IOException)4 FileUtils.copyFile (org.apache.commons.io.FileUtils.copyFile)4 PolicyParametrization (org.mule.runtime.core.api.policy.PolicyParametrization)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Optional (java.util.Optional)3 ApplicationDescriptor (org.mule.runtime.deployment.model.api.application.ApplicationDescriptor)3 PolicyRegistrationException (org.mule.runtime.deployment.model.api.policy.PolicyRegistrationException)3 DeploymentListener (org.mule.runtime.module.deployment.api.DeploymentListener)3 URI (java.net.URI)2 Collection (java.util.Collection)2 List (java.util.List)2 Optional.empty (java.util.Optional.empty)2 FileUtils.writeStringToFile (org.apache.commons.io.FileUtils.writeStringToFile)2