Search in sources :

Example 26 with Application

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

the class ApplicationDeploymentTestCase method undeploysAppRemovesTemporaryData.

@Test
public void undeploysAppRemovesTemporaryData() throws Exception {
    addPackedAppFromBuilder(dummyAppDescriptorFileBuilder);
    startDeployment();
    assertDeploymentSuccess(applicationDeploymentListener, dummyAppDescriptorFileBuilder.getId());
    final Application app = findApp(dummyAppDescriptorFileBuilder.getId(), 1);
    File appTemporaryFolder = new File(app.getRegistry().<MuleConfiguration>lookupByName(MuleProperties.OBJECT_MULE_CONFIGURATION).get().getWorkingDirectory());
    // As this app has a plugin, the tmp directory must exist
    assertThat(appTemporaryFolder.exists(), is(true));
    // Remove the anchor file so undeployment starts
    assertTrue("Unable to remove anchor file", removeAppAnchorFile(dummyAppDescriptorFileBuilder.getId()));
    assertUndeploymentSuccess(applicationDeploymentListener, dummyAppDescriptorFileBuilder.getId());
    assertStatus(app, DESTROYED);
    // Check the tmp directory was effectively removed
    assertThat(appTemporaryFolder.exists(), is(false));
}
Also used : Application(org.mule.runtime.deployment.model.api.application.Application) FileUtils.writeStringToFile(org.apache.commons.io.FileUtils.writeStringToFile) File(java.io.File) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) Test(org.junit.Test)

Example 27 with Application

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

the class ApplicationDeploymentTestCase method undeploysApplicationRemovingAnchorFile.

@Test
public void undeploysApplicationRemovingAnchorFile() throws Exception {
    addPackedAppFromBuilder(emptyAppFileBuilder);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, emptyAppFileBuilder.getId());
    Application app = findApp(emptyAppFileBuilder.getId(), 1);
    assertTrue("Unable to remove anchor file", removeAppAnchorFile(emptyAppFileBuilder.getId()));
    assertUndeploymentSuccess(applicationDeploymentListener, emptyAppFileBuilder.getId());
    assertStatus(app, DESTROYED);
}
Also used : Application(org.mule.runtime.deployment.model.api.application.Application) Test(org.junit.Test)

Example 28 with Application

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

the class ApplicationDeploymentTestCase method undeploysAppCompletelyEvenOnStoppingException.

@Test
public void undeploysAppCompletelyEvenOnStoppingException() throws Exception {
    addPackedAppFromBuilder(emptyAppFileBuilder);
    final DefaultDomainManager domainManager = new DefaultDomainManager();
    domainManager.addDomain(createDefaultDomain());
    TestApplicationFactory appFactory = createTestApplicationFactory(new MuleApplicationClassLoaderFactory(new DefaultNativeLibraryFinderFactory()), domainManager, serviceManager, extensionModelLoaderManager, moduleRepository, createDescriptorLoaderRepository());
    appFactory.setFailOnStopApplication(true);
    deploymentService.setAppFactory(appFactory);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, emptyAppFileBuilder.getId());
    Application app = findApp(emptyAppFileBuilder.getId(), 1);
    assertTrue("Unable to remove anchor file", removeAppAnchorFile(emptyAppFileBuilder.getId()));
    assertUndeploymentSuccess(applicationDeploymentListener, emptyAppFileBuilder.getId());
    assertAppFolderIsDeleted(emptyAppFileBuilder.getId());
    assertStatus(app, DESTROYED);
}
Also used : DefaultDomainManager(org.mule.runtime.module.deployment.impl.internal.domain.DefaultDomainManager) DefaultNativeLibraryFinderFactory(org.mule.runtime.deployment.model.internal.nativelib.DefaultNativeLibraryFinderFactory) Application(org.mule.runtime.deployment.model.api.application.Application) TestApplicationFactory.createTestApplicationFactory(org.mule.runtime.module.deployment.internal.TestApplicationFactory.createTestApplicationFactory) MuleApplicationClassLoaderFactory(org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoaderFactory) Test(org.junit.Test)

Example 29 with Application

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

the class ApplicationDeploymentTestCase method deploysExplodedAppsInOrderWhenAppArgumentIsUsed.

@Test
public void deploysExplodedAppsInOrderWhenAppArgumentIsUsed() throws Exception {
    assumeThat(parallelDeployment, is(false));
    ApplicationFileBuilder appFileBuilder1 = new ApplicationFileBuilder("1").definedBy("empty-config.xml");
    addExplodedAppFromBuilder(appFileBuilder1);
    ApplicationFileBuilder appFileBuilder2 = new ApplicationFileBuilder("2").definedBy("empty-config.xml");
    addExplodedAppFromBuilder(appFileBuilder2);
    ApplicationFileBuilder appFileBuilder3 = new ApplicationFileBuilder("3").definedBy("empty-config.xml");
    addExplodedAppFromBuilder(appFileBuilder3);
    Map<String, Object> startupOptions = new HashMap<>();
    startupOptions.put("app", format("%s:%s:%s", appFileBuilder3.getId(), appFileBuilder1.getId(), appFileBuilder2.getId()));
    StartupContext.get().setStartupOptions(startupOptions);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, appFileBuilder3.getId());
    assertApplicationDeploymentSuccess(applicationDeploymentListener, appFileBuilder1.getId());
    assertApplicationDeploymentSuccess(applicationDeploymentListener, appFileBuilder2.getId());
    assertAppsDir(NONE, new String[] { appFileBuilder1.getId(), appFileBuilder2.getId(), appFileBuilder3.getId() }, true);
    // When apps are passed as -app app1:app2:app3 the startup order matters
    List<Application> applications = deploymentService.getApplications();
    assertNotNull(applications);
    assertEquals(3, applications.size());
    assertEquals(appFileBuilder3.getId(), applications.get(0).getArtifactName());
    assertEquals(appFileBuilder1.getId(), applications.get(1).getArtifactName());
    assertEquals(appFileBuilder2.getId(), applications.get(2).getArtifactName());
}
Also used : ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Application(org.mule.runtime.deployment.model.api.application.Application) Test(org.junit.Test)

Example 30 with Application

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

the class ApplicationDeploymentTestCase method deploysAppJustOnce.

@Test
public void deploysAppJustOnce() throws Exception {
    addPackedAppFromBuilder(emptyAppFileBuilder);
    Map<String, Object> startupOptions = new HashMap<>();
    String appName = "empty-app-1.0.0-mule-application";
    startupOptions.put("app", format("%s:%s:%s", appName, appName, appName));
    StartupContext.get().setStartupOptions(startupOptions);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, emptyAppFileBuilder.getId());
    assertAppsDir(NONE, new String[] { emptyAppFileBuilder.getId() }, true);
    List<Application> applications = deploymentService.getApplications();
    assertEquals(1, applications.size());
}
Also used : HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Application(org.mule.runtime.deployment.model.api.application.Application) Test(org.junit.Test)

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