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));
}
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());
}
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));
}
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);
}
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);
}
Aggregations