Search in sources :

Example 31 with ArtifactPluginFileBuilder

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

the class ApplicationDeploymentTestCase method deploysAppWithNotExportedPackageAndPlugin.

@Test
@Issue("MULE-13756")
@Description("Tests that code called form plugin's Processor cannot access internal resources/packages of the application")
public void deploysAppWithNotExportedPackageAndPlugin() throws Exception {
    ArtifactPluginFileBuilder loadsAppResourcePlugin = new ArtifactPluginFileBuilder("loadsAppResourcePlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo").containingClass(loadsAppResourceCallbackClassFile, "org/foo/LoadsAppResourceCallback.class");
    ApplicationFileBuilder nonExposingAppFileBuilder = new ApplicationFileBuilder("non-exposing-app").configuredWith(EXPORTED_PACKAGES, "org.bar1").configuredWith(EXPORTED_RESOURCES, "test-resource.txt").definedBy("app-with-loads-app-resource-plugin-config.xml").containingClass(barUtils1ClassFile, "org/bar1/BarUtils.class").containingClass(barUtils2ClassFile, "org/bar2/BarUtils.class").containingResource("test-resource.txt", "test-resource.txt").containingResource("test-resource.txt", "test-resource-not-exported.txt").dependingOn(loadsAppResourcePlugin);
    addPackedAppFromBuilder(nonExposingAppFileBuilder);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, nonExposingAppFileBuilder.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) Issue(io.qameta.allure.Issue) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 32 with ArtifactPluginFileBuilder

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

the class ApplicationDeploymentTestCase method deploysAppUsingPluginResource.

@Test
public void deploysAppUsingPluginResource() throws Exception {
    final ArtifactPluginFileBuilder pluginWithResource = new ArtifactPluginFileBuilder("resourcePlugin").configuredWith(EXPORTED_RESOURCE_PROPERTY, "/pluginResource.properties").containingResource("pluginResourceSource.properties", "pluginResource.properties");
    final ApplicationFileBuilder resourcePluginAppFileBuilder = new ApplicationFileBuilder("dummyWithPluginResource").definedBy("plugin-resource-app-config.xml").dependingOn(pluginWithResource);
    addPackedAppFromBuilder(resourcePluginAppFileBuilder);
    startDeployment();
    assertDeploymentSuccess(applicationDeploymentListener, resourcePluginAppFileBuilder.getId());
}
Also used : ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) Test(org.junit.Test)

Example 33 with ArtifactPluginFileBuilder

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

the class ApplicationDeploymentTestCase method failsToDeployWithExtensionThatHasNonExistingIdForClassLoaderModel.

@Test
public void failsToDeployWithExtensionThatHasNonExistingIdForClassLoaderModel() throws Exception {
    String extensionName = "extension-with-classloader-model-id-non-existing";
    MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder().setName(extensionName).setMinMuleVersion(MIN_MULE_VERSION);
    builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().setId("a-non-existing-ID-describer").addProperty("aProperty", "aValue").build());
    builder.withBundleDescriptorLoader(createBundleDescriptorLoader(extensionName, MULE_EXTENSION_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID));
    final ArtifactPluginFileBuilder byeXmlExtensionPlugin = new ArtifactPluginFileBuilder(extensionName).describedBy(builder.build());
    ApplicationFileBuilder applicationFileBuilder = new ApplicationFileBuilder("appWithExtensionXmlPluginFails").definedBy("app-with-extension-xml-plugin-module-bye.xml").dependingOn(byeXmlExtensionPlugin);
    addPackedAppFromBuilder(applicationFileBuilder);
    startDeployment();
    assertDeploymentFailure(applicationDeploymentListener, applicationFileBuilder.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) MuleArtifactLoaderDescriptorBuilder(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder) MulePluginModel(org.mule.runtime.api.deployment.meta.MulePluginModel) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 34 with ArtifactPluginFileBuilder

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

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

the class ApplicationDeploymentTestCase method deploysAppWithNotExportedPackageAndPluginWithInterceptors.

@Test
@Issue("MULE-13756")
@Description("Tests that code called form plugin's ProcessorInterceptor cannot access internal resources/packages of the application")
public void deploysAppWithNotExportedPackageAndPluginWithInterceptors() throws Exception {
    File loadsAppResourceInterceptorFactoryClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/LoadsAppResourceInterceptorFactory.java"));
    File loadsAppResourceInterceptorClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/LoadsAppResourceInterceptor.java"));
    ArtifactPluginFileBuilder loadsAppResourceInterceptorPlugin = new ArtifactPluginFileBuilder("loadsAppResourceInterceptorPlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.lalala").containingClass(loadsAppResourceInterceptorFactoryClassFile, "org/foo/LoadsAppResourceInterceptorFactory.class").containingClass(loadsAppResourceInterceptorClassFile, "org/foo/LoadsAppResourceInterceptor.class").containingResource("registry-bootstrap-loads-app-resource-pif.properties", "META-INF/org/mule/runtime/core/config/registry-bootstrap.properties");
    ApplicationFileBuilder nonExposingAppFileBuilder = new ApplicationFileBuilder("non-exposing-app").configuredWith(EXPORTED_PACKAGES, "org.bar1").configuredWith(EXPORTED_RESOURCES, "test-resource.txt").definedBy("app-with-plugin-bootstrap.xml").containingClass(barUtils1ClassFile, "org/bar1/BarUtils.class").containingClass(barUtils2ClassFile, "org/bar2/BarUtils.class").containingResource("test-resource.txt", "test-resource.txt").containingResource("test-resource.txt", "test-resource-not-exported.txt").dependingOn(loadsAppResourceInterceptorPlugin);
    addPackedAppFromBuilder(nonExposingAppFileBuilder);
    startDeployment();
    assertApplicationDeploymentSuccess(applicationDeploymentListener, nonExposingAppFileBuilder.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) FileUtils.writeStringToFile(org.apache.commons.io.FileUtils.writeStringToFile) File(java.io.File) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) SingleClassCompiler(org.mule.tck.util.CompilerUtils.SingleClassCompiler) Issue(io.qameta.allure.Issue) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

ArtifactPluginFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder)41 Test (org.junit.Test)31 ApplicationFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder)27 JarFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder)18 MulePluginModel (org.mule.runtime.api.deployment.meta.MulePluginModel)15 MuleArtifactLoaderDescriptorBuilder (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder)13 File (java.io.File)12 MuleArtifactLoaderDescriptor (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor)10 URISyntaxException (java.net.URISyntaxException)5 MulePluginModelBuilder (org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder)5 CompilerUtils (org.mule.tck.util.CompilerUtils)5 TestArtifactDescriptor (org.mule.runtime.module.artifact.builder.TestArtifactDescriptor)4 PolicyFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder)4 ArrayList (java.util.ArrayList)3 Arrays.asList (java.util.Arrays.asList)3 Collections.emptyList (java.util.Collections.emptyList)3 Collections.emptyMap (java.util.Collections.emptyMap)3 Collections.singletonList (java.util.Collections.singletonList)3 Collections.singletonMap (java.util.Collections.singletonMap)3 List (java.util.List)3