Search in sources :

Example 21 with Domain

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

the class DefaultDomainFactoryTestCase method createCustomDomain.

@Test
public void createCustomDomain() throws IOException {
    String domainName = "custom-domain";
    final DomainDescriptor descriptor = new DomainDescriptor(domainName);
    when(domainDescriptorFactory.create(any(), any())).thenReturn(descriptor);
    final MuleApplicationClassLoader domainArtifactClassLoader = mock(MuleApplicationClassLoader.class);
    when(domainArtifactClassLoader.getArtifactId()).thenReturn(domainName);
    DomainClassLoaderBuilder domainClassLoaderBuilderMock = mock(DomainClassLoaderBuilder.class);
    when(domainClassLoaderBuilderMock.setArtifactDescriptor(any())).thenReturn(domainClassLoaderBuilderMock);
    when(domainClassLoaderBuilderMock.setArtifactId(any())).thenReturn(domainClassLoaderBuilderMock);
    when(domainClassLoaderBuilderMock.addArtifactPluginDescriptors(descriptor.getPlugins().toArray(new ArtifactPluginDescriptor[0]))).thenReturn(domainClassLoaderBuilderMock);
    when(domainClassLoaderBuilderMock.build()).thenReturn(domainArtifactClassLoader);
    when(domainClassLoaderBuilderFactory.createArtifactClassLoaderBuilder()).thenReturn(domainClassLoaderBuilderMock);
    Domain domain = domainFactory.createArtifact(new File(domainName), empty());
    assertThat(domain.getArtifactName(), is(domainName));
    assertThat(domain.getDescriptor(), is(descriptor));
    assertThat(domain.getArtifactClassLoader(), is(domainArtifactClassLoader));
}
Also used : ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) DomainClassLoaderBuilder(org.mule.runtime.deployment.model.internal.domain.DomainClassLoaderBuilder) MuleApplicationClassLoader(org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoader) Domain(org.mule.runtime.deployment.model.api.domain.Domain) DomainDescriptor(org.mule.runtime.deployment.model.api.domain.DomainDescriptor) File(java.io.File) Test(org.junit.Test)

Example 22 with Domain

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

the class DomainDeploymentTestCase method deploysDomainZipOnStartup.

