Search in sources :

Example 41 with ApplicationFileBuilder

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

the class ApplicationDeploymentTestCase method deployAppNameWithZipSuffix.

@Test
public void deployAppNameWithZipSuffix() throws Exception {
    final ApplicationFileBuilder applicationFileBuilder = new ApplicationFileBuilder("empty-app.jar", emptyAppFileBuilder);
    addPackedAppFromBuilder(applicationFileBuilder);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
    reset(applicationDeploymentListener);
    assertAppsDir(NONE, new String[] { applicationFileBuilder.getDeployedPath() }, true);
    assertEquals("Application has not been properly registered with Mule", 1, deploymentService.getApplications().size());
    // Checks that the empty-app.zip folder is not processed as a zip file
    assertNoDeploymentInvoked(applicationDeploymentListener);
}
Also used : ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) Test(org.junit.Test)

Example 42 with ApplicationFileBuilder

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

the class ApplicationDeploymentTestCase method failsToDeployApplicationWithPluginDependantOnPluginNotShipped.

@Test
public void failsToDeployApplicationWithPluginDependantOnPluginNotShipped() throws Exception {
    ArtifactPluginFileBuilder dependantPlugin = new ArtifactPluginFileBuilder("dependantPlugin").dependingOn(echoPlugin);
    final TestArtifactDescriptor artifactFileBuilder = new ApplicationFileBuilder("plugin-depending-on-plugin-app").definedBy("plugin-depending-on-plugin-app-config.xml").dependingOn(dependantPlugin);
    addPackedAppFromBuilder(artifactFileBuilder);
    startDeployment();
    assertDeploymentFailure(applicationDeploymentListener, artifactFileBuilder.getId(), times(1));
}
Also used : ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) TestArtifactDescriptor(org.mule.runtime.module.artifact.builder.TestArtifactDescriptor) Test(org.junit.Test)

Example 43 with ApplicationFileBuilder

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

the class ApplicationDeploymentTestCase method deploysWithExtensionXmlPluginWithDependencies.

@Test
public void deploysWithExtensionXmlPluginWithDependencies() throws Exception {
    String moduleFileName = "module-using-java.xml";
    String extensionName = "using-java-extension";
    String moduleDestination = "org/mule/module/" + moduleFileName;
    MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder().setName(extensionName).setMinMuleVersion(MIN_MULE_VERSION).setRequiredProduct(MULE);
    builder.withExtensionModelDescriber().setId(XmlExtensionModelLoader.DESCRIBER_ID).addProperty(RESOURCE_XML, moduleDestination);
    builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().addProperty(EXPORTED_PACKAGES, asList("org.foo")).setId(MULE_LOADER_ID).build());
    builder.withBundleDescriptorLoader(createBundleDescriptorLoader(extensionName, MULE_EXTENSION_CLASSIFIER, MULE_LOADER_ID));
    builder.setRequiredProduct(MULE).setMinMuleVersion(MIN_MULE_VERSION);
    final ArtifactPluginFileBuilder byeXmlExtensionPlugin = new ArtifactPluginFileBuilder(extensionName).describedBy(builder.build()).containingResource("module-using-javaSource.xml", moduleDestination).dependingOn(new JarFileBuilder("echoTestJar", echoTestJarFile)).describedBy(builder.build());
    ApplicationFileBuilder applicationFileBuilder = new ApplicationFileBuilder("appWithExtensionXmlPluginWithDependencies").definedBy("app-with-extension-xml-plugin-module-using-java.xml").dependingOn(byeXmlExtensionPlugin);
    addPackedAppFromBuilder(applicationFileBuilder);
    final DefaultDomainManager domainManager = new DefaultDomainManager();
    domainManager.addDomain(createDefaultDomain());
    TestApplicationFactory appFactory = createTestApplicationFactory(new MuleApplicationClassLoaderFactory(new DefaultNativeLibraryFinderFactory()), domainManager, serviceManager, extensionModelLoaderManager, moduleRepository, createDescriptorLoaderRepository());
    deploymentService.setAppFactory(appFactory);
    startDeployment();
    assertDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
}
Also used : ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) DefaultDomainManager(org.mule.runtime.module.deployment.impl.internal.domain.DefaultDomainManager) MuleArtifactLoaderDescriptorBuilder(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder) JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) MulePluginModel(org.mule.runtime.api.deployment.meta.MulePluginModel) DefaultNativeLibraryFinderFactory(org.mule.runtime.deployment.model.internal.nativelib.DefaultNativeLibraryFinderFactory) Matchers.containsString(org.hamcrest.Matchers.containsString) TestApplicationFactory.createTestApplicationFactory(org.mule.runtime.module.deployment.internal.TestApplicationFactory.createTestApplicationFactory) MuleApplicationClassLoaderFactory(org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoaderFactory) Test(org.junit.Test)

