Search in sources :

Example 6 with Domain

use of org.mule.runtime.deployment.model.api.domain.Domain in project mule by mulesoft.

the class DomainDeploymentTestCase method deploysDomainZipAfterStartup.

@Test
public void deploysDomainZipAfterStartup() throws Exception {
    startDeployment();
    addPackedDomainFromBuilder(emptyDomainFileBuilder);
    assertDeploymentSuccess(domainDeploymentListener, emptyDomainFileBuilder.getId());
    assertDomainDir(NONE, new String[] { DEFAULT_DOMAIN_NAME, emptyDomainFileBuilder.getId() }, true);
    final Domain domain = findADomain(emptyDomainFileBuilder.getId());
    assertNotNull(domain);
    assertNotNull(domain.getRegistry());
    assertDomainAnchorFileExists(emptyDomainFileBuilder.getId());
}
Also used : Domain(org.mule.runtime.deployment.model.api.domain.Domain) Test(org.junit.Test)

Example 7 with Domain

use of org.mule.runtime.deployment.model.api.domain.Domain in project mule by mulesoft.

the class DomainDeploymentTestCase method undeploysDomainAndDomainsApps.

@Test
public void undeploysDomainAndDomainsApps() throws Exception {
    doDomainUndeployAndVerifyAppsAreUndeployed(() -> {
        Domain domain = findADomain(dummyDomainFileBuilder.getId());
        deploymentService.undeploy(domain);
    });
}
Also used : Domain(org.mule.runtime.deployment.model.api.domain.Domain) Test(org.junit.Test)

Example 8 with Domain

use of org.mule.runtime.deployment.model.api.domain.Domain in project mule by mulesoft.

the class DomainDeploymentTestCase method refreshDomainClassloaderAfterRedeployment.

@Ignore("MULE-6926: flaky test")
@Test
public void refreshDomainClassloaderAfterRedeployment() throws Exception {
    startDeployment();
    // Deploy domain and apps and wait until success
    addPackedDomainFromBuilder(sharedDomainFileBuilder);
    addPackedAppFromBuilder(sharedAAppFileBuilder);
    addPackedAppFromBuilder(sharedBAppFileBuilder);
    assertDeploymentSuccess(domainDeploymentListener, sharedDomainFileBuilder.getId());
    assertDeploymentSuccess(applicationDeploymentListener, sharedAAppFileBuilder.getId());
    assertDeploymentSuccess(applicationDeploymentListener, sharedBAppFileBuilder.getId());
    // Ensure resources are registered at domain's registry
    Domain domain = findADomain(sharedDomainFileBuilder.getId());
    assertThat(domain.getRegistry().lookupByName("http-listener-config").isPresent(), is(true));
    ArtifactClassLoader initialArtifactClassLoader = domain.getArtifactClassLoader();
    reset(domainDeploymentListener);
    reset(applicationDeploymentListener);
    // Force redeployment by touching the domain's config file
    File domainFolder = new File(domainsDir.getPath(), sharedDomainFileBuilder.getId());
    File configFile = new File(domainFolder, sharedDomainFileBuilder.getConfigFile());
    long firstFileTimestamp = configFile.lastModified();
    touch(configFile);
    alterTimestampIfNeeded(configFile, firstFileTimestamp);
    assertUndeploymentSuccess(applicationDeploymentListener, sharedAAppFileBuilder.getId());
    assertUndeploymentSuccess(applicationDeploymentListener, sharedBAppFileBuilder.getId());
    assertUndeploymentSuccess(domainDeploymentListener, sharedDomainFileBuilder.getId());
    assertDeploymentSuccess(domainDeploymentListener, sharedDomainFileBuilder.getId());
    assertDeploymentSuccess(applicationDeploymentListener, sharedAAppFileBuilder.getId());
    assertDeploymentSuccess(applicationDeploymentListener, sharedBAppFileBuilder.getId());
    domain = findADomain(sharedDomainFileBuilder.getId());
    ArtifactClassLoader artifactClassLoaderAfterRedeployment = domain.getArtifactClassLoader();
    // Ensure that after redeployment the domain's class loader has changed
    assertThat(artifactClassLoaderAfterRedeployment, not(sameInstance(initialArtifactClassLoader)));
    // Undeploy domain and apps
    removeAppAnchorFile(sharedAAppFileBuilder.getId());
    removeAppAnchorFile(sharedBAppFileBuilder.getId());
    removeDomainAnchorFile(sharedDomainFileBuilder.getId());
    assertUndeploymentSuccess(applicationDeploymentListener, sharedAAppFileBuilder.getId());
    assertUndeploymentSuccess(applicationDeploymentListener, sharedBAppFileBuilder.getId());
    assertUndeploymentSuccess(domainDeploymentListener, sharedDomainFileBuilder.getId());
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) Domain(org.mule.runtime.deployment.model.api.domain.Domain) FileUtils.copyInputStreamToFile(org.apache.commons.io.FileUtils.copyInputStreamToFile) File(java.io.File) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with Domain

use of org.mule.runtime.deployment.model.api.domain.Domain 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);
}
Also used : Domain(org.mule.runtime.deployment.model.api.domain.Domain) Application(org.mule.runtime.deployment.model.api.application.Application)

Example 10 with Domain

use of org.mule.runtime.deployment.model.api.domain.Domain in project mule by mulesoft.

the class DomainArchiveDeployer method findApplicationsAssociated.

private Collection<Application> findApplicationsAssociated(String artifactId) {
    Domain domain = deploymentService.findDomain(artifactId);
    Preconditions.checkArgument(domain != null, String.format("Domain %s does not exists", artifactId));
    return findApplicationsAssociated(domain);
}
Also used : Domain(org.mule.runtime.deployment.model.api.domain.Domain)

Aggregations

Domain (org.mule.runtime.deployment.model.api.domain.Domain)26 Test (org.junit.Test)13 File (java.io.File)10 Application (org.mule.runtime.deployment.model.api.application.Application)9 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)7 FileUtils.copyFile (org.apache.commons.io.FileUtils.copyFile)6 FileUtils.copyInputStreamToFile (org.apache.commons.io.FileUtils.copyInputStreamToFile)6 IOException (java.io.IOException)5 URI (java.net.URI)5 Collection (java.util.Collection)5 Properties (java.util.Properties)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 FileInputStream (java.io.FileInputStream)4 URISyntaxException (java.net.URISyntaxException)4 URL (java.net.URL)4 Paths (java.nio.file.Paths)4 Collections.emptyList (java.util.Collections.emptyList)4 Collections.emptyMap (java.util.Collections.emptyMap)4 SECONDS (java.util.concurrent.TimeUnit.SECONDS)4 FileUtils.forceDelete (org.apache.commons.io.FileUtils.forceDelete)4