@Test
public void deploysDomainZipOnStartup() throws Exception {
    addPackedDomainFromBuilder(emptyDomainFileBuilder);
    startDeployment();
    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 23 with Domain

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

the class DomainDeploymentTestCase method appliesApplicationPolicyWithPluginDependingOnDomainPlugin.

@Test
public void appliesApplicationPolicyWithPluginDependingOnDomainPlugin() throws Exception {
    installEchoService();
    installFooService();
    policyManager.registerPolicyTemplate(policyIncludingDependantPluginFileBuilder.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());
    policyManager.addPolicy(applicationFileBuilder.getId(), policyIncludingPluginFileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, s -> true, 1, emptyMap(), getResourceFile("/appPluginPolicy.xml"), emptyList()));
    executeApplicationFlow("main");
    assertThat(invocationCount, equalTo(1));
}
Also used : URL(java.net.URL) Assert.assertNotSame(org.junit.Assert.assertNotSame) DEFAULT_CONFIGURATION_RESOURCE(org.mule.runtime.deployment.model.api.domain.DomainDescriptor.DEFAULT_CONFIGURATION_RESOURCE) URISyntaxException(java.net.URISyntaxException) Matchers.not(org.hamcrest.Matchers.not) ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) DESTROYED(org.mule.runtime.deployment.model.api.application.ApplicationStatus.DESTROYED) ByteArrayInputStream(java.io.ByteArrayInputStream) Is.is(org.hamcrest.core.Is.is) Assert.fail(org.junit.Assert.fail) DeploymentListener(org.mule.runtime.module.deployment.api.DeploymentListener) URI(java.net.URI) FileUtils.copyInputStreamToFile(org.apache.commons.io.FileUtils.copyInputStreamToFile) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) CompilerUtils(org.mule.tck.util.CompilerUtils) PolicyRegistrationException(org.mule.runtime.deployment.model.api.policy.PolicyRegistrationException) Domain(org.mule.runtime.deployment.model.api.domain.Domain) DomainFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) ApplicationStatus(org.mule.runtime.deployment.model.api.application.ApplicationStatus) ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) EXPORTED_CLASS_PACKAGES_PROPERTY(org.mule.runtime.container.internal.ClasspathModuleDiscoverer.EXPORTED_CLASS_PACKAGES_PROPERTY) DomainClassLoaderFactory(org.mule.runtime.deployment.model.internal.domain.DomainClassLoaderFactory) FileUtils.forceDelete(org.apache.commons.io.FileUtils.forceDelete) FileUtils.touch(org.apache.commons.io.FileUtils.touch) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) IOUtils(org.mule.runtime.core.api.util.IOUtils) Application(org.mule.runtime.deployment.model.api.application.Application) TestPolicyProcessor.invocationCount(org.mule.runtime.module.deployment.internal.TestPolicyProcessor.invocationCount) Collections.emptyMap(java.util.Collections.emptyMap) Properties(java.util.Properties) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) PolicyParametrization(org.mule.runtime.core.api.policy.PolicyParametrization) JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) IOException(java.io.IOException) Test(org.junit.Test) FileInputStream(java.io.FileInputStream) File(java.io.File) Mockito.verify(org.mockito.Mockito.verify) Mockito.never(org.mockito.Mockito.never) Ignore(org.junit.Ignore) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) Paths(java.nio.file.Paths) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) DEFAULT_DOMAIN_NAME(org.mule.runtime.deployment.model.api.domain.DomainDescriptor.DEFAULT_DOMAIN_NAME) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) Mockito.reset(org.mockito.Mockito.reset) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Assert.assertEquals(org.junit.Assert.assertEquals) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) DomainFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder) PolicyParametrization(org.mule.runtime.core.api.policy.PolicyParametrization) Test(org.junit.Test)

Example 24 with Domain

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

the class DomainDeploymentTestCase method redeployedDomainsAreDifferent.

@Test
public void redeployedDomainsAreDifferent() throws Exception {
    startDeployment();
    addPackedDomainFromBuilder(emptyDomainFileBuilder);
    File dummyDomainFile = new File(domainsDir, emptyDomainFileBuilder.getZipPath());
    long firstFileTimestamp = dummyDomainFile.lastModified();
    assertDeploymentSuccess(domainDeploymentListener, emptyDomainFileBuilder.getId());
    assertEquals("Domain has not been properly registered with Mule", 2, deploymentService.getDomains().size());
    Domain firstDomain = findADomain(emptyDomainFileBuilder.getId());
    reset(domainDeploymentListener);
    addPackedDomainFromBuilder(emptyDomainFileBuilder);
    alterTimestampIfNeeded(dummyDomainFile, firstFileTimestamp);
    assertDomainRedeploymentSuccess(emptyDomainFileBuilder.getId());
    assertEquals("Domain has not been properly registered with Mule", 2, deploymentService.getDomains().size());
    Domain secondDomain = findADomain(emptyDomainFileBuilder.getId());
    assertNotSame(firstDomain, secondDomain);
}
Also used : 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) Test(org.junit.Test)

Example 25 with Domain

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

the class DomainDeploymentTestCase method undeploysStoppedDomain.

@Test
public void undeploysStoppedDomain() throws Exception {
    addPackedDomainFromBuilder(emptyDomainFileBuilder);
    startDeployment();
    assertDeploymentSuccess(domainDeploymentListener, emptyDomainFileBuilder.getId());
    final Domain domain = findADomain(emptyDomainFileBuilder.getId());
    domain.stop();
    deploymentService.undeploy(domain);
}
Also used : Domain(org.mule.runtime.deployment.model.api.domain.Domain) Test(org.junit.Test)

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