Search in sources :

Example 16 with JarFileBuilder

use of org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder 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 17 with JarFileBuilder

use of org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder 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 18 with JarFileBuilder

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

the class ApplicationDeploymentTestCase method deploysLightApplicationWithPluginDependingOnPlugin.

@Test
public void deploysLightApplicationWithPluginDependingOnPlugin() throws Exception {
    ArtifactPluginFileBuilder dependantPlugin = new ArtifactPluginFileBuilder("dependantPlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo.echo").containingClass(pluginEcho3TestClassFile, "org/foo/echo/Plugin3Echo.class").dependingOn(echoPlugin);
    File mavenRepoFolder = Paths.get(getMuleBaseFolder().getAbsolutePath(), "repository").toFile();
    File testGroupIdRepoFolder = Paths.get(mavenRepoFolder.getAbsolutePath(), "org", "mule", "test").toFile();
    JarFileBuilder testJarFileDependency = new JarFileBuilder("echoTestJar", echoTestJarFile);
    copyFile(testJarFileDependency.getArtifactPomFile(), Paths.get(testGroupIdRepoFolder.getAbsolutePath(), "echoTestJar", "1.0.0", "echoTestJar-1.0.0.pom").toFile());
    copyFile(testJarFileDependency.getArtifactFile(), Paths.get(testGroupIdRepoFolder.getAbsolutePath(), "echoTestJar", "1.0.0", "echoTestJar-1.0.0.jar").toFile());
    copyFile(echoPlugin.getArtifactPomFile(), Paths.get(testGroupIdRepoFolder.getAbsolutePath(), "echoPlugin", "1.0.0", "echoPlugin-1.0.0.pom").toFile());
    copyFile(echoPlugin.getArtifactFile(), Paths.get(testGroupIdRepoFolder.getAbsolutePath(), "echoPlugin", "1.0.0", "echoPlugin-1.0.0-mule-plugin.jar").toFile());
    copyFile(dependantPlugin.getArtifactPomFile(), Paths.get(testGroupIdRepoFolder.getAbsolutePath(), "dependantPlugin", "1.0.0", "dependantPlugin-1.0.0.pom").toFile());
    copyFile(dependantPlugin.getArtifactFile(), Paths.get(testGroupIdRepoFolder.getAbsolutePath(), "dependantPlugin", "1.0.0", "dependantPlugin-1.0.0-mule-plugin.jar").toFile());
    final TestArtifactDescriptor artifactFileBuilder = new ApplicationFileBuilder("plugin-depending-on-plugin-app").definedBy("plugin-depending-on-plugin-app-config.xml").dependingOn(dependantPlugin).usingLightWeightPackage();
    addPackedAppFromBuilder(artifactFileBuilder);
    startDeployment();
    assertDeploymentSuccess(applicationDeploymentListener, artifactFileBuilder.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) JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) TestArtifactDescriptor(org.mule.runtime.module.artifact.builder.TestArtifactDescriptor) FileUtils.writeStringToFile(org.apache.commons.io.FileUtils.writeStringToFile) File(java.io.File) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) Test(org.junit.Test)

Example 19 with JarFileBuilder

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

the class ApplicationDeploymentTestCase method deploysAppWithExportedPackagePrecedenceOverPlugin.

@Test
public void deploysAppWithExportedPackagePrecedenceOverPlugin() throws Exception {
    // Defines a plugin that contains org.bar package, which is also exported on the application
    ArtifactPluginFileBuilder echoPluginWithoutLib1 = new ArtifactPluginFileBuilder("echoPlugin1").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo").containingClass(pluginEcho1TestClassFile, "org/foo/Plugin1Echo.class").dependingOn(new JarFileBuilder("barUtils2_0", barUtils2_0JarFile));
    ApplicationFileBuilder sharedLibPluginAppFileBuilder = new ApplicationFileBuilder("shared-plugin-lib-app").definedBy("app-with-echo1-plugin-config.xml").dependingOn(echoPluginWithoutLib1).dependingOnSharedLibrary(new JarFileBuilder("barUtils", barUtils1_0JarFile));
    addPackedAppFromBuilder(sharedLibPluginAppFileBuilder);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, sharedLibPluginAppFileBuilder.getId());
    assertAppsDir(NONE, new String[] { sharedLibPluginAppFileBuilder.getId() }, true);
    assertApplicationAnchorFileExists(sharedLibPluginAppFileBuilder.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) JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) Test(org.junit.Test)

Example 20 with JarFileBuilder

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

the class ApplicationDeploymentTestCase method deploysAppWithPluginSharedLibrary.

@Test
public void deploysAppWithPluginSharedLibrary() throws Exception {
    final ArtifactPluginFileBuilder echoPluginWithoutLib1 = new ArtifactPluginFileBuilder("echoPlugin1").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo").containingClass(pluginEcho1TestClassFile, "org/foo/Plugin1Echo.class");
    final ApplicationFileBuilder sharedLibPluginAppFileBuilder = new ApplicationFileBuilder("shared-plugin-lib-app").definedBy("app-with-echo1-plugin-config.xml").dependingOn(echoPluginWithoutLib1).dependingOnSharedLibrary(new JarFileBuilder("barUtils", barUtils1_0JarFile));
    addPackedAppFromBuilder(sharedLibPluginAppFileBuilder);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, sharedLibPluginAppFileBuilder.getId());
    assertAppsDir(NONE, new String[] { sharedLibPluginAppFileBuilder.getId() }, true);
    assertApplicationAnchorFileExists(sharedLibPluginAppFileBuilder.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) JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) Test(org.junit.Test)

Aggregations

JarFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder)21 Test (org.junit.Test)15 ArtifactPluginFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder)15 ApplicationFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder)13 MuleArtifactLoaderDescriptorBuilder (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder)6 MulePluginModel (org.mule.runtime.api.deployment.meta.MulePluginModel)4 DomainFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.DomainFileBuilder)3 File (java.io.File)2 MulePluginModelBuilder (org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder)2 TestArtifactDescriptor (org.mule.runtime.module.artifact.builder.TestArtifactDescriptor)2 DeployableFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.DeployableFileBuilder)2 FileUtils.copyFile (org.apache.commons.io.FileUtils.copyFile)1 FileUtils.writeStringToFile (org.apache.commons.io.FileUtils.writeStringToFile)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 BeforeClass (org.junit.BeforeClass)1 MuleApplicationClassLoaderFactory (org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoaderFactory)1 DefaultNativeLibraryFinderFactory (org.mule.runtime.deployment.model.internal.nativelib.DefaultNativeLibraryFinderFactory)1 DefaultDomainManager (org.mule.runtime.module.deployment.impl.internal.domain.DefaultDomainManager)1 TestApplicationFactory.createTestApplicationFactory (org.mule.runtime.module.deployment.internal.TestApplicationFactory.createTestApplicationFactory)1 ExtensionCompiler (org.mule.tck.util.CompilerUtils.ExtensionCompiler)1