Search in sources :

Example 6 with DomainFileBuilder

use of org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder in project mule by mulesoft.

the class DomainDeploymentTestCase method deploysDomainWithSharedLibPrecedenceOverApplicationSharedLib.

@Test
public void deploysDomainWithSharedLibPrecedenceOverApplicationSharedLib() throws Exception {
    final String domainId = "shared-lib";
    final DomainFileBuilder domainFileBuilder = new DomainFileBuilder(domainId).dependingOnSharedLibrary(new JarFileBuilder("barUtils1", barUtils1_0JarFile)).definedBy("empty-domain-config.xml");
    final ApplicationFileBuilder applicationFileBuilder = new ApplicationFileBuilder("shared-lib-precedence-app").definedBy("app-shared-lib-precedence-config.xml").dependingOnSharedLibrary(new JarFileBuilder("barUtils2", barUtils2_0JarFile)).containingClass(pluginEcho1TestClassFile, "org/foo/Plugin1Echo.class").dependingOn(domainFileBuilder);
    addPackedDomainFromBuilder(domainFileBuilder);
    addPackedAppFromBuilder(applicationFileBuilder);
    startDeployment();
    assertDeploymentSuccess(domainDeploymentListener, domainFileBuilder.getId());
    assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
    executeApplicationFlow("main");
}
Also used : ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) DomainFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder) Test(org.junit.Test)

Example 7 with DomainFileBuilder

use of org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder in project mule by mulesoft.

the class DomainDeploymentTestCase method deploysInvalidExplodedDomainOnlyOnce.

@Test
public void deploysInvalidExplodedDomainOnlyOnce() throws Exception {
    startDeployment();
    addExplodedDomainFromBuilder(emptyDomainFileBuilder, "domain with spaces");
    assertDeploymentFailure(domainDeploymentListener, "domain with spaces", times(1));
    addExplodedDomainFromBuilder(emptyDomainFileBuilder);
    assertDeploymentSuccess(domainDeploymentListener, emptyDomainFileBuilder.getId());
    DomainFileBuilder updatedDomainFileBuilder = new DomainFileBuilder("empty2-domain", emptyDomainFileBuilder);
    addExplodedDomainFromBuilder(updatedDomainFileBuilder);
    assertDeploymentSuccess(domainDeploymentListener, updatedDomainFileBuilder.getId());
    // After three update cycles should have only one deployment failure notification for the broken app
    assertDeploymentFailure(domainDeploymentListener, "domain with spaces");
}
Also used : DomainFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder) Test(org.junit.Test)

Example 8 with DomainFileBuilder

use of org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder in project mule by mulesoft.

the class DomainDeploymentTestCase method deploysAppUsingDomainExtensionWithSharedExtension.

@Test
public void deploysAppUsingDomainExtensionWithSharedExtension() throws Exception {
    installEchoService();
    installFooService();
    DomainFileBuilder domainFileBuilder = new DomainFileBuilder("hello-domain-bundle").definedBy("hello-domain-config.xml").dependingOn(helloExtensionV1Plugin);
    ApplicationFileBuilder applicationFileBuilder = new ApplicationFileBuilder("appWithSharedHelloExtension").definedBy(APP_WITH_SHARED_EXTENSION_PLUGIN_CONFIG).dependingOn(domainFileBuilder);
    addPackedDomainFromBuilder(domainFileBuilder);
    addPackedAppFromBuilder(applicationFileBuilder);
    startDeployment();
    assertDeploymentSuccess(domainDeploymentListener, domainFileBuilder.getId());
    assertDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
    executeApplicationFlow("main");
}
Also used : ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) DomainFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder) Test(org.junit.Test)

Example 9 with DomainFileBuilder

use of org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder in project mule by mulesoft.

the class DomainDeploymentTestCase method failsToApplyApplicationPolicyWithDomainPluginVersionMismatch.

@Test
public void failsToApplyApplicationPolicyWithDomainPluginVersionMismatch() throws Exception {
    installEchoService();
    installFooService();
    policyManager.registerPolicyTemplate(policyIncludingHelloPluginV2FileBuilder.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());
    try {
        policyManager.addPolicy(applicationFileBuilder.getId(), policyIncludingHelloPluginV2FileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, s -> true, 1, emptyMap(), getResourceFile("/appPluginPolicy.xml"), emptyList()));
        fail("Policy application should have failed");
    } catch (PolicyRegistrationException expected) {
    }
}
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) PolicyRegistrationException(org.mule.runtime.deployment.model.api.policy.PolicyRegistrationException) DomainFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder) PolicyParametrization(org.mule.runtime.core.api.policy.PolicyParametrization) Test(org.junit.Test)

Example 10 with DomainFileBuilder

use of org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder in project mule by mulesoft.

the class DomainDeploymentTestCase method deploysAppWithPluginDependingOnDomainPlugin.

@Test
public void deploysAppWithPluginDependingOnDomainPlugin() throws Exception {
    DomainFileBuilder domainFileBuilder = new DomainFileBuilder("dummy-domain-bundle").definedBy("empty-domain-config.xml").dependingOn(echoPlugin);
    ArtifactPluginFileBuilder dependantPlugin = new ArtifactPluginFileBuilder("dependantPlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo.echo").containingClass(new CompilerUtils.SingleClassCompiler().compile(getResourceFile("/org/foo/echo/Plugin3Echo.java")), "org/foo/echo/Plugin3Echo.class").dependingOn(echoPlugin);
    ApplicationFileBuilder echoPluginAppFileBuilder = new ApplicationFileBuilder("dummyWithEchoPlugin").definedBy("app-with-echo-plugin-config.xml").dependingOn(domainFileBuilder).dependingOn(dependantPlugin);
    addPackedDomainFromBuilder(domainFileBuilder);
    addPackedAppFromBuilder(echoPluginAppFileBuilder);
    startDeployment();
    assertDeploymentSuccess(domainDeploymentListener, domainFileBuilder.getId());
    assertDeploymentSuccess(applicationDeploymentListener, echoPluginAppFileBuilder.getId());
    executeApplicationFlow("main");
}
Also used : ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) CompilerUtils(org.mule.tck.util.CompilerUtils) DomainFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder) Test(org.junit.Test)

Aggregations

DomainFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder)17 Test (org.junit.Test)16 ApplicationFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder)14 JarFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 File (java.io.File)5 FileInputStream (java.io.FileInputStream)5 FileUtils.copyFile (org.apache.commons.io.FileUtils.copyFile)5 FileUtils.copyInputStreamToFile (org.apache.commons.io.FileUtils.copyInputStreamToFile)5 Ignore (org.junit.Ignore)5 ArtifactPluginFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder)5 IOException (java.io.IOException)4 URI (java.net.URI)4 URISyntaxException (java.net.URISyntaxException)4 URL (java.net.URL)4 Paths (java.nio.file.Paths)4 Collection (java.util.Collection)4 Collections.emptyList (java.util.Collections.emptyList)4 Collections.emptyMap (java.util.Collections.emptyMap)4 Properties (java.util.Properties)4