Example 44 with ApplicationFileBuilder

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

the class ApplicationDeploymentTestCase method deploysAppWithLibDifferentThanPlugin.

@Test
public void deploysAppWithLibDifferentThanPlugin() throws Exception {
    final ApplicationFileBuilder differentLibPluginAppFileBuilder = new ApplicationFileBuilder("appWithLibDifferentThanPlugin").definedBy("app-plugin-different-lib-config.xml").dependingOn(echoPluginWithLib1).dependingOn(new JarFileBuilder("barUtils2_0", barUtils2_0JarFile)).containingClass(pluginEcho2TestClassFile, "org/foo/echo/Plugin2Echo.class");
    addPackedAppFromBuilder(differentLibPluginAppFileBuilder);
    startDeployment();
    assertDeploymentSuccess(applicationDeploymentListener, differentLibPluginAppFileBuilder.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) Test(org.junit.Test)

Example 45 with ApplicationFileBuilder

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

the class ApplicationDeploymentTestCase method appHomePropertyIsPresent.

@Test
public void appHomePropertyIsPresent() throws Exception {
    final ApplicationFileBuilder globalPropertyAppFileBuilder = new ApplicationFileBuilder("property-app").definedBy("app-properties-config.xml");
    addExplodedAppFromBuilder(globalPropertyAppFileBuilder);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, globalPropertyAppFileBuilder.getId());
    final Application app = findApp(globalPropertyAppFileBuilder.getId(), 1);
    Optional<ConfigurationProperties> configurationProperties = app.getRegistry().lookupByType(ConfigurationProperties.class);
    assertThat(configurationProperties.isPresent(), is(true));
    String appHome = configurationProperties.get().resolveStringProperty("appHome").orElseThrow(() -> new RuntimeException("Could not find property appHome"));
    assertThat(new File(appHome).exists(), is(true));
}
Also used : ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) ConfigurationProperties(org.mule.runtime.api.component.ConfigurationProperties) Matchers.containsString(org.hamcrest.Matchers.containsString) 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)

Aggregations

ApplicationFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder)74 Test (org.junit.Test)72 ArtifactPluginFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder)43 JarFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder)32 File (java.io.File)25 PolicyParametrization (org.mule.runtime.core.api.policy.PolicyParametrization)21 CompilerUtils (org.mule.tck.util.CompilerUtils)21 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)20 URISyntaxException (java.net.URISyntaxException)19 Collections.emptyList (java.util.Collections.emptyList)19 Collections.emptyMap (java.util.Collections.emptyMap)19 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)19 Matchers.equalTo (org.hamcrest.Matchers.equalTo)19 Is.is (org.hamcrest.core.Is.is)19 Assert.fail (org.junit.Assert.fail)19 PolicyRegistrationException (org.mule.runtime.deployment.model.api.policy.PolicyRegistrationException)19 TestPolicyProcessor.invocationCount (org.mule.runtime.module.deployment.internal.TestPolicyProcessor.invocationCount)19 MulePluginModel (org.mule.runtime.api.deployment.meta.MulePluginModel)18 MuleArtifactLoaderDescriptorBuilder (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder)17 MuleArtifactLoaderDescriptor (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor)16