Search in sources :

Example 11 with JarFileBuilder

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

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

the class DeployableArtifactDescriptorFactoryTestCase method readsSharedLibs.

@Test
public void readsSharedLibs() throws Exception {
    DeployableFileBuilder artifactFileBuilder = (DeployableFileBuilder) createArtifactFileBuilder().dependingOnSharedLibrary(new JarFileBuilder("shared", echoTestJarFile));
    unzip(artifactFileBuilder.getArtifactFile(), getArtifactFolder());
    D desc = createArtifactDescriptor();
    assertThat(desc.getClassLoaderModel().getUrls().length, equalTo(2));
    assertThat(toFile(desc.getClassLoaderModel().getUrls()[0]).getPath(), equalTo(getArtifactFolder().toString()));
    assertThat(toFile(desc.getClassLoaderModel().getUrls()[1]).getPath(), endsWith(getArtifactRootFolder() + "test/repository/org/mule/test/shared/1.0.0/shared-1.0.0.jar"));
    assertThat(desc.getClassLoaderModel().getExportedPackages(), contains("org.foo"));
    assertThat(desc.getClassLoaderModel().getExportedResources(), containsInAnyOrder("META-INF/MANIFEST.MF", "README.txt"));
}
Also used : JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) DeployableFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DeployableFileBuilder) Test(org.junit.Test)

Example 13 with JarFileBuilder

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

the class DeployableArtifactDescriptorFactoryTestCase method readsRuntimeLibs.

@Test
public void readsRuntimeLibs() throws Exception {
    DeployableFileBuilder artifactFileBuilder = (DeployableFileBuilder) createArtifactFileBuilder().dependingOn(new JarFileBuilder("runtime", echoTestJarFile));
    unzip(artifactFileBuilder.getArtifactFile(), getArtifactFolder());
    D desc = createArtifactDescriptor();
    assertThat(desc.getClassLoaderModel().getUrls().length, equalTo(2));
    assertThat(toFile(desc.getClassLoaderModel().getUrls()[0]).getPath(), equalTo(getArtifactFolder().toString()));
    assertThat(desc.getClassLoaderModel().getExportedPackages(), is(empty()));
    assertThat(toFile(desc.getClassLoaderModel().getUrls()[1]).getPath(), endsWith(getArtifactRootFolder() + "test/repository/org/mule/test/runtime/1.0.0/runtime-1.0.0.jar"));
}
Also used : JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) DeployableFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.DeployableFileBuilder) Test(org.junit.Test)

Example 14 with JarFileBuilder

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

the class AbstractDeploymentTestCase method beforeClass.

@BeforeClass
public static void beforeClass() throws URISyntaxException, IllegalAccessException {
    barUtils1ClassFile = new SingleClassCompiler().compile(getResourceFile("/org/bar1/BarUtils.java"));
    barUtils1_0JarFile = new JarFileBuilder("barUtils1", new JarCompiler().compiling(getResourceFile("/org/bar1/BarUtils.java")).compile("bar-1.0.jar")).getArtifactFile();
    barUtils2ClassFile = new SingleClassCompiler().compile(getResourceFile("/org/bar2/BarUtils.java"));
    barUtils2_0JarFile = new JarCompiler().compiling(getResourceFile("/org/bar2/BarUtils.java")).compile("bar-2.0.jar");
    echoTestJarFile = new JarCompiler().compiling(getResourceFile("/org/foo/EchoTest.java")).compile("echo.jar");
    defaulServiceEchoJarFile = new JarCompiler().compiling(getResourceFile("/org/mule/echo/DefaultEchoService.java"), getResourceFile("/org/mule/echo/EchoServiceProvider.java")).compile("mule-module-service-echo-default-4.0-SNAPSHOT.jar");
    defaultFooServiceJarFile = new JarCompiler().compiling(getResourceFile("/org/mule/service/foo/DefaultFooService.java"), getResourceFile("/org/mule/service/foo/FooServiceProvider.java")).dependingOn(defaulServiceEchoJarFile.getAbsoluteFile()).compile("mule-module-service-foo-default-4.0-SNAPSHOT.jar");
    helloExtensionV1JarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/hello/HelloExtension.java"), getResourceFile("/org/foo/hello/HelloOperation.java")).including(getResourceFile("/org/foo/hello/registry-bootstrap.properties"), "META-INF/org/mule/runtime/core/config/registry-bootstrap.properties").compile("mule-module-hello-1.0.0.jar", "1.0.0");
    helloExtensionV2JarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/hello/HelloExtension.java"), getResourceFile("/org/foo/hello/HelloOperation.java")).compile("mule-module-hello-2.0.0.jar", "2.0.0");
    echoTestClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/EchoTest.java"));
    loadsAppResourceCallbackClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/LoadsAppResourceCallback.java"));
    pluginEcho1TestClassFile = new SingleClassCompiler().dependingOn(barUtils1_0JarFile).compile(getResourceFile("/org/foo/Plugin1Echo.java"));
    internalIsRunningTests = (Boolean) readDeclaredStaticField(ModuleDelegatingEntityResolver.class, "internalIsRunningTests", true);
    writeDeclaredStaticField(ModuleDelegatingEntityResolver.class, "internalIsRunningTests", true, true);
}
Also used : JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) ExtensionCompiler(org.mule.tck.util.CompilerUtils.ExtensionCompiler) JarCompiler(org.mule.tck.util.CompilerUtils.JarCompiler) SingleClassCompiler(org.mule.tck.util.CompilerUtils.SingleClassCompiler) BeforeClass(org.junit.BeforeClass)

Example 15 with JarFileBuilder

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

the class AbstractDeploymentTestCase method createHelloExtensionV1PluginFileBuilder.

private ArtifactPluginFileBuilder createHelloExtensionV1PluginFileBuilder() {
    MulePluginModelBuilder mulePluginModelBuilder = new MulePluginModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName("helloExtensionPlugin").setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader("helloExtensionPlugin", MULE_EXTENSION_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID, "1.0.0"));
    mulePluginModelBuilder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().setId(MULE_LOADER_ID).build());
    mulePluginModelBuilder.withExtensionModelDescriber().setId(JAVA_LOADER_ID).addProperty("type", "org.foo.hello.HelloExtension").addProperty("version", "1.0.0");
    return new ArtifactPluginFileBuilder("helloExtensionPlugin-1.0.0").dependingOn(new JarFileBuilder("helloExtensionV1", helloExtensionV1JarFile)).describedBy((mulePluginModelBuilder.build()));
}
Also used : ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) MuleArtifactLoaderDescriptorBuilder(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder) JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) MulePluginModelBuilder(org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder)

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